ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

What is the difference between delete and truncate?

user-image
تم إضافة السؤال من قبل Abdullah Bajaber , ERP Supervisor and Business Analysis , 3D vision
تاريخ النشر: 2014/09/06
Gaith Amer Yousef  Rammaha
من قبل Gaith Amer Yousef Rammaha , Sr. Oracle developer and Project Manager , Technology village information system TVIS

TRUNCATE is a DDL statement. It issues auto-commit after the exectution of the statement.

BUT DELETE keeps records in buffers(temporary storage) till the first ROLLBACK or COMMIT. You can use conditions on DELETE like WHERE but  You can't using TRUNCATE.

and trancate for data size = zero

 

ranam maktabi
من قبل ranam maktabi , manager of programming and dba oracle , electrcity Aleppo

DELETE is a logged operation on a per row basis.  This means that the deletion of each row gets logged and physically deleted.

 

You can DELETE any row that will not violate a constraint, while leaving the foreign key or any other contraint in place

TRUNCATE is also a logged operation, but in a different way.  TRUNCATE logs the deallocation of the data pages in which the data exists.  The deallocation of data pages means that your data rows still actually exist in the data pages, but the extents have been marked as empty for reuse.  This is what makes TRUNCATE a faster operation to perform over DELETE.

You cannot TRUNCATE a table that has any foreign key constraints.  You will have to remove the contraints, TRUNCATE the table, and reapply the contraints.

 

 

 

VENKATESH NADIPINENI
من قبل VENKATESH NADIPINENI , Senior Project Engineer , WIPRO ARABIA LTD

Truncate is DDL command and Delete is DML command.

Truncate not maintains log and Delete command does.

Truncate cannot rollback but Delete can rollback data. 

Amitkumar Pandey
من قبل Amitkumar Pandey , Manager IT , Reliance Industries Ltd

Hi,

 

Delete operation simply mark the data to be removed from the extent/data block.

Delete operation is logged into redo log file hence same can be rollback.

 

However the truncate which is DDL operation its simply remove the data and free up the Data block /Data extent. it faster and can not rollback.

 

 

 

 

 

Ali Nawashy
من قبل Ali Nawashy , Medical representative , Al-Hilal Drug Store

DELETE operations can be rolled back, while TRUNCATE operations cannot be rolled back .

 

Mohammed Sirajuddin
من قبل Mohammed Sirajuddin , Software Development Senior Analyst , Dell International Services

DELETE operations can be rolled back, while TRUNCATE operations cannot be rolled back as it is DDL command. DELETE can be used to remove all or few records from a table using where clause. Where as TRUNCATE is used to remove all the records in a table.

siva panchakarla
من قبل siva panchakarla

delete can be used to delete particular row r colunm.

truncate can be used to delete overall table perminently.

Abdullah Bajaber
من قبل Abdullah Bajaber , ERP Supervisor and Business Analysis , 3D vision

 

Thanks a lot , clear answer

mudit dubey
من قبل mudit dubey , Senior Solution Integrator , Ericsson India Global Services Pvt. Ltd

1>TRUNCATE is a DDL command whereas DELETE is a DML command.

 

2>TRUNCATE is much faster than DELETE.

 

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.

 

3>You cann't rollback in TRUNCATE but in DELETE you can rollback.TRUNCATE removes the record permanently.

 

4>In case of TRUNCATE ,Trigger doesn't get fired.But in DML commands like DELETE .Trigger get fired.

5>You cann't use conditions(WHERE clause) in TRUNCATE.But in DELETE you can write conditions using WHERE clause

Arshad Jamil
من قبل Arshad Jamil , Freelancer , Freelancer

Truncate is a DDL command with auto-commit  and no selection (all data removed) and can not be reversed whereas delete is a DML command require a commit to confirm deletion + selection of records in where clause can be added to delete command.

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟