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 is relational database with example?

0 Answers  


HOW PASS PARAMETERS FOLLOWING ORDER RPG-CL-RPG?

0 Answers  


hOW TO LOAD SOURCE INTO TARGET 2 TIMES?(INFORMATICA)

2 Answers  


can i use the commands "modify" and Change in DB2 to alter my column datatype and its name in a table?

0 Answers  


What are different types of resources?

0 Answers  






Differentiate between unique key and foreign key?

0 Answers   CGI,


Explain database partitioning. What is its importance?

0 Answers  


Explain entity type?

0 Answers  


Source File: Target EMPNO, SAL Empno, Format 101, 1000 101, 1000 101, 1100 101, 1000, 1100 101, 1000 101, 1000, 1100, 1000 101, 10000 101, 1000, 1100, 1000, 10000 102, 1100 102, 1100 102, 1300 102, 1100, 1300 102, 1200 102, 1100, 1300, 1200 102, 1500 102, 1100, 1300, 1200, 1500 How can i get that output using datastage(ETL) tool

0 Answers   Miracle Software,


What the various ways to tune a teradata query

0 Answers  


What is redis good for?

0 Answers  


What is the difference between oracle and MS Access?

0 Answers   Alcatel-Lucent,


Categories