DROP TABLE
DROP TABLE;delete table;.
Removes one or more tables and their projections. When you run DROP TABLE
, the change is auto-committed.
Syntax
DROP TABLE [ IF EXISTS ] [[{namespace. | database. }]schema.]table[,...] [ CASCADE ]
Parameters
IF EXISTS
- Specifies not to report an error if one or more of the tables to drop does not exist. Use this clause in SQL scripts to avoid errors on dropping non-existent objects before attempting to create them.
{
namespace.
|
database.
}
- Name of the database or namespace that contains
table
, depending on the mode of the database:- Eon Mode: name of the namespace to which
table
belongs. If unspecified, the namespace is assumed to bedefault_namespace
. - Enterprise Mode: name of the database. If specified, it must be the current database.
- Eon Mode: name of the namespace to which
schema
- Name of the schema, by default
public
. If you specify the namespace or database name, you must provide the schema name, even if the schema ispublic
.
table
- The table to drop.
CASCADE
- Specifies to drop all projections of the target tables.
CASCADE
is optional if the target tables have only auto-projections. If you omit this option and any of the tables has non-superprojections, Vertica returns an error and rolls back the entire drop operation.This option is not valid for external tables.
Privileges
Non-superuser:
-
Table: owner, or DROP privilege
-
Table schema: owner, or USAGE privilege
Requirements
-
Do not cancel an executing
DROP TABLE
. Doing so can leave the database in an inconsistent state. -
Check that the target table is not in use, either directly or indirectly—for example, in a view.
-
If you drop and restore a table that is referenced by a view, the new table must have the same name and column definitions.
Examples
See Dropping tables