DROP TABLE

2023-12-25 08:49:41  Updated

Purpose

You can use this statement to drop tables from OceanBase Database.

Syntax

DROP {TABLE | TABLES} [IF EXISTS]
table_name [,table_name]...
[RESTRICT | CASCADE]

Parameters

Parameter Description
table_name The name of the table to be dropped. Multiple table names must be separated with commas (,).
IF EXISTS If IF EXISTS is specified, no error is returned even if the table to be dropped does not exist. Otherwise, an error is returned.
RESTRICT | CASCADE This parameter is applicable when you migrate data from other databases to OceanBase Database.
Note: The current version does not support this parameter. If this parameter is specified, it will be parsed and ignored.

Examples

  • Drop the test1 table with IF EXISTS specified.

    obclient> DROP TABLE IF EXISTS test1;
    Query OK, 0 rows affected
    
  • Drop tables test1 and test2 with IF EXISTS specified.

    obclient> DROP TABLES IF EXISTS test1,test2;
    Query OK, 0 rows affected
    
  • Drop multiple tables without specifying IF EXISTS. If a table does not exist, an error is returned.

    obclient> DROP TABLES test1,test2;
    ERROR 1051 (42S02): Unknown table 'test.test2'
    

Contact Us