DROP TABLE

Delete the table.

Summary

DROP TABLE [IF EXISTS] name [, ...] [CASCADE | RESTRICT]

describe

DROP TABLE Deletes tables from the database. Only table owners, schema owners and superusers can delete tables. To clear the row table without deleting the table definition, use DELETE or TRUNCATE.

DROP TABLE always deletes all indexes, rules, triggers, and constraints that exist in the target table. However, to delete a table referenced by a view, CASCADE must be specified. CASCADE will completely remove the dependent view.

Parameters

IF EXISTS

  • If the table does not exist, please do not report an error. In this case, a notification will be issued.

name

  • The name of the table to be deleted (can be specified by the schema).

CASCADE

  • Automatically delete table-dependent objects (such as views).

RESTRICT

  • If there are any object dependencies tables, the table is denied. This is the default value.

Example

Delete table mytable:

DROP TABLE mytable;

compatibility

DROP TABLE is fully compliant with the SQL standard, but this standard only allows one table to be deleted per command. Additionally, the IF EXISTS option is a YMatrix database extension.

See also

ALTER TABLE, CREATE TABLE