View Feed
group-icon
Coffee Room
Discuss anything here - everything that you wish to discuss with fellow engineers.
12940 Members
Join this group to post and comment.
babloo0311
babloo0311 • Nov 25, 2008

Sql: Difference between truncate and delete command

Hi friends,

what is the difference between delete and trancate command
Kaustubh Katdare
Kaustubh Katdare • Nov 25, 2008
babloo0311
Hi friends,

what is the difference between delete and trancate command
Its 'truncate', I think.
manupep
manupep • Nov 25, 2008
Is there any command 'delete' ?
I think 'drop table' is the command used to delete one table.
'truncate' will delete only the contents of the table . The table structure should remain. we can add datas further.
Prasad Ajinkya
Prasad Ajinkya • Nov 26, 2008
Well, you can also use delete from command to delete only the contents of the table. Schema will remain intact though.
manupep
manupep • Nov 26, 2008
oh! yes 'delete' is there to delete rows according to condition.
shalini_goel14
shalini_goel14 • Nov 27, 2008
Hi Babloo

1. TRUNCATE : You can't use WHERE clause
DELETE : You can use WHERE clause

2. TRUNCATE : You can't use WHERE clause
DELETE : You can use WHERE clause

3. Delete - delete deletes the records from table it can be rollbacked also you can give the where condiition to it.
Truncate - delete all records from table There is no rollback it always commit without giving the commit command

TRUNCATE is a DDL command and cannot be rolled back and All of the memory space is released back to the server. It can not use the Where conditions. DELETE is a DML command and can be rolled back. here can be use where conditions. TRUNCATE is much faster but don not use it if delete can work.
babloo0311
babloo0311 • Nov 27, 2008
yeah thanks buddy
manupep
manupep • Nov 27, 2008
oh! so much infos .Thanks shalini.
shalini_goel14
shalini_goel14 • Nov 27, 2008
Always welcome 😀 .

Sorry for Duplicate points:

1. TRUNCATE : You can't use WHERE clause
DELETE : You can use WHERE clause

2. TRUNCATE : You can't use WHERE clause
DELETE : You can use WHERE clause
babloo0311
babloo0311 • Nov 27, 2008
yeah no probs
Prasad Ajinkya
Prasad Ajinkya • Nov 28, 2008
Wow! Good tips Shalini!!
zia.sepsis
zia.sepsis • Dec 31, 2008
Truncate table does not support the Where clause. In addition, the Truncate table statement does not fire a trigger. When truncate is used, the deleted rows are not entered in the transaction log. there fore it can't be rolled back. when the delete command is used , it creates a transaction log file which help you in the process of rollback.
the syntax of truncate statement is:-
truncate table table_name
the syntax of delete statement is:-
delete table_name

both the statements is used to delete all the records form the table
correct me if am wrong 😁
HEART-HACKER
HEART-HACKER • Dec 31, 2008
I think you got your ANS 😁

Share this content on your social channels -