Cred Interview Question | Table Drop

Question

If we drop a table, does it also drop related objects like constraints, indexes, columns, defaults, Views and Stored Procedures?

in progress 1
Dhruv2301 4 years 2 Answers 776 views Great Grand Master 1

Answers ( 2 )

  1. YES, It drops all related objects, which exists INSIDE a table like, constraints, indexes, columns, defaults, etc. BUT dropping a table will not drop Views and Stored Procedures as they exist OUTSIDE the table

  2. When SQL Server drops a table, it also deletes all data, triggers, constraints, permissions of that table.
    Moreover, SQL Server does not explicitly drop the views and stored procedures that reference the dropped table.
    Therefore, to explicitly drop these dependent objects, you must use the DROP VIEW and DROP PROCEDURE statement.

    Reference:
    https://www.sqlservertutorial.net/sql-server-basics/sql-server-drop-table/

Leave an answer

Browse
Browse