Syntax
Parameters
| Parameter | Description |
|---|---|
IF EXISTS | Prevents an error if the table does not exist. The statement is a no-op when the table is absent. |
schema_name | The name of the attached database containing the table. Defaults to the main database if omitted. |
table_name | The name of the table to drop. |
Description
DROP TABLE permanently removes a table definition along with all data stored in the table. All indexes, triggers, and constraints associated with the table are also removed.
Behavior
- All rows in the table are deleted.
- All indexes built on the table are removed.
- All triggers associated with the table are removed.
- The table entry is removed from the
sqlite_schemasystem table. - If foreign key constraints in other tables reference the dropped table, those references become invalid. Turso does not prevent dropping a table that is referenced by foreign keys elsewhere.
DROP TABLEis not allowed while the table is being read or written by another statement in the same connection.
Examples
Drop a table
Drop a table only if it exists
Drop a table in an attached database
See also
- CREATE TABLE — create a new table
- ALTER TABLE — modify an existing table
- DELETE — remove rows without dropping the table
- DROP INDEX — remove an index