Learning an alternative way to delete data with the TRUNCATE statement 

There is a faster way to delete all the rows from a table, called TRUNCATE. Deleting rows is a data manipulation language(DML) action, but a truncate is a data definition language (DDL) action. Deleting values is a slower process because the database system has to log each delete, but the truncate process doesn't. Another difference between deleting and truncating is that with a TRUNCATE statement, you reclaim the storage that the data used after a truncate; with a DELETE statement, you can't reclaim the storage. If a table has foreign key references, you are unable to truncate and will need to use a DELETE statement to delete the rows from the referenced tables first. 

A TRUNCATE statement is final. There is no way to roll it back

If you are sure you want to delete all the rows in a table, then truncating is the best way to do this. To do so, you can execute the following script: 

USE yourschema;
TRUNCATE TABLE allstarfull;

The previous script deletes all the rows in the allstarfull table by performing a truncate against the table.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.253.62