Purpose
This statement is used to delete a table from OceanBase Database.
Syntax
DROP {TABLE | TABLES} [TEMPORARY] [IF EXISTS]
table_name [,table_name]...
[RESTRICT | CASCADE]
Parameters
| Parameter | Description |
|---|---|
| table_name | The name of the table to be deleted. When deleting multiple tables, separate them with commas. |
| TEMPORARY | Indicates that the temporary table is to be deleted.
Note
|
| IF EXISTS | If you specify IF EXISTS, no error will be returned even if the table to be deleted does not exist. If you do not specify this option, an error will be returned. |
| RESTRICT | CASCADE | Used in scenarios where tables are migrated from other databases to OceanBase Database. Note This parameter is not supported in the current version. If specified, it will be parsed and ignored. |
Examples
Specify
IF EXISTSto delete thetest1table.obclient> DROP TABLE IF EXISTS test1; Query OK, 0 rows affectedSpecify
IF EXISTSto delete thetest1andtest2tables.obclient> DROP TABLES IF EXISTS test1,test2; Query OK, 0 rows affectedDelete multiple tables without specifying
IF EXISTS. If any of the tables does not exist, an error will be returned.obclient> DROP TABLES test1,test2; ERROR 1051 (42S02): Unknown table 'test.test2'Delete the temporary table
tset3.obclient> DROP TEMPORARY TABLE test3; Query OK, 0 rows affected