Monday, September 10, 2012

What is difference between DELETE & TRUNCATE commands?




Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we run the truncate command.

TRUNCATE
...

TRUNCATE is faster and uses fewer system and transaction log resources than DELETE.
TRUNCATE removes the data by deallocating the data pages used to store the table’s data, and only the page deallocations are recorded in the transaction log.
TRUNCATE removes all rows from a table, but the table structure, its columns, constraints, indexes and so on, remains. The counter used by an identity for new rows is reset to the seed for the column.
You cannot use TRUNCATE TABLE on a table referenced by a FOREIGN KEY constraint. Because TRUNCATE TABLE is not logged, it cannot activate a trigger.
TRUNCATE cannot be rolled back.
TRUNCATE is DDL Command.
TRUNCATE Resets identity of the table
DELETE

DELETE removes rows one at a time and records an entry in the transaction log for each deleted row.
If you want to retain the identity counter, use DELETE instead. If you want to remove table definition and its data, use the DROP TABLE statement.
DELETE Can be used with or without a WHERE clause
DELETE Activates Triggers.
DELETE can be rolled back.
DELETE is DML Command.
DELETE does not reset identity of the table.

3 comments:

  1. Very Useful Information.Thanks for Sharing This Blog.

    CEH Training In Hyderabad: Kernel Training provides CEH Classroom Training in Hyderabad. In adition, EC Council Verified Certification is also Provided.

    CEH Training In Hyderabad

    ReplyDelete
  2. nice information, please visit this link also

    https://unichrone.com/au/courses/it-security-governance/cism-certification-training/bathurst

    Unichrone offers CISM Certification Training Course in Bathurst Australia by its most experienced CISM Certified Professional Trainer. This CISM Training in Bathurst will enable you to clear CISM exam with ease, and thereby, improve your employability. Certified Information Security Manager Training Course in Bathurst demonstrates relationship between an information security program and broader business goal objectives. The CISM Certification helps you gain an in-depth knowledge of the four CISM domains: security governance; risk management and compliance; security program development and management. The CISM® Certification endorses international security practices and acknowledges the professional who manages designs, and oversees and assesses an enterprise’s information security. The qualification differentiates you as having knowledge and experience in building and managing an information security program. CISM Certification Training in Bathurst Australia is not only an objective measure of excellence, but a globally recognized standard of achievement for security training. Unichrone provides comprehensive CISM Training in Bathurst Australia for participants who wish to gain expertise in defining the design, architecture, management and controls leading to a secure business environment. Individuals possessing this vendor neutral credential are high in demand by corporations all over the world who want to protect their organizations from a growing spurt of sophisticated cyber attacks.

    ReplyDelete
  3. nice information. please visit this also.

    CURRENT EDUCATION SYSTEM IN INDIA

    what is education?
    what does a book teaches?
    where we are in the educational standards?
    what is our ancient education systems?
    Possible ways to out of this type of education.
    WHAT IS EDUCATION ?
    Education is not that difficult and not that easy. Whatever we are currently learning in the book, that is not even 1% of the education. The real education we are learning something, not only in the book, you can learn from anywhere. if you see a situation, what you understand and how you will handle. Each and everything is something special to learn. but we have to think about how it is useful and how it will create an opportunity for you and others. learn from the atmosphere. if you think properly, each and everything on the universe will do something for you. but, understand why it is and what we have to do. you can get the opportunity from those. use your knowledgeable education strategies, that must work for you. that will change the current education system in India, it will start with you.

    ReplyDelete