The difference between the oracle delte, truncate and drop the

1. Type: First, delete is dml statements, truncate and drop is ddl statement.

2. The space occupied by tables and indexes

After truncate table, the size of the tables and indexes to recover the space occupied by the original size.

delete does not change the size of the table and index space occupied.

drop tables and indexes in the space occupied by the release of all.

3. Delete speed

drop > truncate > delete

4. Structure

truncate and delete data without deleting the table where conditions, without deleting the table structure.

drop statement to delete the table structure, including constraints, triggers, indexes.

The dependent table stored procedures and functions are retained, but the status is invalid.

5.truncate与delete

truncate and delete without a where clause is identical in functionality, are deleted all the rows in the table. But truncate faster, and fewer system and transaction log resources used.

each delete statement delete a row, and record an entry for each row deleted in the transaction log.

truncate table to delete data stored in the page table by releasing the data used for data, and only releases the page is recorded in the transaction log.

6. For tables referenced by the foreign key constraint can not truncate table, but should not be used where clause delete statement. Since truncate table is not recorded in the log, it can not activate the trigger.

7.delete

delete statements do not affect the table occupied by the extent, high watermark remains unchanged.

8.truncate

Delete only the table data, table structure retention indexes, constraints, and so on. By default the space to release a minextents extent, unless reuse storage;

9.drop

Delete table structure and table data, and the release of all occupied space.

 

ocp exam:

Choose two.

You execute this command:

TRUNCATE TABLE dept;

Which two are true?

A) It drops any triggers defined on the table.

B) It retains the indexes defined on the table.

C) It retains the integrity constraints defined on the table.

D) A ROLLBACK statement can be used to retrieve the deleted data.

E) It always retains the space used by the removed rows.

F) A FLASHBACK TABLE statement can be used to retrieve the deleted data.

Correct Answer: BC

Which statement is true about TRUNCATE and DELETE?

A.  For large tables TRUNCATE is faster than DELETE.

B.  For tables with multiple indexes and triggers is faster than TRUNCATE.

C.  You can never TRUNCATE a table if foreign key constraints will be violated.

D.  You can never tows from a table if foreign key constraints will be violated.

 

135. Which two statements are true about truncate and delete?  

A. the result of a delete can be undone by issuing a rollback

B. delete can use a where clause to determine which row(s) should be removed.

C. TRUNCATE can use a where clause to determine which row(s) should be removed.

D. truncate leavers any indexes on the table in an UNUSABLE STATE.

E. the result of a truncate can be undone by issuing a ROLLBACK.

The answer : AB

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/liang-ning/p/11988725.html