Anti delete library Practical Guide | one step, rapid recall of accidentally deleted table

Some very good enterprise-level database functionality is "maintaining an army for a thousand days, temporary use of troops," such as Oracle 10g Recycle Bin (Recycle Bin) function, can play a special forces in exceptional circumstances, such as when you delete a table space when a user (Schema), may remove many tables, including some tables you do not want to delete.

Examples of this are still many, many of the early years of DBA use graphical tools to access the database, user rights connected and relatively high, when a query large amounts of data caused a brief loss of response graphical tools, it is easy to play a few more keyboard or multiple a few clicks of the mouse, the graphical tool until the response came, found some tables or some users had disappeared.

Speaking in front is intentional, you can also see some determined malicious actions, destructive actions such as due to the relationship between employees and the company is not friendly due. Then you can check whether there are trash Oracle database table is deleted.

AliSQL is a branch of Ali cloud RDS MySQL team well-built, has greatly improved and a breakthrough in performance, functionality and stability. In December 2019 the published version also brought Recycle Bin function, only need to set a parameter can be opened:

mysql> set global recycle_bin=on;
Query OK, 0 rows affected (0.00 sec)
mysql> show global variables like 'recycle_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| recycle_bin   | ON    |
+---------------+-------+
1 row in set (0.00 sec)

Let's create a table, insert some data, functional testing and validation. As follows:

mysql> use test;
Database changed
mysql> create table t_recycle_bin_demo (col1 int not null);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t_recycle_bin_demo values (1),(2);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0
mysql> select * from t_recycle_bin_demo;
+------+
| col1 |
+------+
|    1 |
|    2 |
+------+
2 rows in set (0.00 sec)

Assuming this is a very important table, and was accidentally Drop out, let's look at how to retrieve data for this table. As follows:
* Please read Swipe

mysql> drop table t_recycle_bin_demo;
Query OK, 0 rows affected (0.01 sec)
mysql> call dbms_recycle.show_tables();
+-----------------+---------------+---------------+--------------------+---------------------+---------------------+
| SCHEMA          | TABLE         | ORIGIN_SCHEMA | ORIGIN_TABLE       | RECYCLED_TIME       | PURGE_TIME          |
+-----------------+---------------+---------------+--------------------+---------------------+---------------------+
| __recycle_bin__ | __innodb_1073 | test          | t_recycle_bin_demo | 2020-02-27 06:48:24 | 2020-03-05 06:48:24 |
+-----------------+---------------+---------------+--------------------+---------------------+---------------------+
1 row in set (0.00 sec)
mysql> select * from `__recycle_bin__`.`__innodb_1073`;
+------+
| col1 |
+------+
|    1 |
|    2 |
+------+
2 rows in set (0.00 sec)

You can see, AliSQL in the case of the Recycle Bin function is turned on, the deleted table is moved to the "__recycle_bin__" database below, can be accessed by Select statements directly read out the data to be deleted to recover, so back up your important data. Oracle and different places, "__ recycle_bin__" database access requires a clear mandate to operate, which can prevent the owner of a table (possibly malicious person) synchronous clean up the trash in the table. For example, I use the general user login into operation, it will report a permissions error, as follows:
* Please read about the slide

mysql> select * from `__recycle_bin__`.`__innodb_1073`;
ERROR 1142 (42000): SELECT command denied to user 'test'@'localhost' for table '__innodb_1073'
mysql> call dbms_recycle.purge_table('__innodb_1073');
ERROR 1142 (42000): DROP command denied to user 'test'@'localhost' for table '__innodb_1073'

AliSQL can be seen through the Recycle Bin feature, as well as a well-planned rights management mechanism, can effectively deal with the problem table is accidentally or maliciously deleted, make sure your data is secure.

Point here to understand the Recycle Bin function details


 

Ali cloud procurement season
cloud database Stream One-stop solution
to scan two-dimensional code directly


Lala .jpg

Original link
This article Yunqi community original content may not be reproduced without permission.

Released 2315 original articles · won praise 2020 · Views 1.39 million +

Guess you like

Origin blog.csdn.net/yunqiinsight/article/details/104999097