Sponsored Links

Interview Questions



INTERVIEW QUESTIONS DATABASE SQL DETAILS

Question: What is the difference between TRUNCATE and DELETE commands?

Answer: TRUNCATE is a DDL command whereas DELETE is a DML command. Hence DELETE operation can be rolled back, but TRUNCATE operation cannot be rolled back.<br>WHERE clause can be used with DELETE and not with TRUNCATE.

Category SQL Interview Questions & Answers - Exam Mode / Learning Mode
Rating (0.3) By 8630 users
Added on 10/12/2009
Views 85436
Rate it!

Question: What is the difference between TRUNCATE and DELETE commands?

Answer:

TRUNCATE is a DDL command whereas DELETE is a DML command. Hence DELETE operation can be rolled back, but TRUNCATE operation cannot be rolled back.<br>WHERE clause can be used with DELETE and not with TRUNCATE. Source: CoolInterview.com


Truncate resets the identity and delete does not Source: CoolInterview.com

Answered by: swapana | Date: | Contact swapana Contact swapana

If we use truncate command it will delete the physical structure of the table and retains the logical structure of same as for the next usage.<br>delete is used to delete a particular row from the table. Source: CoolInterview.com

Answered by: jayaprada | Date: | Contact jayaprada Contact jayaprada

When we truncate a table then no trigger fired with associate table but in delete sts the trigger will be fire.<br><br>Truncate is fast and delete is not because delete have undo information . Source: CoolInterview.com

Answered by: King saini | Date: | Contact King saini Contact King saini

Truncate command cant be rollback as its a DDL statement n its much faster then delete as delete command has as undo/rollback segment in which stores the orignal data before delete command so when rollback we get d data as it was before. delete statement can be rollback as its DML statement.for truncate statement we doest hav to commit manually infact after truncate statement there is automatic commit so we cant rollback in truncate whereas in delete we hav to commit manually.one important differenece is that truncate statement frees the storage space where as delete doesnt frees d space. Source: CoolInterview.com

Answered by: sheetal sanghvi | Date: | Contact sheetal sanghvi Contact sheetal sanghvi

Truncate is a DDL command where as delete is a DML command.<br> The main difference is if we are using truncate command we cant able to rollback the records what we have deleted.But in the case of delete it is possible to rollback the records.<br> The another major difference is delete command deletes the contents of the table row by row,but truncate command will drop the entire table and reconstruct only the structure of the table and this is the reason why truncate is faster than delete.<br><br> Source: CoolInterview.com

Answered by: A.S.Sathish | Date: 2/21/2009 | Contact A.S.Sathish Contact A.S.Sathish

Truncate is a DDL command where as delete is a DML command.<br> The main difference is if we are using truncate command we cant able to rollback the records what we have deleted.But in the case of delete it is possible to rollback the records.<br> The another major difference is delete command deletes the contents of the table row by row,but truncate command will drop the entire table and reconstruct only the structure of the table and this is the reason why truncate is faster than delete.<br><br> Source: CoolInterview.com

Answered by: hari | Date: 2/23/2009 | Contact hari Contact hari

By using DELETE DML command we can delete a particular record or all records in a table and can be<br>rollbacked later.In case of TRUNCATE DDL command we can truncate all records in a table and can't be rollbacked later. Source: CoolInterview.com

Answered by: Prabhu.T | Date: 4/19/2009 | Contact Prabhu.T Contact Prabhu.T

Sometimes we wish to get rid of all the data in a table. One way of doing this is with DROP TABLE, But what if we wish to simply get rid of the data but not the table itself? For this, we can use the TRUNCATE TABLE command. Source: CoolInterview.com

Answered by: Shankar Gorkhe | Date: 4/19/2009 | Contact Shankar Gorkhe Contact Shankar Gorkhe

TRUNCATE is a DDL command whereas is a DML command and DELETE TABLE is a logged operation, so the deletion of each row gets<br>logged in the transaction log, which makes it slow. TRUNCATE TABLE<br>also deletes all the rows in a table, but it won't log the deletion of<br>each row, instead it logs the deallocation of the data pages of the<br>table, which makes it faster. Of course, TRUNCATE TABLE can be rolled<br>back.<br><br> Source: CoolInterview.com

Answered by: Robin Joseph | Date: 8/17/2009 | Contact Robin Joseph Contact Robin Joseph

In oracle truncate cant be roll back but in sql server truncate can be rollback.trigger never work for truncate,main concept in HWM(high water mark).<br> Source: CoolInterview.com

Answered by: Shabbir Alam | Date: 8/19/2009 | Contact Shabbir Alam Contact Shabbir Alam

There is one more difference:<br>Truncate do not return the number of rows deleted.But delete returns the no of rows deleted.<br> Source: CoolInterview.com

Answered by: Yogendra Mishra | Date: 10/31/2009 | Contact Yogendra Mishra Contact Yogendra Mishra

The main difference is if we are using truncate command,we can not use where clause.<br>bt in the case of delete we can use where clause.<br>truncate command will drop the entire table and reconstruct only the structure of the table and this is the reason why truncate is faster than delete. Source: CoolInterview.com

Answered by: sajitha | Date: 11/1/2009 | Contact sajitha Contact sajitha

Both Truncate and Delete removes data from table.<br><br>Truncate is a DDL command and cannnot be rolled back.It releases all the memory space after deleting the data.<br><br>Delete is a DML command. We need to perform commit/Rollback to save or undo our changes and Moreover thye memory space is not released after deleting the data.<br><br>Truncate is faster than delete operation.<br> Source: CoolInterview.com

Answered by: kultar kaur | Date: 11/9/2009 | Contact kultar kaur Contact kultar kaur

Truncate is a ddl command where as delete is a dml command. Turncate is faster then delete becuase in turncate no logs are created but in delete logs are created for rollback. Source: CoolInterview.com

Answered by: shukadev sahu | Date: 11/20/2009 | Contact shukadev sahu Contact shukadev sahu

TRUNCATE is a DDL command whereas DELETE is a DML command.truncate removes only the content of a object (table,synonym etc)and delete operation deletes all rows and columns by conditionally without modifiying their own structure both are. Source: CoolInterview.com

Answered by: rajesh | Date: 12/8/2009 | Contact rajesh Contact rajesh

Truncate is a DDL command where as delete is a DML command.<br> Major difference between delete and truncate is delete command deletes the contents of the table row by row,but truncate command will drop the entire table and reconstruct only the structure of the table and so truncate is faster than delete.<br> If we use truncate command it will delete the physical structure of the table and retains the logical structure of same as for the next usage.<br>delete is used to delete a particular row from the table.<br><br><br><br> Source: CoolInterview.com

Answered by: Nikhil Dudhbaware | Date: 12/15/2009 | Contact Nikhil Dudhbaware Contact Nikhil Dudhbaware

TRUNCATE is a DDL command whereas DELETE is a DML command.Turncate is faster then delete becuase in turncate no logs are created but in delete logs are created for rollback.
Source: CoolInterview.com

Answered by: avinash omar | Date: 1/27/2010 | Contact avinash omar Contact avinash omar

Truncate is DDL command, so it is auto commit.Delete is DML command, we need to do commit after delete transaction.
There is concept of "HIGH WATER MARK", truncate resets the high water mark level while delete does not,this is reason truncate is fater than delete. Source: CoolInterview.com

Answered by: vipin kumar | Date: 3/9/2010 | Contact vipin kumar Contact vipin kumar

TRUNCATE is a DDL command whereas DELETE is a DML command.truncate removes only the content of a object (table,synonym etc)and delete operation deletes all rows and columns by conditionally without modifiying their own structure both are.
thats all
sandeep Source: CoolInterview.com

Answered by: sandeep kumar yadav | Date: 4/15/2010 | Contact sandeep kumar yadav Contact sandeep kumar yadav

Truncate command drops the table(delete all the records and drops table) and recreate the table again....delete command delete the records of the table... Source: CoolInterview.com

Answered by: vikram shinde | Date: 4/17/2010 | Contact vikram shinde Contact vikram shinde

In the both the cases data in the table is lost.
In delete rowid's and memory of the data is not cleaned.
Where as in Truncate rowids and memory also cleaned.
Delete can have the rollback facility, because it is DML command.
Truncate doesnt have the rollback facility because it is DDL command. Source: CoolInterview.com

Answered by: svphanikumar | Date: 6/10/2010 | Contact svphanikumar Contact svphanikumar

1>TRUNCATE is a DDL command whereas DELETE is a DML command.

2>TRUNCATE is much faster than DELETE.

Reason:When you type DELETE.all the data get copied into the Rollback Tablespace first.then delete operation get performed.Thatswhy when you type ROLLBACK after deleting a table ,you can get back the data(The system get it for you from the Rollback Tablespace).All this process take time.But when you type TRUNCATE,it removes data directly without copying it into the Rollback Tablespace.Thatswhy TRUNCATE is faster.Once you Truncate you cann't get back the data.

3>You cann't rollback in TRUNCATE but in DELETE you can rollback.TRUNCATE removes the record permanently.

4>In case of TRUNCATE ,Trigger doesn't get fired.But in DML commands like DELETE .Trigger get fired.

5>You cann't use conditions(WHERE clause) in TRUNCATE.But in DELETE you can write conditions using WHERE clause Source: CoolInterview.com

Answered by: Dhanabal | Date: 7/4/2010 | Contact Dhanabal Contact Dhanabal

1>TRUNCATE is a DDL command whereas DELETE is a DML command.

2>TRUNCATE is much faster than DELETE.

Reason:When you type DELETE.all the data get copied into the Rollback Tablespace first.then delete operation get performed.Thatswhy when you type ROLLBACK after deleting a table ,you can get back the data(The system get it for you from the Rollback Tablespace).All this process take time.But when you type TRUNCATE,it removes data directly without copying it into the Rollback Tablespace.Thatswhy TRUNCATE is faster.Once you Truncate you cann't get back the data.

3>You cann't rollback in TRUNCATE but in DELETE you can rollback.TRUNCATE removes the record permanently.

4>In case of TRUNCATE ,Trigger doesn't get fired.But in DML commands like DELETE .Trigger get fired.

5>You cann't use conditions(WHERE clause) in TRUNCATE.But in DELETE you can write conditions using WHERE clause Source: CoolInterview.com

Answered by: Dhanabal | Date: 7/4/2010 | Contact Dhanabal Contact Dhanabal


If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification Enter the above shown code: *
Inform me about updated answers to this question

Related Questions
View Answer
What command is used to create a table by copying the structure of another table?
View Answer
What will be the output of the following query?
SELECT REPLACE(TRANSLATE(LTRIM(RTRIM('!! ATHEN !!','!'), '!'), 'AN', '**'),'*','TROUBLE') FROM DUAL;
View Answer
What will be the output of the following query?
SELECT DECODE(TRANSLATE('A','1234567890','1111111111'), '1','YES', 'NO' );
View Answer
What does the following query do?
SELECT SAL + NVL(COMM,0) FROM EMP;
View Answer
Which date function is used to find the difference between two dates?
View Answer
Why does the following command give a compilation error?
DROP TABLE &TABLE_NAME;
View Answer
What is the advantage of specifying WITH GRANT OPTION in the GRANT command?
View Answer
What is the use of the DROP option in the ALTER TABLE command?
View Answer
What is the value of comm and sal after executing the following query if the initial value of ‘sal’ is 10000
UPDATE EMP SET SAL = SAL + 1000, COMM = SAL*0.1;
View Answer
What is the use of DESC in SQL?
View Answer
What is the use of CASCADE CONSTRAINTS?
View Answer
Which function is used to find the largest integer less than or equal to a specific value?
View Answer
What is the output of the following query
SELECT TRUNC(1234.5678,-2) FROM DUAL;
View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

View All SQL Interview Questions & Answers - Exam Mode / Learning Mode



User Options
India News Network

Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal



Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |




Copyright ©2003-2024 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions