what is the difference truncate or delete - All Records

very basic question: to delete data for more than 100 tables and wanted to retain the table structure and index.

Which one is the best option to remove all data from table TRUNCATE or DELETE?


truncate is DDL.

which means

- implicit commit before the statement

- implicit commit after the statement

- the high water mark of the table will be reset

It will use no redo and can not be rolled back.

delete is dml

it means

if no commit after the statement

The HWM will not be reset.

commit/rolled back is possible

DROP : 

It is a DDL. It is used to drop the whole table. With the help of the “DROP” command we can drop the whole structure in one go it removes the object from the schema. 

DROP table table-name purge;

can’t restore the table by using the “ROLLBACK” command because it auto commits.

DELETE : 

it is dml It is used to delete one or more tuples of a table. With the help of the “DELETE” command, we can either delete all the rows in one go or can delete rows one by one. i.e., we can use it as per the requirement or the condition using the Where clause. It is comparatively slower than the TRUNCATE command. The TRUNCATE command does not remove the structure of the table.

    DELETE from table-name where condition;

TRUNCATE : 

It is DDL. It is used to delete all the rows of a table. With the help of the “TRUNCATE” command, we can’t delete the single row as here WHERE clause is not used. By using this command the existence of all the rows will be deleted. It is comparatively faster than the delete command. 

TRUNCATE table table_name;
        

    Comments

    Popular posts from this blog

    How to fix Oracle SQL Developer connection issue "Got minus one from a read call"

    How to drop index and before dropping it how to get the DDL.

    How to troubleshoot Long Running Concurrent Request in EBS 12.2

    How to autopopulate user_guid in fnd_user table ( EBS Blank Page)

    Opatch is getting faild for GI patch with error code 2 while doing prereq

    Few Important steps of Oracle Database Clone

    How to Check AD and TXK code levels in your EBS environment

    The Server is not able to service this request: [Socket:000445]Connection rejected, filter blocked Socket, weblogic.security.net.FilterException

    CPU Patch Analysis

    PRVG-11250 : The check "RPM Package Manager database" was not performed because