Open topic with navigation
DROP TABLE — remove a table
DROP TABLE [IF EXISTS] [CASCADE | RESTRICT] [
table_nameDROP TABLE [
table_name[IF EXISTS] [CASCADE | RESTRICT]
DROP TABLE statement to remove the table and all its data from the database entirely.
Only its owner may remove a table. A table may be emptied of rows, but not removed, by using
DELETE. You can also use
DROP TABLE always removes any indexes, triggers, and constraints that exist for the target table. However, to drop a table that is referenced by a view
CASCADE must be specified.
RESTRICT can occur before or after
table_name, but not both.
Optional. The name of the schema that owns the table to be dropped. If schema is not provided, the table must be owned by the current schema.
Name (optionally schema-qualified) of an existing table to drop.
If the table does not exist and you specify
IF EXISTS, NuoDB does not generate an error. If not specified and the table does not exist, an error is generated.
Automatically drop objects that are referencing the table attempting to be dropped (such as a
FOREIGN KEY constraint, etc). For example, you cannot drop a table that is referenced by another table in a
FOREIGN KEY constraint. In order to drop the referenced table, you need to use the
CASCADE option. This will drop the
FOREIGN KEY constraint on the referencing table first, and then drop the table.
Refuse to drop the table if there are any dependent objects. This is the default.
USE HOCKEY DROP TABLE hockey_fan;can't find table "HOCKEY_FAN"
DROP TABLE IF EXISTS hockey_fan; CREATE TABLE hockey_fan (id INTEGER GENERATED ALWAYS AS IDENTITY, name STRING ); CREATE VIEW vw_hockey_a AS SELECT * FROM hockey_fan WHERE name LIKE 'A%'; DROP TABLE hockey_fan;can't drop table HOCKEY.HOCKEY_FAN -- referenced in view for HOCKEY.VW_HOCKEY_A
DROP TABLE hockey_fan CASCADE;