what is difference between delete and truncet ?

Answer Posted / shivaleela

DELETE:-

1.it is a DML stmt
2.it can include WHERE condition
3.it is only delete, so it can be rolled back can be ROLL
BACK

TRUNCATE:-

1.it is a DDL stmt
2.it can not include WHERE cnd
3.it is delete+commit ,so we cant roll back can not be ROLL
BACK


Both commands accomplish identical tasks (removing all data
from a table), but TRUNCATE is much faster

Reason:When you type DELETE.all the data get copied into
the Rollback Tablespace first.then delete operation get
performed.Thatswhy when you type ROLLBACK after deleting a
table ,you can get back the data(The system get it for you
from the Rollback Tablespace).All this process take
time.But when you type TRUNCATE,it removes data directly
without copying it into the Rollback Tablespace.Thatswhy
TRUNCATE is faster.Once you Truncate you cann't get back
the data.

Is This Answer Correct ?    8 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is aws documentdb?

648


How heap is implemented in database?

644


What is database bounce?

591


What is difference between server and database?

574


What is the advantage of varchar2 over char?

798






What is a driver in database?

559


What is the database url?

558


Is redis in memory database?

545


Can you tell any two advantages of stored procedures?

598


How do you connect to a database?

613


What is Data Modelling?

640


What are the various ways to execute a query in teradata?

2200


Write a query to get maximum and second maximum in oracle?

606


What is a database connection string?

590


After normalization, what are the conditions which have to keep in mind to de-normalize it?

624