Truncate and delete database delete data

 

delete from table where

Delete a row in the data table, and at the same row as the delete operation for transaction records stored in the log to roll back operations. So delete compared to truncate more resource-intensive, data space is not released, because of the need to roll back. You can operate on the table and view

truncate table

Once all data is deleted from the table (table data storing releasing data page used to delete data) does not delete the individual records logged saved (only the release of the page is recorded in the transaction log), and therefore can not be rollback can not recover the data, the process does not delete the activation of delete trigger associated with a table, a small footprint more, faster. Will release data space, the table and index space occupied will return to its original size. Not only the operation table view associated

drop table

Delete the entire table, including the table structure, data definitions. Permanently erase, the space freed. You can operate on the table and view

 

Since TRUNCATE TABLE not recorded in the log, it can not activate the trigger, the foreign key for the table (ForeignKey) constraint references can not be used truncate table, but should not be used where clause delete statement.
truncate table can not be used in view of the involvement of the table index

Guess you like

Origin www.cnblogs.com/xiangtingshen/p/10971742.html