1. Home >
  2. Apps >
  3. Groups >

Sql: Difference between truncate and delete command

Question asked by babloo0311 in #Coffee Room on Nov 25, 2008
babloo0311
babloo0311 · Nov 25, 2008
Rank C3 - EXPERT
Hi friends,

what is the difference between delete and trancate command Posted in: #Coffee Room
Kaustubh Katdare
Kaustubh Katdare · Nov 25, 2008
Rank A1 - PRO
babloo0311
Hi friends,

what is the difference between delete and trancate command
Its 'truncate', I think.
manupep
manupep · Nov 25, 2008
Rank D3 - MASTER
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
Rank B1 - LEADER
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
Rank D3 - MASTER
oh! yes 'delete' is there to delete rows according to condition.
shalini_goel14
shalini_goel14 · Nov 27, 2008
Rank A3 - PRO
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
Rank C3 - EXPERT
yeah thanks buddy
manupep
manupep · Nov 27, 2008
Rank D3 - MASTER
oh! so much infos .Thanks shalini.
shalini_goel14
shalini_goel14 · Nov 27, 2008
Rank A3 - PRO
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
Rank C3 - EXPERT
yeah no probs
Prasad Ajinkya
Prasad Ajinkya · Nov 28, 2008
Rank B1 - LEADER
Wow! Good tips Shalini!!
zia.sepsis
zia.sepsis · Dec 31, 2008
Rank C3 - EXPERT
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
Rank D3 - MASTER
I think you got your ANS 😁

You must log-in or sign-up to reply to this post.

Click to Log-In or Sign-Up