> ## Documentation Index
> Fetch the complete documentation index at: https://ngquct-docs-fix-500-query-results.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Table Operations

> Drop, truncate, run maintenance, manage views, and switch databases from the sidebar

Dropping a table cannot be undone, and **Cascade** in the confirmation dialog widens it to every table that depends on this one. The dialog runs nothing on its own, though: the drop is staged on the table's row and reaches the server when you save.

## Create a table or view

**Database > New Table…** opens the visual structure editor (see [Table Structure](/features/table-structure)). **Database > New View…** opens a query tab holding a `CREATE VIEW` template for the engine. Both are also on the sidebar's right-click menu over empty space, and both are dimmed while [safe mode](/features/safe-mode) blocks writes.

## Drop and truncate

Right-click a table and choose **Delete** to drop it, or **Truncate** to empty it and keep the structure. **Database > Truncate Table** and `Option+Delete` do the same. Cmd-click to select several tables first and one confirmation covers all of them, with the same options applied to each.

| Option                    | Effect                                                                                                                                                  |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Ignore foreign key checks | Skips constraint checks. Dimmed where the engine has no equivalent, and PostgreSQL's dialog points at Cascade instead                                   |
| Cascade                   | On a drop, takes every table that depends on this one. On a truncate, takes every table linked by a foreign key. Dimmed where the engine has no CASCADE |

Confirming with **Drop** or **Truncate** stages the operation. The row picks up a red minus badge for a pending drop, an orange exclamation badge for a pending truncate. **Preview SQL** (`Cmd+Shift+P`) shows the statements, **Save Changes** (`Cmd+S`) runs them alongside any pending cell edits, and choosing the same menu item again takes the table back out of the queue.

<Frame caption="Drop table confirmation with options">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/hA72m8tSnRe3b-ew/images/drop-table-dialog.png?fit=max&auto=format&n=hA72m8tSnRe3b-ew&q=85&s=3fbc8ff8d90f2b18f2223dfa7e50ef5d" alt="Drop table dialog" width="1560" height="960" data-path="images/drop-table-dialog.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/hA72m8tSnRe3b-ew/images/drop-table-dialog-dark.png?fit=max&auto=format&n=hA72m8tSnRe3b-ew&q=85&s=b4a5a6d1552ea287ae4b27f699db56d3" alt="Drop table dialog" width="1560" height="960" data-path="images/drop-table-dialog-dark.png" />
</Frame>

<Danger>
  Dropping is irreversible. On MySQL and MariaDB, truncate also resets the auto-increment counter. Back up important data first.
</Danger>

## Maintenance

Right-click a table, choose **Maintenance**, and pick an operation. A sheet shows the operation's options and the exact SQL before it runs.

| Database        | Operations                                               |
| --------------- | -------------------------------------------------------- |
| PostgreSQL      | VACUUM, ANALYZE, REINDEX, CLUSTER                        |
| MySQL / MariaDB | OPTIMIZE TABLE, ANALYZE TABLE, CHECK TABLE, REPAIR TABLE |
| SQLite          | VACUUM, ANALYZE, REINDEX, Integrity Check                |

PostgreSQL VACUUM carries FULL (rewrites the table and blocks access), ANALYZE, and VERBOSE toggles. MySQL CHECK TABLE offers QUICK, FAST, MEDIUM (the default), EXTENDED, and CHANGED. No other engine reports maintenance operations, so the submenu is hidden there, and in read-only safe mode.

## Views

Views carry an eye icon in the sidebar; materialized views and foreign tables get their own. All three are read-only kinds, so their menus drop **Truncate** and **Import**, and the drop item reads **Drop View**, **Drop Materialized View**, or **Drop Foreign Table**. Dropping removes the definition only, and the data in the underlying tables stays.

Right-click empty space and choose **Create New View…** to write a new one; right-click an existing view and choose **Edit View Definition** to open the current definition in a query tab. Either way, execute the statement to apply it.

## Databases and schemas

`Cmd+K` switches database, covered in [Managing Connections](/connections#switch-connections-and-databases). The switcher takes the engine's own vocabulary: Schema on Oracle, Keyspace on Cassandra, Dataset on BigQuery, Namespace on SurrealDB. SQLite is file-based, so it points at the welcome window to open a different file.

<Frame caption="Database switcher with search">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/hA72m8tSnRe3b-ew/images/database-switcher.png?fit=max&auto=format&n=hA72m8tSnRe3b-ew&q=85&s=3ec92ff4540dc0bf1e685fae13d126e9" alt="Database switcher popover" width="1560" height="960" data-path="images/database-switcher.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/hA72m8tSnRe3b-ew/images/database-switcher-dark.png?fit=max&auto=format&n=hA72m8tSnRe3b-ew&q=85&s=15b11056722af23566fc84f6e66229ed" alt="Database switcher popover" width="1560" height="960" data-path="images/database-switcher-dark.png" />
</Frame>

**New Database…** at the bottom of the switcher creates one. Its fields come from the driver: MySQL and MariaDB ask for a name, character set, and collation; other engines show their own. The button is absent where the engine cannot create databases.

To drop one, right-click it in the switcher or the sidebar tree and choose **Drop Database “name”…**. The item is missing for system databases and for the database you are connected to, so switch away first.

<Danger>
  Dropping a database permanently deletes every table in it. The server rejects the drop if your account lacks the privilege.
</Danger>

### Several at once

Shift-click for a range, Cmd-click to add or remove one, and the menu counts what it covers: **Drop 3 Databases…**, **Copy 3 Names**. **Refresh** reloads every selected database. **Export…** opens the export dialog with every table of the selected database already selected, one database at a time; it is absent on DuckDB and PGlite for any database other than the active one. **Use as Active Database** appears only when a single row is selected and it is not already active.

Databases the server will not drop are left out of the drop item. A drop that fails partway finishes the rest, then reports which ones failed and why.

### Schemas

On engines that group tables by schema, the same menu appears on a schema row: PostgreSQL, SQL Server, SurrealDB, and Dameng. PostgreSQL and Dameng drop the schema with `CASCADE`. SQL Server has no cascade, so it refuses to drop a schema that still holds objects; drop those first.

<Danger>
  Dropping a schema permanently deletes everything in it. On PostgreSQL and Dameng it also drops objects in other schemas that depend on it.
</Danger>
