DROP Statements

All of the database objects created with CREATE commands may be destroyed using complementary DROP statements. The DROP command is irreversible and permanent, so it must be used with care. The syntax follows this format:

DROP object_type [owner_name.]object_name

With most vendors, the DROP command fails if the database object is in use by another user. With some vendors, the DROP command fails if the database object has other characteristics. For example, Microsoft SQL Server does not drop a table that is replicated. The table must be removed from replication before it can be dropped.

Warning

It is important to be aware that most vendors do not notify a user if the DROP command creates a dependency problem. Thus, if a table is dropped that is used by a few views and stored procedures elsewhere in the database, no warning is issued. Those other objects simply return failures when they are accessed.

Get SQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.