Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is the difference between the drop and truncate table commands?

0
Posted

What is the difference between the drop and truncate table commands?

0

Talebzadeh: The drop table command drops the table, including the table definition and the associated objects (rules, indexes, constraints, triggers, primary key and so on). Obviously, once a table is dropped all the data rows contained in the table are also removed. A truncate table command removes all rows from a table. The table structure and all the indexes continue to exist until you issue a drop table command (as discussed above). The rules, defaults and constraints that are bound to the columns remain bound, and triggers remain in effect. The truncate table command also de-allocates the distribution pages for all indexes. The truncate table is equivalent to, but faster than, a delete command without a where clause. Delete removes rows one at a time and logs each deleted row as a transaction; truncate table de-allocates whole data pages and makes fewer log entries. Both delete and truncate table reclaim the space occupied by the data and its associated indexes. Only the table own

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123