what is difference between delete and truncet ?

Answers were Sorted based on User's Feedback



what is difference between delete and truncet ?..

Answer / 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

what is difference between delete and truncet ?..

Answer / 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 ?    4 Yes 2 No

what is difference between delete and truncet ?..

Answer / nitin bisht

Delete : A delete statement deletes the data from a table. A
delete statement can have a where clause, on which it
deletes the records that satisfy only the “where” condition.
If the
“where” condition is omitted the delete statement deletes
all the records in a table.

Actions of Delete statement :

* deletes the data from the current table space
* Modifies the undo tablespace with the delete records.
* Executes all the before / after statement and row
level triggers.
* Updates the indexes (makes the index empty if the
where clause is omitted).
* Constraint checks are performed before deleting the rows

.

Syntax of a delete Statement:

DELETE FROM table [WHERE condition]

Truncate : Truncate drops all the records in a table . But
as it is a DDL statement data cannot be retrieved. Usually
truncate is faster than delete statement becuase there is no
need to change or update the UNDO tablespace with the
deleted records. Truncate is an implict commit
Statement.Truncate statement deallocates the space.

Actions of Truncate Statement:Removes all the records from
the current tablespace.

* Updates the indexes.
* High watermark of the truncated table is reset.
* Integrity Constraint checks are performed

Syntax of a Truncate Statement:

TRUNCATE TABLE table_NAME ;

Is This Answer Correct ?    1 Yes 0 No

what is difference between delete and truncet ?..

Answer / pooja

The DELETE statement is used to delete rows in a table.

Syntax:
DELETE FROM table_name
WHERE some_column=some_value

e.g.
DELETE FROM Persons
WHERE LastName='Tjessem' AND FirstName='Jakob'


Truncate:-
What if we only want to delete the data inside the table,
and not the table itself?

Then, use the TRUNCATE TABLE statement:

Syntax:
TRUNCATE TABLE table_name

Is This Answer Correct ?    1 Yes 0 No

what is difference between delete and truncet ?..

Answer / karna

As of I know,we can roll back bothe delete and truncate
statements.but in case of delete statement logging of the
details in the log file takes more time,beacuse it logs the
details row by row in the page.
when it comes to truncate,all the rows will be logged at
the same time.

Please correct me,If I am wrong.

Is This Answer Correct ?    3 Yes 3 No

what is difference between delete and truncet ?..

Answer / prabhanjan

1)Truncate will perform faster then delete.
2)When we truncate table triggers will not fire on delete
event.Where as for delete triggers will fire
3)After truncate table we can't roll back.
But for Delete we can roll back

Is This Answer Correct ?    0 Yes 1 No

what is difference between delete and truncet ?..

Answer / 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 ?    0 Yes 2 No

Post New Answer

More Databases AllOther Interview Questions

What advantages does DBMS have over traditional file systems?

0 Answers   ABB, Infogain,


Differentiate between delete and truncate table?

0 Answers  


how to send multiple records which matches all the condition in the lookup transformation ? (if lookup matches the codition for duplicate values)

0 Answers  


define primary key index, bitmap index, hash index,virtual indwx

0 Answers   Cap Gemini,


How do database connections work?

0 Answers  






Should I store images in database?

0 Answers  


What is the best database?

0 Answers  


What are the advantages of normalizing a database.

0 Answers  


Can we use redis as database?

0 Answers  


What are ACID Properties?

1 Answers   TCS,


What is the Difference Primary key and Unique Key

0 Answers   HCL,


Which database is best to store images?

0 Answers  


Categories