For the Oracle database, in order to ensure the security of data, we need to set up the database of the Recycle Bin function, the default function is open. We can view and modify them through the following steps
1 See if the database has a Recycle Bin (recyclebin feature)
Show parameter RecycleBin;
Sql> Show parameter RecycleBin;
NAME TYPE VALUE
------------------------------------ -----------
RecycleBin string on
2 If this value is on, it indicates that the Recycle Bin function has been turned on, and if it is off , Then we need to open the database Recycle Bin function through the command.
command to turn recyclebin on and off
Turn on the reclebin command
View status
Sql> Show parameter RecycleBin;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
RecycleBin string OFF
The modification will be on, and it is important to note that you want to specify scope=spfileBecause this parameter cannot be modified in memory.
Sql> alter system set Recyclebin=on Scope=spfile;
System Altered
The state has been modified and we need to restart the database to make the parameters effective
Sql> alter system set Recyclebin=on Scope=spfile;
System Altered
3 Turn off the Recycle Bin feature of the database ( because the SPFile is modified , the database will need to be restarted for it to take effect )
Sql> alter system set Recyclebin=on Scope=spfile;
System Altered
4 emptying the data inside the recycle bin
Empty all data inside the Recycle Bin
Sql> purge RecycleBin;
Done
Clear a specific table
Sql> Purge Table dept;
Done
5 Data Restore function (most important), the function of turning on the Recycle Bin of the database is to prevent accidental deletion, can collect data.
Flashback table BONUS to before drop ;
Restore data in a renamed manner
Flashback table salgrade to before Drop rename to Salgrade_bak ;
Modify table names in a database
Alter table salgrade_bak rename to Salgrade
Recycle Bin for Oracle Database