Purpose
This statement is used to drop a table in 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 dropped. When dropping multiple tables, separate the table names with commas. |
| TEMPORARY | Indicates that a temporary table is to be dropped.
Note
|
| IF EXISTS | If you specify IF EXISTS, an error is not returned when the table to be dropped does not exist. If you do not specify this option, an error is 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 drop thetest1table.obclient> DROP TABLE IF EXISTS test1; Query OK, 0 rows affectedSpecify
IF EXISTSto drop thetest1andtest2tables.obclient> DROP TABLES IF EXISTS test1,test2; Query OK, 0 rows affectedDo not specify
IF EXISTS. If any of the tables to be dropped does not exist, an error is returned.obclient> DROP TABLES test1,test2; ERROR 1051 (42S02): Unknown table 'test.test2'Drop the temporary table
tset3.obclient> DROP TEMPORARY TABLE test3; Query OK, 0 rows affected
