diff between TRUNCATE & DELETE [message #7563] |
Sun, 22 June 2003 01:45 |
shashi
Messages: 34 Registered: March 2001
|
Member |
|
|
TRUNCATE AND DELETE do the same job except that TRUNCATE as an implicit COMMIT.
So why to have 2 commands doing the same job.
Is there anything else to differentiate them
|
|
|
|
|
Re: diff between TRUNCATE & DELETE [message #7616 is a reply to message #7563] |
Wed, 25 June 2003 04:55 |
Chandru
Messages: 12 Registered: July 2000
|
Junior Member |
|
|
Hi,
Here are the differences between the two
1. Delete allows you to filter the records that have to be deleted, while with Truncate you will have to delete all the records only.
2. Since Delete doesnot use an implicit commit, deleted rows can be rolled back, while truncate cannot be rolled back. This is why Deleting all records from a large table is much slower than Truncating the table, because when you delete all the rows, they are written into the RBS and stay there till you do a commit or a rollback.
3. Even if you use Cascade Delete referntial integrity, Truncate will not allow you to delete parent records unless the constarint is disabled. On the other hand Delete will proceed under such circumstances.
4. Unlike what Mahesh said, Truncate also has the option to leave the storage to be reused. But the default option is Drop Storage.
HTH
Chandru
|
|
|
|