GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL Plus
Go To First  |  Previous Question  |  Next Question 
 SQL Plus  |  Question 66 of 132    Print  
What is difference between TRUNCATE & DELETE ?
TRUNCATE commits after deleting entire table i.e., can not be rolled back. Database triggers do not fire on TRUNCATEDELETE allows the filtered deletion. Deleted records can be rolled back or committed.Database triggers fire on DELETE.


  
Total Answers and Comments: 9 Last Update: June 27, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
February 08, 2006 08:53:28   #1  
rajaramian        

RE: What is difference between TRUNCATE & DELETE ?
We can ROLLBACK the DELETE statement but we can not ROLLBACK the TRUNCATE statement
 
Is this answer useful? Yes | No
December 07, 2006 09:49:15   #2  
rampratap409 Member Since: September 2006   Contribution: 111    

RE: What is difference between TRUNCATE & DELETE ?

Delete generates rollback segments and its DML

Truncate does not generate rollback segment and its DDL

once Truncate does not generate rollback so its faster then delete


 
Is this answer useful? Yes | No
February 09, 2007 00:26:28   #3  
prince maruthi        

RE: What is difference between TRUNCATE & DELETE ?
truncate DELETE+COMMIT;

delete delete+rollback;we can rollback after the delete command then we can get the deleted data

 
Is this answer useful? Yes | No
May 11, 2007 08:30:06   #4  
riteshratna Member Since: October 2006   Contribution: 3    

RE: What is difference between TRUNCATE & DELETE ?
Delete
Delete remove the Data only the Table structure remains intact.

This is a DML Statement
Rollback possible
No Commit is performed neither before nor after. (Because it is a DML Statement).
They take locks on rows
They generate redo (lots of it)
They require segments in the UNDO tablespace.
A delete does not relinquish segment space thus a table in which all records have been deleted retains all of its original blocks.
A truncate does not move the High Water Mark of the table back to zero it retains it s original position.
Delete deletes the specific rows filtered by where statement. and log is maintained for it.
It can activate the triggers.

Truncate
Truncate remove the Data only the Table structure remains intact.
This is a DDL Statement
Rollback not possible (Except in SQL 2005)
It issues a COMMIT before it acts and another COMMIT afterward so no rollback of the transaction is possible. (Because it is a DDL Statement)
No row-level locks are taken.
No redo or rollback is generated.
They do not require segments in the UNDO tablespace.
All extents bar the initial are de-allocated from the table
A truncate moves the High Water Mark of the table back to zero
Truncate deletes the page associated with the table so all indexes are reset
It does not activate the triggers.
 

Is this answer useful? Yes | No
May 17, 2007 00:11:59   #5  
sheel        

RE: What is difference between TRUNCATE & DELETE ?
Hi friends
In truncate command deletion of row happen but one important thing is that after truncate memory space is also empty or you can say that operation going on memory element is deleted from memory permanetly. that is why they cannot rollback.
But in case of delete command the element is still present in memory so memory is not empty after the delete operation so they can rollback after deletion. thanx

if any one has new logic plz send me

 
Is this answer useful? Yes | No
August 24, 2007 07:19:35   #6  
harneet2004us Member Since: August 2007   Contribution: 2    

RE: What is difference between TRUNCATE & DELETE ?

1) Rollback : Not possible in Truncate but possible in Delete because it
Delete uses the rollback Segments.

2) Trigger : If we have a Delete Trigger it will not be fired in case of
Truncate.

3) Type : Delete is a DML Type of statement but Truncate is a DDL statement.

4) Speed : Truncate is much faster than Delete because it does not use the
rollback segments

5) High Water Mark : The High water mark of the table is set to 0 in case of
Truncate but this variable retains its original value in Delete.


 
Is this answer useful? Yes | No
June 26, 2008 11:44:41   #7  
G.D.S.Prasad Member Since: November 2006   Contribution: 191    

RE: What is difference between TRUNCATE & DELETE ?
1. Truncate is a DDL command where as Delete is DML.
2. There is no rollback for Truncate where as for Delete we can rollback.

 
Is this answer useful? Yes | No
June 27, 2008 05:44:33   #8  
nandk.sharma Member Since: June 2008   Contribution: 10    

RE: What is difference between TRUNCATE & DELETE ?
TRUNCATE - Truncate is a ddl command.

DELETE- Delete is a dml command.

TRUNCATE - We can not use 'where' clause with truncate.

DELETE- We can use 'where ' clause with delete .

 
Is this answer useful? Yes | No
June 27, 2008 05:48:05   #9  
nandk.sharma Member Since: June 2008   Contribution: 10    

RE: What is difference between TRUNCATE & DELETE ?
Truncate is faster than delete as it does not generate rollback segment.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape