Browse documentation

Browse and edit

Structure

The Structure tab shows a table's columns, keys, indexes, constraints, triggers and definition. Changes to columns, indexes and keys wait as pending changes until you preview and commit them, the same way row edits do.

Where to find it

ActionHow
Open a table's structureStructure at the bottom of a table tab, ⌘⌃] (Ctrl+Alt+]), View → Structure, or Open Structure in the table's sidebar context menu
Return to the rowsData, or ⌘⌃[ (Ctrl+Alt+[)
Create a table or viewThe Create object button above the sidebar catalog, then New table... or New view...
Rename, truncate or drop a tableRename..., Truncate... or Drop... in the table's sidebar context menu
Read the definitionDefinition in the structure header
Preview pending changesPreview, or ⌘⇧P (Ctrl+Shift+P)
Commit pending changesCommit, or ⌘S (Ctrl+S)

Reading a table's structure

The header shows the schema and table name, a kind badge such as Table, an estimated row count and the table's size. Below it, Columns, Primary key, Indexes, Foreign keys, Constraints and Triggers each have a heading with a count. The columns grid lists each column's name, type, nullability, default, identity or generated attribute, comment and key roles, and on MySQL it adds unsigned, collation, on update, generated and auto increment details. Expand an index, foreign key, constraint or trigger to read its full definition.

The orders table in the Structure tab: the header with its row estimate and size, and the columns grid listing id, customer_id, status, placed_at, placed_unix, total, shipping_address and updated_at with their types, nullability and defaults.
Columns come first, followed by the key, index, constraint and trigger sections.
The Indexes section of orders listing the primary key index and orders_placed_at_idx on placed_at, and the Triggers section listing orders_updated_at.
Each index shows its columns and properties, and each trigger shows when it fires and what it runs.

Changing columns

Column above the grid adds a column, and so does ⌘I (Ctrl+I). Double-click a cell or press Enter to edit a name, type or default, and select columns and choose Drop to mark them for removal. Each change is highlighted, and the bar above the tab counts them, for example 3 changes, next to Discard, Preview and Commit. Preview opens SQL preview with the exact ALTER TABLE statements, and Index and Foreign key in their section headings add to the same set of changes.

New and changed columns stay pending until you preview and commit them.

Creating tables and views

New table... opens New table, where each column gets a name, type, default, nullability and primary key choice, and Preview shows the CREATE TABLE statement before you choose Create table. New view... opens New view with a name, a query editor and a Statement preview, and Create view runs it. Both run as soon as you confirm, without waiting in the pending changes.

Renaming, truncating and dropping

Rename... shows the rename statement for the new name and runs it when you choose Rename. Truncate... and Drop... always open a confirmation that names the table and shows the Exact statement, whatever the safe mode setting. On PostgreSQL the confirmation adds CASCADE, truncate also adds RESTART IDENTITY, and the statement changes as you tick them. On a connection tagged Production you also type the table name before Truncate or Drop is available.

The truncate confirmation for a table, with This removes every row immediately., the exact TRUNCATE statement, and RESTART IDENTITY and CASCADE checkboxes.
Truncate confirms every time, even with safe mode off.

Definition

Definition in the structure header opens the table's full definition in a side panel, and Copy puts it on the clipboard. On MySQL and MariaDB the panel is titled SHOW CREATE.

Good to know

  • PostgreSQL, CockroachDB, SQL Server and SQLite commit structure changes in one transaction.
  • MySQL, MariaDB, TiDB, Oracle, ClickHouse and Snowflake cannot roll back DDL. Commit opens the preview first, with a warning that earlier statements stay applied if a later one fails, and the create, rename, truncate and drop dialogs show the same warning.
  • On SQLite, changing a column other than renaming it, adding or removing a key or constraint, or dropping a column that belongs to a key or index rebuilds the table, and the preview says This change rebuilds the table.
  • With safe mode on, creating, renaming and committing structure changes also ask before they run.
  • On a read-only connection the editing controls are disabled and explain Connection is read-only.
  • Cloudflare D1 does not support graphical structure changes. Run DDL in the SQL editor instead.
  • The schema diagram draws the same keys across tables. Native workspaces such as MongoDB and Redis have no Structure tab.