what is the difference between TRUNCATE and DELETE command
in SQL

Answers were Sorted based on User's Feedback



what is the difference between TRUNCATE and DELETE command in SQL..

Answer / chandu

Delete:
In delete statement we can use conditions
we can roll back
we can delete parent and child table rows also
it will activate in triggers
it can be slow compare to truncate.
Truncate:
In truncate statement we cant use conditons.
we cant roll back
we can delete child table rows only.
it will not activate in triggers.
it can be fast compare to delete.

Is This Answer Correct ?    2 Yes 0 No

what is the difference between TRUNCATE and DELETE command in SQL..

Answer / dhanasekar.s

Truncate command executes faster then Delete command.
when you truncate the table we can't get back the data again
because data is removed from the memory.because ddl command
is auto commit.So we need not store any information about
deleted data in the memory.So it takes less time so faster.

But in the case of delete command is dml command.we can get
back(rollback) the data again.When you delete the data that
deleted data are stored in some where in memory that
information should be logged in the database log
information.From that information we can get the data again
easily.
So that (logging purpose) it takes time then truncate command.

It is my observation and my idea.If it is having any
mistakes please post the reason .

Thanks in Advance.

Is This Answer Correct ?    2 Yes 1 No

what is the difference between TRUNCATE and DELETE command in SQL..

Answer / tripurari

truncate id ddl command .so it can't store data into redo log files, so it can't be rollback.

Delete is dml command so it contains data into log files so it may be rollback.

Is This Answer Correct ?    1 Yes 0 No

what is the difference between TRUNCATE and DELETE command in SQL..

Answer / padmapriya

1) Delete create log files when it is deleted and occupy
more space of memory

Whereas Truncate will not create any log files and hence
much faster than delete.

2) Delete can be roll back whereas Truncate is autocommit.

3) When there is foreign key constraint even though there
is no data in child table Truncate cannot be done. only
when the constraint is dropped truncate can be executed.

Whereas though we have foreign key constraints if the child
table is deleted, then parent table can be deleted.

Is This Answer Correct ?    2 Yes 2 No

what is the difference between TRUNCATE and DELETE command in SQL..

Answer / bhupat

Truncate Statement:
1.Deletes all the rows from the table.

Delete Statement:
1.Delete a specific row.

Is This Answer Correct ?    0 Yes 0 No

what is the difference between TRUNCATE and DELETE command in SQL..

Answer / priya

Truncate an Delete both are used to delete data from the table. These both command will only delete data of the specified table, they cannot remove the whole table data structure.Both statements delete the data from the table not the structure of the table.
TRUNCATE is a DDL (data definition language) command whereas DELETE is a DML (data manipulation language) command.
You can use WHERE clause(conditions) with DELETE but you can't use WHERE clause with TRUNCATE .
You cann't rollback data in TRUNCATE but in DELETE you can rollback data.TRUNCATE removes(delete) the record permanently.

A trigger doesn’t get fired in case of TRUNCATE whereas Triggers get fired in DELETE command.

If tables which are referenced by one or more FOREIGN KEY constraints then TRUNCATE will not work.

TRUNCATE resets the Identity counter if there is any identity column present in the table where delete not resets the identity counter.

Delete and Truncate both are logged operation.But DELETE is a logged operation on a per row basis and TRUNCATE logs the deallocation of the data pages in which the data exists.

TRUNCATE is faster than DELETE.

Is This Answer Correct ?    0 Yes 0 No

what is the difference between TRUNCATE and DELETE command in SQL..

Answer / sathya

I just wanna add a point ..

while truncating a table both the structure and the datas will be removed. where as in Delete structure of the table ramains only the data in the table will be deleted.

Is This Answer Correct ?    0 Yes 0 No

what is the difference between TRUNCATE and DELETE command in SQL..

Answer / vijay rana

1.truncate is a DML command but Delete is a DDL Command

2.truncate is much faster then Delete

3.we can rollback delete but we cant rollback Truncate

4.we can not use where in truncate but we can use where with
delete

5.in case of truncate memory released immediately, but in
case of delete memory dosen release if we dont press commit.

Is This Answer Correct ?    2 Yes 4 No

what is the difference between TRUNCATE and DELETE command in SQL..

Answer / vasanth

Truncate
1.Truncate Can be DDL Command.
2.it can be rollback.
3.we cann't use Where clause.
4.truncate=delete+commit so we cann't rollback.
5.truncate delete all record from the table.
6.truncate is a DDL command and cannot be rollbackand all
memory space is released back to server.
7.speed faster.
8.do not chcek constraint.
Delete
1.Delete Can be DML Command.
2.it can be rollback.
3.we can use Where clause.
4.delete=delete-- so we can be rollback.
5.delete delete record from the table.
6.truncate is a DDL command and can be rollback and all
memory space is not released back to server.
7.speed slow.
8. chcek constraint.

Is This Answer Correct ?    1 Yes 3 No

what is the difference between TRUNCATE and DELETE command in SQL..

Answer / akshar jain

hi every one , i want to tell that truncate can also be
rolled back,i have used that , its my practical experience
if you want further clarifications write to me at
akshar.mysore@gmail.com

Is This Answer Correct ?    12 Yes 18 No

Post New Answer

More Oracle AllOther Interview Questions

how to get the values if source table & target table having duplicate values that matches the lookup condition ?(i want all duplicate match)

1 Answers  


What is the Symbol use for Inner Join

1 Answers   Oracle, TCS,


IS IT POSSIBLE TO CREATE REPORTS FROM DIFFERENT UNIVERSES IN ONE DOCUMENT?

0 Answers  


deference between & and &&

2 Answers   Mphasis,


types of receipts and detail desription about recipts and tables effected by receipts?

0 Answers  






please explain about oracle

1 Answers  


now iam working as an hr executive in hyderabad i would like to learn oracle hrms kindly suggest me some good institutes in hyderabd

0 Answers   Wipro,


Hi I am searching for best oracle Apps institute? Please tel me which is best institute in hyderabad I am working in developer 6i....

2 Answers   Ion Exchange,


Should you take the backup of Logfiles if the database is running in ARCHIVELOG mode?

4 Answers  


Explain the use of table functions.

0 Answers  


statement string in open is null or 0 length ORA-40735

1 Answers   RoboSoft, Unilog,


When the procedures or packagess become invalidate

3 Answers   TCS,


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)