Question:
What is the difference between TRUNCATE and DELETE commands
Answer:
Both will result in deleting all the rows in the table .TRUNCATE call cannot be rolled back as it is a DDL command and all memory space for that table is released back to the server. TRUNCATE is much faster.Whereas DELETE call is an DML command and can be rolled back. Source: CoolInterview.com
truncate : it is a DDL Command. it cant rollback because all DDL command is auto commit. Delete : It is DML command. It can be Roll Backed. we can delete rows based on condition. Both are Delete The Records in The Table but not structure. Source: CoolInterview.com
Answered by: sathyaajh | Date:
| Contact sathyaajh
delete:delete will remove the rows from the table.rollback of rows will possible. truncate:it will remove all the rows as well as the storage space used by that table. rollback of row removal is not possible. truncate is faster than delete because it fires the delete trigger. Source: CoolInterview.com
Answered by: mohank | Date: 11/12/2007
| Contact mohank
Truncate - It is a d.d.l command which delete all the records in an object at a time which we cannot rollback the structure of the object remains and the space in database gets empty.
Delete - Is the d.m.l command which is used to delete the records at a time r conditionally by use where condition where we can rollback since it is committed. Source: CoolInterview.com
Answered by: praneeth | Date: 12/17/2008
| Contact praneeth
truncate is resets the identity function to its initial value. where as delete doesn't reset to its initial value when we delete all records which are presented. Source: CoolInterview.com
Answered by: pushpa g | Date: 5/30/2009
| Contact pushpa g
Truncate is a ddl command which will be committed automatically. All the records in the table will be deleted in a single short. Delete is dml command which need to committed explicitly the rows which are deleted can be undeleted. Source: CoolInterview.com
Answered by: kiran | Date: 8/16/2010
| Contact kiran
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.
|