DROP TABLE Statement

Removes a table definition and all data, indexes, triggers, constraints, and permission specifications for that table from the database.

Syntax

DROP TABLE [[database.]owner.]table_name
[, [[database.]owner.]table_name...]

where

table_name
Specifies the table to be removed.

Remarks

The DROP TABLE statement cannot be used to drop a table that is being referenced by a FOREIGN KEY constraint. You must first drop the referencing FOREIGN KEY constraint or the referencing table.

If you are the table owner, you can drop a table in any database. When you drop a table, rules or defaults on it lose their binding, and any constraints or triggers associated with it are automatically dropped. If you re-create a table, you must rebind the appropriate rules and defaults, re-create any triggers, and add all necessary constraints.

The sysobjects, syscolumns, sysindexes, sysprotects, and syscomments system tables are affected when a table is dropped.

You cannot use the DROP TABLE statement on system tables.

If you delete all rows in a table (DELETE tablename) or use the TRUNCATE TABLE statement, the table still exists until you drop it.

Permission

DROP TABLE permission defaults to the table owner and is not transferable. However, the database owner and system administrator can drop any object by specifying the owner in the DROP TABLE statement. The system administrator and database owner can also use the SETUSER statement to impersonate another user.

Examples

A.    Drop a Table in the Current Database

This example removes the titles1 table and its data and indexes from the current database.

DROP TABLE titles1
B.    Drop a Table in Another Database

The following example drops the authors2 table in the pubs database. This can be executed from any database.

DROP TABLE pubs.dbo.authors2

See Also

ALTER TABLE sp_help
CREATE TABLE sp_spaceused
DELETE TRUNCATE TABLE
sp_depends