Drop vs Truncate - W3TECHNOLOGY

Header Ads

Drop vs Truncate

Difference between drop and truncate

When you drop the Table:

1) All data and structure in the table is deleted
2) Any Pending transaction are commited
3) All Indexes are dropped
4) You cannot RollBack the DROP Table statement.
5)DROP TABLE is commited automatically
6)Indexes, tables, and databases can easily be deleted/removed with the DROP statement


DROP INDEX Syntax for MS SQL Server:

DROP INDEX table_name.index_name

The DROP TABLE Statement:

The DROP TABLE statement is used to delete a table
Table Dropped
The DROP DATABASE Statement:
The DROP DATABASE statement is used to delete a database.
DROP DATABASE database_name


When you Truncate a Table

1) Removes all Rows from a Table
2) Releses the storage space used by that table
3) You cannot roll back row removal when using TRUNCATE.
4) If the table is Parent of a refrential integrity constraint,you cannot truncate the TABLE.Disable the constraint before issuing the TRUNCATE statement.



tablename is the name of the table.

No comments:

Powered by Blogger.