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 does new grouping sets enables you to do?

0 Answers   ADITI,


I have single column in a file. Input 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 my output is file 1 have 1,2,3,10,11,12 file 2 have 4,5,6,13,14,15 and file 3 have 7,8,9 how is it possible in datastage

0 Answers   IBM,


Should I store images in database?

0 Answers  


How heap is implemented in database?

0 Answers   Amazon,


HOW PASS PARAMETERS FOLLOWING ORDER RPG-CL-RPG?

0 Answers  






Can a database table exist without a primary key?

0 Answers  


What is aws documentdb?

0 Answers  


Given a table of Player which contains Sno and player name, write a query which finds all possible Table Tennis doubles pairings.

0 Answers   Amazon,


Two tables emp(empid,name,deptid,sal) and dept(deptid,deptname) are there.write a query which displays empname,corresponding deptname also display those employee names who donot belong to any dept.

0 Answers   Amazon,


How many indexes can be created on a table?

0 Answers   Abacus,


Define stored procedure?

0 Answers  


what is data set ?

1 Answers  


Categories