DROP TABLE

To delete a table definition, use the DROP TABLE statement:

DROP TABLE [IF EXISTS] table-name

where:

  • IF EXISTS is optional. If you use this option and the specified table does not exist, the system returns a message:
    
    sql-> drop table if exists foo;
    Statement did not require execution
    
    If you do not specify IF EXISTS , and the table does not currently exist, the DROP statement returns as follows:
    
    sql-> drop table foo;
    Error handling command drop table foo: 
    Error: User error in query: DROP TABLE failed for table foo: 
    Table does not exist: foo
    
    If you specify IF EXISTS, and the table exists, the DROP statement executes successfully:
    
    sql-> create table foo (first string, second integer, primary key (second));
    Statement completed successfully
    sql-> drop table if exists foo;
    Statement completed successfully
  • table-name is the name of the table you want to drop.

As soon as you execute the DROP TABLE statement, users can no longer access the deleted table or its data. Deleting all of the table data occurs asynchronously in the background after you execute the DROP TABLE statement.

If you choose to drop an MR Table in a particular region, it still continues to remain an MR Table in the other participating regions. In a case where you want to drop a particular MR Table from multiple regions, you must execute the DROP TABLE statement in each region separately.

Note:

In a case where an MR Table is dropped in all remote regions but still exists in local region, it still continues to be an MR Table linked with a single region. Such an MR Table with a single region can be expanded to more regions in future. That is, you can add new regions to this table in future, as needed.

If the table to drop has child tables, you must drop those first. For example, if you have these tables:

  • myTable

  • myTable.childTable1

  • myTable.childTable2

You must first drop myTable.childTable1 and myTable.childTable2 before you can drop the parent myTable. If you try to drop the parent, the statement returns an error.