# Time travel and branches: SELECT ... AS OF, CREATE DATABASE ... BRANCH OF
> Read a table as it was at an earlier time or commit, undo a bad change with one query, and make a full writable copy of a database in a moment, without copying its files.
- Category: Databases & folders
- Keywords: AS OF, AS OF TIMESTAMP, AS OF LSN, AS OF SYSTEM TIME, FOR SYSTEM\_TIME AS OF, time travel, flashback, read the past, table as it was, undo, undo a bad import, point in time, BRANCH OF, branch, clone, copy database, zero-copy, test copy, hard link, keep\_versions, KARELADB\_KEEP\_VERSIONS, no longer kept
- See also: [Databases and the data folder](databases.md), [Change stream and live subscriptions: changes('t'), GET /api/changes, GET /api/subscribe](change-stream.md), [Backup, check, repair and restore](backup-and-safety.md), [kareladb serve](cli-serve.md), [The trash - UNDROP TABLE](trash.md)
KarelaDB never changes a data file once it is written. Each checkpoint writes the changed files anew and keeps the older versions for a while. With those and the log, KarelaDB can show a table **as it was**, and make a new database from another one **without copying** its files.
| You want | Write |
|---|---|
| a table as it was at a time | `SELECT ... FROM t AS OF TIMESTAMP '2026-09-25 14:30'` (or `AS OF '2026-09-25 14:30'`) |
| a table as it was after a commit | `SELECT ... FROM t AS OF LSN 12345` |
| undo a bad change | `INSERT OR REPLACE INTO t SELECT * FROM t AS OF TIMESTAMP '...'` |
| a copy of a database to try things on | `CREATE DATABASE test BRANCH OF live` |
| a copy of a database as it was | `CREATE DATABASE before BRANCH OF live AS OF TIMESTAMP '...'` |
## SELECT ... AS OF
Syntax:
```sql
SELECT ... FROM