Use Truncate:Clear and recycle space (mysql, sqlserver, and other databases with auto-incrementing sequences return to zero). The database cannot be restored and cannot be rolled back;
Use drop:The table can be restored but cannot be rolled back;
Use delete:Delete a record. No space is reclaimed. The record can be recovered and rolled back;
1. How can I restore data after using drop and delete?
Use the flashback statementFlashback table test2 to before drop; query the recycle bin select * from dba_recyclebin;
If you do not know whether the original table name or multiple identical tables are dropped at different times, you can use the recycle bin name to flash back.
Example: flashback table "BIN $ b2q1qVWuQZy + 1TAWJ0M + OA = $0" to before drop;
In this way, you will know the time when the table is recovered and dropped. After dropping a table before Oracle10g, the table will be deleted from the data dictionary. However, after dropping table (non-purge) in Oracle10g, only the deleted table is renamed in the data dictionary, and the table is not actually deleted from the data dictionary, the data dictionary table used to maintain the relationship between the name of the table before the deletion and the name of the table after the re-generated table, which is called the "recycle bin ), when drop table (with no purge added), the index and trigger will also go to the recycle bin together.
Objects in the recycle bin will always exist until the user decides to permanently delete them, and uses the PURGE command to clear the recycle bin space; or when there is insufficient space in the tablespace, they will be deleted.
Note: although only the table name in the data dictionary (of course there may be an index name, trigger name) is changed (usually it will become like BIN $ Phio9oeiQYESLIAUICKSE = $0 ), however, the object data is stored in the tablespace of the original table.
Table Name format in the recycle BIN: BIN $ globalUID $ Sversion. globalUID is a globally unique identifier object with a length of 24 characters. It is an internal identifier of Oracle. $ Sversion is the version number allocated by the database.
2. How do I recycle tablespaces after using drop and delete tables?
Use the Purge statementYou can directly use the following syntax to completely delete the TABLE and recycle the space drop table TABLE_NAME PURGE. the recycle bin can provide necessary information for recovery after misoperation, but if the recycle bin information is not frequently deleted
The disk space will be occupied for a long period of time, so the useless east in the recycle bin should be cleared frequently.
West. To clear the recycle bin, run the PURGE command. The PURGE command can delete
Tables, tablespaces, and indexes, and release the space occupied by tables, tablespaces, and indexes. PURGE command syntax
The format is as follows:
Purge table table_name;
Purge index index_name;
Purge recyclebin;
PURGE DBA_RECYCLEBIN;
Purge tablespace tablespace_name USER username;
(1) TABLE indicates clearing tables in the recycle bin.
(2) INDEX indicates clearing the INDEX in the recycle bin.
(3) TABLESPACE indicates clearing the TABLESPACE in the recycle bin.
(4) RECYCLEBIN refers to the recycle bin to be cleared by the current user.
(5) RECYCLEBIN can only be used with SYSDBA system permissions. This parameter allows you to clear all objects from the Oracle System recycle bin.