Categories:
DDL Commands

DROP <object>

Removes the specified object from the system.

See also:
CREATE <object> , SHOW <objects>

Syntax

DROP <object_type> [ IF EXISTS ] <identifier>  [ CASCADE | RESTRICT ]

For specific syntax, usage notes, and examples, see:

Account Objects:

Database Objects:

General Usage Notes

  • The DROP command can include an IF EXISTS clause. If specified and the target object does not exist, the command does not return an error and completes successfully.
  • The CASCADE | RESTRICT parameters apply only to databases, schemas, and tables, and is used to specify whether the object can be dropped if foreign keys that reference the object exist:
    • CASCADE drops the object, along with all the foreign keys that reference the object.
    • RESTRICT returns a warning and does not drop the object.

Examples

DROP DATABASE mydb;

DROP DATABASE IF EXISTS mydb;

DROP DATABASE IF EXISTS mydb RESTRICT;

DROP DATABASE IF EXISTS mydb CASCADE;