babloo0311
babloo0311
Branch Unspecified
31 Dec 2008

Sql: Difference between truncate and delete command

Hi friends,

what is the difference between delete and trancate command
10 years ago
babloo0311
Hi friends,

what is the difference between delete and trancate command
Its 'truncate', I think.
manupep

manupep

Branch Unspecified
10 years ago
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

Branch Unspecified
10 years ago
Well, you can also use delete from <table_name> command to delete only the contents of the table. Schema will remain intact though.
manupep

manupep

Branch Unspecified
10 years ago
oh! yes 'delete' is there to delete rows according to condition.
shalini_goel14

shalini_goel14

Branch Unspecified
10 years ago
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

Branch Unspecified
10 years ago
yeah thanks buddy
manupep

manupep

Branch Unspecified
10 years ago
oh! so much infos .Thanks shalini.
shalini_goel14

shalini_goel14

Branch Unspecified
10 years ago
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

Branch Unspecified
10 years ago
yeah no probs
Prasad Ajinkya

Prasad Ajinkya

Branch Unspecified
10 years ago
Wow! Good tips Shalini!!
zia.sepsis

zia.sepsis

Branch Unspecified
10 years ago
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

Branch Unspecified
10 years ago
I think you got your ANS 😁

Share this content on your social channels -

Only logged in users can reply.