首页 > 数据库 >oracle 11g单表恢复

oracle 11g单表恢复

时间:2022-12-05 21:01:36浏览次数:44  
标签:11g timestamp 00 leo test 单表 SQL oracle select

文档课题:oracle 11g单表恢复.
数据库:oracle 11.2.0.4 64位
系统:oel 7.9 64位
1、非rman方式
1.1、flashback恢复
[oracle@oel ~]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
[oracle@oel ~]$ export NLS_LANG=AMERICAN
[oracle@oel ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Dec 5 09:55:09 2022

Copyright (c) 1982, 2013, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> conn leo/leo;
Connected.
SQL> create table test as select * from all_objects;

Table created.

SQL> select count(*) from test;

COUNT(*)
----------
84209

SQL> delete from test where rownum<40000;

2000 rows deleted.

SQL> commit;

Commit complete.

SQL> select count(*) from test;

COUNT(*)
----------
0

SQL> conn / as sysdba
Connected.

SQL> select count(*) from leo.test as of timestamp to_timestamp('2022-12-05 10:00:00','yyyy-mm-dd hh24:mi:ss');

COUNT(*)
----------
84209

SQL> flashback table leo.test to timestamp to_timestamp('2022-12-05 10:00:00','yyyy-mm-dd hh24:mi:ss');
flashback table leo.test to timestamp to_timestamp('2022-12-05 10:00:00','yyyy-mm-dd hh24:mi:ss')
*
ERROR at line 1:
ORA-08189: cannot flashback the table because row movement is not enabled


SQL> alter table leo.test enable row movement;

Table altered.

SQL> flashback table leo.test to timestamp to_timestamp('2022-12-05 10:00:00','yyyy-mm-dd hh24:mi:ss');

Flashback complete.

SQL> select count(*) from leo.test;

COUNT(*)
----------
84209
1.2、创建副表
SQL> conn leo/leo;
Connected.
SQL> host date
Mon Dec 5 10:27:50 CST 2022

SQL> delete from test;

84212 rows deleted.

SQL> commit;

Commit complete.

SQL> select count(*) from test;

COUNT(*)
----------
0

SQL> conn / as sysdba
Connected.

SQL> select count(*) from leo.test as of timestamp to_timestamp('2022-12-05 10:27:50','yyyy-mm-dd hh24:mi:ss');

COUNT(*)
----------
84212

SQL> create table leo.testbak as select * from leo.test as of timestamp to_timestamp('2022-12-05 10:27:50','yyyy-mm-dd hh24:mi:ss');

Table created.

SQL> conn leo/leo;
Connected.
SQL> select count(*) from testbak;

COUNT(*)
----------
84212

说明:创建的副表不会有原表存在的主键等约束.
参考网址:https://www.jianshu.com/p/9eb51510b1fc

标签:11g,timestamp,00,leo,test,单表,SQL,oracle,select
From: https://blog.51cto.com/u_12991611/5913285

相关文章