> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tablepro.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Table Operations

> Drop, truncate, maintenance, create 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.

## Create Table

Click the plus button in the bottom-left of the Tables sidebar and choose **New Table** (or **New View**) to open a create tab. The button is disabled while safe mode blocks writes.

## Drop Table

Permanently deletes a table and all its data.

Right-click the table (or select multiple) > **Delete**, confirm in the dialog, click **OK**. Irreversible - back up first.

<Frame caption="Drop table confirmation with options">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/drop-table-dialog.png" alt="Drop table dialog" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/drop-table-dialog-dark.png" alt="Drop table dialog" />
</Frame>

<Warning>
  Dropping a table is irreversible. Always backup important data before dropping tables.
</Warning>

## Truncate Table

Removes all rows while keeping the table structure.

1. Right-click the table (or select multiple tables)
2. Select **Truncate**
3. Configure options in the confirmation dialog
4. Click **OK** to execute

<Note>
  Truncate is faster than `DELETE FROM table` because it skips per-row delete logs. It also resets auto-increment counters.
</Note>

<Frame caption="Truncate table confirmation with options">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/truncate-table-dialog.png" alt="Truncate table confirmation with options" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/truncate-table-dialog-dark.png" alt="Truncate table confirmation with options" />
</Frame>

## Maintenance

Right-click a table > **Maintenance** to run database maintenance operations. A confirmation sheet shows operation 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 options for FULL (rewrites the table, blocks access), ANALYZE (updates statistics), and VERBOSE (prints progress).

MySQL CHECK TABLE supports check modes: QUICK, FAST, MEDIUM, EXTENDED, CHANGED.

<Note>
  Maintenance is disabled in Read-Only Safe Mode. Databases without maintenance support (Redis, MongoDB, etc.) do not show this submenu.
</Note>

## Batch Operations

Hold `Cmd` and click to select multiple tables, then right-click and choose **Delete** or **Truncate**. The same options apply to all selected tables.

## View Management

Views appear in the sidebar with an eye icon and purple color.

### Create View

1. Right-click in the sidebar > **Create New View\...** (or **File** > **New View\...**)
2. A SQL editor tab opens with a CREATE VIEW template adapted to your database type
3. Modify the view name and SELECT query
4. Execute to create

<Frame caption="Create View with SQL template">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/create-view-editor.png" alt="Create View with SQL template" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/create-view-editor-dark.png" alt="Create View with SQL template" />
</Frame>

### Edit View Definition

Modify an existing view's SQL definition:

1. Right-click the view in the sidebar
2. Select **Edit View Definition**
3. The current view definition opens in a new SQL editor tab
4. Modify the query and execute to update the view

<Note>
  For MySQL/MariaDB, use `ALTER VIEW` to modify a view. For PostgreSQL, use `CREATE OR REPLACE VIEW`. SQLite does not support ALTER VIEW. Drop and recreate the view instead.
</Note>

### Drop View

Right-click the view > **Drop View** > confirm. Dropping a view only removes the definition; underlying table data stays intact.

### Context Menu Differences

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

<Frame caption="View-specific context menu options">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/view-context-menu.png" alt="View-specific context menu options" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/view-context-menu-dark.png" alt="View-specific context menu options" />
</Frame>

## Database Operations

Create a new database (MySQL/MariaDB): click the database name in the toolbar or press `Cmd+K`, click **Create**, enter a name, character set, and collation.

<Frame caption="Create database dialog">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/create-database.png" alt="Create Database" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/create-database-dark.png" alt="Create Database" />
</Frame>

### Database Switcher

Click the database name in the toolbar to browse databases on the current connection. Search by name, view recent databases, or double-click to switch.

<Frame caption="Database switcher with search and recent databases">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/database-switcher.png" alt="Database switcher with search and recent databases" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/database-switcher-dark.png" alt="Database switcher with search and recent databases" />
</Frame>

### Drop Database

Drop a database from the database switcher (shipped v0.33.0). Three entry points:

* Right-click a database and select **Drop Database**
* Select a database and click the trash icon in the switcher toolbar
* Select a database and press `Delete`

A confirmation dialog appears with a destructive (red) action button and the database name typed in the prompt. The current database cannot be dropped: switch to another one first.

<Warning>
  Dropping a database is irreversible. Whether the action succeeds depends on the connected user's privileges (`DROP` on MySQL/MariaDB, `DROPDB` or owner on PostgreSQL). Permission errors surface inline.
</Warning>

## MongoDB Collections

### Create Collection

Use the MQL editor. For collections with specific options (capped, validator):

```javascript theme={null}
db.createCollection("myCollection", {
  capped: true,
  size: 1048576,
  max: 1000
})
```

### Drop Collection

Right-click a collection in the sidebar and select **Drop Table**. This executes `db.collection.drop()` and removes all documents and indexes.

### Show All Collections

Select **Show All Tables** from the sidebar to list all collections in the current database.

<Note>
  Truncate is not available for MongoDB. To remove all documents while keeping the collection, use `db.collection.deleteMany({})` in the MQL editor.
</Note>
