Share on Facebook Share on Twitter Email
Answers.com

Truncate

 
Wikipedia: Truncate (SQL)

In SQL, the TRUNCATE TABLE statement quickly removes all data from a table, typically bypassing a number of integrity enforcing mechanisms.

The TRUNCATE TABLE mytable statement is logically (though not physically) equivalent to the DELETE FROM mytable statement (without a WHERE clause). The following characteristics distinguish TRUNCATE TABLE from DELETE:

  • In the Oracle Database, TRUNCATE is implicitly followed by a commit operation. (This may also be the case in MySQL, depending on the chosen storage engine.)
  • Typically, TRUNCATE TABLE quickly deletes all records in a table by deallocating the data pages used by the table. This reduces the resource overhead of logging the deletions, as well as the number of locks acquired. Records removed this way cannot be restored in a rollback operation. Two notable exceptions to this rule are the implementations found in PostgreSQL and Microsoft SQL Server, both of which allow TRUNCATE TABLE statements to be committed or rolled back transactionally.
  • You cannot specify a WHERE clause in a TRUNCATE TABLE statement—it is all or nothing.
  • TRUNCATE TABLE cannot be used when a foreign key references the table to be truncated, since TRUNCATE TABLE statements do not fire triggers. This could result in inconsistent data because ON DELETE/ON UPDATE triggers would not fire.
  • In some database systems, TRUNCATE TABLE resets the count of an Identity column back to the identity's seed.
  • In Microsoft SQL Server, TRUNCATE TABLE statements cannot be used for tables involved in replication or log shipping, since both depend on the transaction log to keep remote databases consistent.

Notes



Search unanswered questions...
Enter a question here...
Search: All sources Community Q&A Reference topics
 
 
Learn More
frontate
aegithognathous (vertebrate zoology)
round off (mathematics)

What is the meaning of truncated? Read answer...
What is truncate data? Read answer...
Volume of a truncated cylinder? Read answer...

Help us answer these
What is truncated VAT?
What is the abbreviation of truncation?
What is truncat in oracle9i?

Post a question - any question - to the WikiAnswers community:

 

Copyrights:

Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "Truncate (SQL)" Read more