This topic describes how to drop a table in OceanBase Database in MySQL mode.
Prerequisites
The current user has the DROP privilege for the target table.
Syntax
DROP [TEMPORARY] {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. |
| TEMPORARY | If TEMPORARY is specified, the target table is dropped even if it is a temporary table. |
| RESTRICT | CASCADE | This parameter is applicable when you migrate data from other databases to OceanBase Database.
Note |
Example
Show the
studenttable.obclient> show tables; +---------------------------+ | Tables_in_ny | +---------------------------+ | dws_ai_ny | | dws_ny | | item | | ny_mv | | s | | s3 | | sequence | | staff | | staff_copy | | staff_dc | | staff_like | | student | | student_seq | | t1_like | | t2 | | t3 | | t4 | | t5 | | t_key_ny | | t_log_part_by_range_hash | | t_lu | | t_lu1 | | t_ny | | t_ordr_part_by_hash_range | | tb_key | | yhkh | +---------------------------+ 26 rows in setDrop the
studenttable.DROP TABLE student;View the results.
obclient> show tables; +---------------------------+ | Tables_in_ny | +---------------------------+ | dws_ai_ny | | dws_ny | | item | | ny_mv | | s | | s3 | | sequence | | staff | | staff_copy | | staff_dc | | staff_like | | student_seq | | t1_like | | t2 | | t3 | | t4 | | t5 | | t_key_ny | | t_log_part_by_range_hash | | t_lu | | t_lu1 | | t_ny | | t_ordr_part_by_hash_range | | tb_key | | yhkh | +---------------------------+ 25 rows in set