Database Programming
Windows XP
The Difference Between

Describe drop table commands of sql with both the options cascade and restrict?

252627

Answer

User Avatar
Wiki User
10/30/2007

A table can have object dependencies. Indexes, views, programs. When you give a "drop table" command, it will not drop the table that has dependencies unless you include the "cascade" command in the statement. The database programming is written this way to make sure you know the table has dependent objects and makes you explicitly say you want to drop the table and all its dependencies. You should be very careful with this command. If you find you need to restore this table, you'd also have to recreate the view and index and recompile the programs attached. The best way to recover from this is if you have a tool that will put the create statement into a file, including all attached objects. That way, if you drop the table and need to recover, all you have to do is run the create command which will recreate in a minute versus a recovery that could take 30 minutes to hours dependent upon the availability of the data. After you run the create statement, make sure all objects are attached, test the view and make sure the programs are VALID.