> ## Documentation Index
> Fetch the complete documentation index at: https://ngquct-feat-ai-sql-walkthroughs.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

# Table Operations

Right-click tables in the sidebar to drop, truncate, run maintenance, or manage views. Switch between databases on the same connection with Cmd+K.

## Create Table or View

Click the plus button in the bottom-left of the sidebar and choose **New Table** or **New View**. New Table opens the visual structure editor (see [Table Structure](/features/table-structure)). New View opens a SQL editor tab with a CREATE VIEW template for your database type. The button is disabled while [safe mode](/features/safe-mode) blocks writes.

## Drop and Truncate

Right-click a table and choose **Delete** to drop it, or **Truncate** to remove all rows while keeping the structure. Hold Cmd and click to select multiple tables; the same options apply to all of them.

A confirmation dialog shows two checkboxes:

| Option                    | Effect                                                                                                         |
| ------------------------- | -------------------------------------------------------------------------------------------------------------- |
| Ignore foreign key checks | Skips foreign key constraint checks. Grayed out on engines without it (PostgreSQL suggests Cascade instead).   |
| Cascade                   | Drops or truncates tables linked by foreign keys. Only enabled on engines that support it, such as PostgreSQL. |

Click **Drop** or **Truncate** to execute, or **Cancel**.

<Frame caption="Drop table confirmation with options">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-feat-ai-sql-walkthroughs/REI9tfF_TGivM099/images/drop-table-dialog.png?fit=max&auto=format&n=REI9tfF_TGivM099&q=85&s=feaaacc7d74d2520cf8159bafab80035" 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-feat-ai-sql-walkthroughs/REI9tfF_TGivM099/images/drop-table-dialog-dark.png?fit=max&auto=format&n=REI9tfF_TGivM099&q=85&s=4736d5eb7e6d3880bf982a356cfafb81" alt="Drop table dialog" width="1560" height="960" data-path="images/drop-table-dialog-dark.png" />
</Frame>

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

## Maintenance

Right-click a table > **Maintenance** and pick an operation. A sheet shows the operation's options and a SQL preview before executing.

| 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 has FULL (rewrites the table, blocks access), ANALYZE (updates statistics), and VERBOSE (prints progress) toggles. MySQL CHECK TABLE offers QUICK, FAST, MEDIUM, EXTENDED, and CHANGED modes.

<Note>
  The Maintenance submenu is hidden in read-only safe mode and on databases with no maintenance operations.
</Note>

## Views

Views appear in the sidebar with an eye icon in your accent color. Materialized views and foreign tables get their own icons. All three are read-only kinds: their context menus hide **Truncate** and **Import**, and the drop item is labeled **Drop View**, **Drop Materialized View**, or **Drop Foreign Table**.

| Action               | Tables | Views |
| -------------------- | ------ | ----- |
| Show Structure       | Yes    | Yes   |
| Export               | Yes    | Yes   |
| Import               | Yes    | No    |
| Truncate             | Yes    | No    |
| Edit View Definition | No     | Yes   |
| Delete / Drop View   | Yes    | Yes   |

* **Create**: right-click in the sidebar > **Create New View\...** (or **File** > **New View\...**). A SQL editor opens with a CREATE VIEW template; edit the name and SELECT, then execute.
* **Edit**: right-click a view > **Edit View Definition**. The current definition opens in a SQL editor tab; modify and execute to update.
* **Drop**: right-click a view > **Drop View**. Only the definition is removed; underlying table data stays intact.

## Database Operations

### Switch Databases

Click the database name in the toolbar or press `Cmd+K`. Type to filter, move with the arrow keys, then press Return or double-click to switch. `Cmd+R` refreshes the list. The switcher adapts to the engine's vocabulary: Schema on Oracle, Keyspace on Cassandra, Dataset on BigQuery, Namespace on SurrealDB. SQLite is file-based, so the switcher points you to the Welcome window to open a different file.

<Frame caption="Database switcher with search">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-feat-ai-sql-walkthroughs/REI9tfF_TGivM099/images/database-switcher.png?fit=max&auto=format&n=REI9tfF_TGivM099&q=85&s=8de0c68e2c2df4131911d8a5c460f3a5" alt="Database switcher popover" width="1560" height="960" data-path="images/database-switcher.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-feat-ai-sql-walkthroughs/REI9tfF_TGivM099/images/database-switcher-dark.png?fit=max&auto=format&n=REI9tfF_TGivM099&q=85&s=1eb78f879113e0a0d3320d57539d799c" alt="Database switcher popover" width="1560" height="960" data-path="images/database-switcher-dark.png" />
</Frame>

### Create Database

Click **New Database...** at the bottom of the switcher. The form fields come from the driver: MySQL/MariaDB ask for a name, character set, and collation; PostgreSQL, ClickHouse, MongoDB, and others show their own fields. The button only appears on engines that support creating databases.

### Drop Database

Right-click a database in the switcher and choose **Drop Database...**. The item is hidden for system databases and for the database you are currently connected to; switch to another one first. A confirmation dialog shows the database name in its title with a red **Drop Database** button.

<Warning>
  Dropping a database permanently deletes all its tables and data. The server rejects the drop if your account lacks the required privilege.
</Warning>
