what is difference between delete and truncet ?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
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 |
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 |
what is vlook up in ms excel and how does it used???
how to reject duplicates in source sequential file and if by filter option then where is that filter option in the sequential file.
Explain various types of locks in a transaction? Which is better and why?
List various types of log-based recovery in DBMS.
what is primary key,unique key, foreign key? can u teach me in simple language?
44 Answers Banking, CMC, CTS, HCL, Infosys, Keggfarms, SkyEss, Sunrise, TCS, Web Synergies, Wipro,
what is rcp,if rcp disabled what happen?
what is transaction state, buffer management, shadow paging
1. How to test Database? Please, give me all details for "SQL,Msaccess, Mysql Database? 2.For which functionalities database used? 3.How to convert Guest to Admin by Mysql database?
Explain the various types of normalization.
What is dialect in database?
HOW WE PASS PARM PARAMETERS TO CL VARIABLES FROM RPGLE?
Integrity constraints means..? how many and what are they?