Wednesday, October 15, 2014

TRUNCATING TABLES



TRUNCATE TABLE empties a table completely. Logically, this is equivalent to a DELETE statement that deletes all rows, but there Are practical differences under some circumstances.

TRUNCATE TABLE differs from DELETE in the following ways:
Truncate operations drop and re‑create the table, which is much faster than deleting rows one by on
 Truncate operations are not transaction‑safe (i.e. an error will occur if an active transaction or an active table lock exists)
The number of deleted rows are not returned
 Syntax:
TRUNCATE TABLE ;
 Example:
Truncate the table ACCT_MSTR
TRUNCATE TABLE ACCT_MSTR;
 Output:
Table truncated.

No comments: