DROP TABLE:

This SQL command is used to remove a table definition and all data, indexes, triggers, constraints, and permission specifications for that table from the database. The syntax is

DROP TABLE [[database.]owner.]table_name

where

database: name of the database

owner: owner of the table and NOT the database

table_name: Specifies the table to be removed.

An example of this command

Drop table testDB.dbo.patients

Remarks

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.

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

Back to the homepage