-
-
Notifications
You must be signed in to change notification settings - Fork 2
database.dropTable()
Oxford Harrison edited this page Nov 15, 2024
·
5 revisions
DOCS • API • Database API
Programmatically perform a DROP TABLE operation.
See related ➞ DROP TABLE
database.dropTable(
name: string,
options?: DropOptions
): Promise<DropTableResult>;| Param | Interfaces | Description |
|---|---|---|
name |
- | An existing table name. |
options? |
DropOptions |
Optional extra parameters for the query. |
type DropOptions = {
ifExists?: boolean;
cascade?: boolean;
restrict?: boolean;
} & QueryOptions;| Param | Interfaces | Description |
|---|---|---|
ifExists? |
- | An optional flag that adds an EXISTS check to the operation. Defaults to false. |
cascade? |
- |
(PostgreSQL) An optional flag that adds a CASCADE clause to the operation. Defaults to false. |
restrict? |
- |
(PostgreSQL) An optional flag that adds a RESTRICT clause to the operation. Defaults to false. |
| Interface | Description |
|---|---|
| QueryOptions | Inherited options. |
type DropTableResult = boolean | TableSchema | Savepoint | null;| Type | Interfaces | Description |
|---|---|---|
boolean |
- | The boolean true—the default result type for DDL operations without a RETURNING clause. |
TableSchema |
TableSchema |
For an operation with a RETURNING clause set to SCHEMA-the resulting database schema instance. |
Savepoint | null |
Savepoint |
For an operation with a RETURNING clause set to SAVEPOINT-the Savepoint instance associated with the DDL operation; null when savepoint creation has been disabled at the server level. |
See examples ➞ DROP TABLE
Drop a table:
await database.dropTable(
'table_1',
{ desc: 'Drop description' }
);