Skip to content

DROP TABLE

The statement removes a table from the database.

Dependent objects become invalid when a table is dropped.

The table to be dropped must be located in a folder.

See also CREATE TABLE, ALTER TABLE, DELETE, TRUNCATE.

Syntax

sql
DROP TABLE folder.table_name;

Parameters

folder: The name of the folder.


table_name: The name of the table to be dropped.

Usage Notes

When DROP TABLE is executed for a table, the following operations occur:

  • All rows from the table are deleted.

If the table is a base table for a view or if it is referenced in a stored procedure or function, these dependent objects are considered invalid but are not deleted. These objects can no longer be used unless the table is recreated. Such objects must be deleted and recreated to no longer depend on the table. If the table that had dependent objects is to be recreated, it must contain all columns selected by the subqueries originally used to define the views, as well as all columns referenced in the stored procedures or functions, so that the corresponding objects can be used correctly.

Example

sql
create table mkw_doku.my_table (ord string, col1 integer);
insert into mkw_doku.my_table  (ord,col1)             
       values ('a',10);                               
insert into mkw_doku.my_table  (ord,col1)               
       values ('b',20);                               
insert into mkw_doku.my_table  (ord,col1)               
       values ('c',30);                                 
select ord, col1 
    from mkw_doku.my_table;

drop table mkw_doku.my_table; 
output
Table 'mkw_doku.my_table' was dropped