Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions docs/tables/create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,43 @@ If you forget the name of your table, you can always get a listing of all table
</CodeBlock>
</CodeGroup>

### List tables in pages

Python's `db.list_tables()` and the TypeScript `db.listTables()` method return one
page of table names at a time, along with an opaque `pageToken` that resumes the
listing. Use these when a database holds enough tables that a single response is
not practical. The TypeScript `db.tableNames()` method still works but is
deprecated in favor of `db.listTables()`.

Treat the `pageToken` as opaque. Do not construct or parse it. A page can hold
fewer entries than `limit` and still not be the last one, so keep going until
the response no longer carries a `pageToken`.

<Warning>
`listTables` and `list_tables` return tables in an arbitrary, backend-defined
order, not lexicographical order. If you need a stable alphabetical listing
with `startAfter` semantics, use the deprecated `tableNames` in TypeScript or
`table_names` in Rust, which retain that behavior.
</Warning>

Walk the pages until the response no longer carries a `pageToken`:

```typescript TypeScript icon="square-js"
const names: string[] = [];
let pageToken: string | undefined = undefined;
do {
const page = await db.listTables({ pageToken, limit: 100 });
names.push(...page.tables);
pageToken = page.pageToken;
} while (pageToken);
```

To list tables inside a namespace, pass the namespace path first:

```typescript TypeScript icon="square-js"
const page = await db.listTables(["prod", "search"], { limit: 100 });
```

## Drop a table

Use the `drop_table()` method on the database to remove a table.
Expand Down
Loading