Skip to content

database.dropTable()

Oxford Harrison edited this page Nov 11, 2024 · 5 revisions

DOCSAPIDatabase API


Programmatically perform a DROP TABLE operation.

See ➞ DROP TABLE

Syntax

database.dropTable(
    name: string,
    options?: DropOptions
): Promise<DDLResult>;
Param Interfaces Description
name - An existing table name.
options? DropOptions Optional extra parameters for the query.
Interface Description
DDLResult The result type for DDL operations.

DropOptions

type DropOptions = {
    ifExists?: boolean;
    cascade?: boolean;
} & QueryOptions;
Param Interfaces Description
ifExists? - An optional flag that adds an EXISTS check to the operation. Defaults to false.
cascade? - An optional flag that adds a CASCADE clause to the operation. Defaults to false.
Interface Description
QueryOptions Inherited options.

Usage

Drop a table:

const savepoint = await database.dropTable(
    'table_1',
    { desc: 'Dropping for test purposes' }
);

Force-drop, if exits:

const savepoint = await database.dropTable(
    'table_1',
    { desc: 'Dropping for test purposes', ifExists: true, cascade: true }
);
Clone this wiki locally