EXP的flashback_scn和flashback_time
數(shù)據(jù)庫(kù)設(shè)置
a.?設(shè)置UNDO_RETENTION的初始值(在短時(shí)間內(nèi))代表你想要查過(guò)去多遠(yuǎn)的時(shí)間。
b.?設(shè)置初始化參數(shù)UNDO_MANAGEMENT=AUTO。
c.?建立一個(gè)還原點(diǎn)空間,要有足夠的空間存儲(chǔ)需要的數(shù)據(jù)。有多少數(shù)據(jù)更新,就需要多少空間。
?
權(quán)限
FLASHBACK_SCN和FLASHBACK_TIME參數(shù)之前,你一定要允許DBMS_FLASHBACK程序包的執(zhí)行特權(quán),比如:
sqlplus?/nologSQL>?connect?/?as?sysdba
SQL>?GRANT?execute?ON?dbms_flashback?TO?scott;
1. flashback_scn:按SCN號(hào)一致導(dǎo)出數(shù)據(jù)
Session1:
SQL> conn / as sysdba
已連接。
SQL> grant execute on dbms_flashback to scott;
授權(quán)成功。
SQL> conn scott/tiger;
已連接。
SQL> create table t as select * from emp;
表已創(chuàng)建。
SQL> select * from t;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- -------------------- ------------------ ---------- -------------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-12月-80 446.67 20
7499 ALLEN SALESMAN 7698 20-2月 -81 1600 300 30
7521 WARD SALESMAN 7698 22-2月 -81 1250 500 30
7566 JONES MANAGER 7839 02-4月 -81 2975 20
7654 MARTIN SALESMAN 7698 28-9月 -81 1250 1400 30
7698 BLAKE MANAGER 7839 01-5月 -81 2850 30
7782 CLARK MANAGER 7839 09-6月 -81 2450 10
7788 SCOTT ANALYST 7566 19-4月 -87 555 20
7839 KING PRESIDENT 17-11月-81 5001 10
7844 TURNER SALESMAN 7698 08-9月 -81 1500 0 30
7876 ADAMS CLERK 7788 23-5月 -87 1100 20
7900 JAMES CLERK 7698 03-12月-81 950 30
7902 FORD ANALYST 7566 03-12月-81 3000 20
7934 MILLER CLERK 7782 23-1月 -82 1300 10
已選擇14行。
SQL> alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS';
會(huì)話已更改。
SQL> update t set job='ANALYST' where empno=7369;
已更新 1 行。
SQL> select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
3163077
SQL> commit;
提交完成。
SQL> select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
3163081
?
SQL> SELECT current_scn FROM v$database; --這種方法10gR1后也是可以用的
?
CURRENT_SCN
-----------
3165118
?
?
exp scott/tiger file=emp.dump log=emp.log flashback_scn=3163077 tables=EMP
Export: Release 11.2.0.1.0 - Production on 星期二 7月 22 01:09:29 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
連接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已導(dǎo)出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
服務(wù)器使用 AL32UTF8 字符集 (可能的字符集轉(zhuǎn)換)
即將導(dǎo)出指定的表通過(guò)常規(guī)路徑...
. . 正在導(dǎo)出表 EMP導(dǎo)出了 14 行
導(dǎo)出成功終止.
?
2. flashback_time:按給定時(shí)間最近的SCN導(dǎo)出數(shù)據(jù).
SQL> SELECT to_char(scn_to_timestamp(3163077),'YYYY-MM-DD HH24:MI:SS') FROM DUAL; -- 根據(jù)SCN查時(shí)間
TO_CHAR(SCN_TO_TIMESTAMP(3163077),'YYY
--------------------------------------
2014-07-22 00:45:03
?
SQL> SELECT to_char(scn_to_timestamp(3163081),'YYYY-MM-DD HH24:MI:SS') FROM DUAL;-- 根據(jù)SCN查時(shí)間
TO_CHAR(SCN_TO_TIMESTAMP(3163081),'YYY
--------------------------------------
2014-07-22 00:45:09
?
--flashback_time 必須用轉(zhuǎn)義過(guò)的雙引號(hào)包起來(lái),如果是寫在參數(shù)文件里,則不用這么麻煩自卸寫下面的樣子就行了.
flashback_time=to_timestamp('2014-07-22 00:45:05','YYYY-MM-DD HH24:MI:SS')
exp scott/tiger file=emp.dump log=emp.log flashback_time=\"to_timestamp('2014-07-22 00:45:05','YYYY-MM-DD HH24:MI:SS')\" tables=EMP
exp scott/tiger file=emp.dump parfile=param.txt
param.txt
file=emp.dump
log=emp.log
flashback_time='2014-07-22 00:45:05'
tables=EMP
file=emp.dump
log=emp.log
FLASHBACK_TIME="to_timestamp('2014-07-22 00:45:05','YYYY-MM-DD HH24:MI:SS')"
tables=EMP
?
Export: Release 11.2.0.1.0 - Production on 星期二 7月 22 01:09:29 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
連接到: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已導(dǎo)出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
服務(wù)器使用 AL32UTF8 字符集 (可能的字符集轉(zhuǎn)換)
即將導(dǎo)出指定的表通過(guò)常規(guī)路徑...
. . 正在導(dǎo)出表 EMP導(dǎo)出了 14 行
導(dǎo)出成功終止.
參考?http://www.landingbj.com/jbbs/t-0-196871-1.html
轉(zhuǎn)載于:https://www.cnblogs.com/princessd8251/p/3859538.html
總結(jié)
以上是生活随笔為你收集整理的EXP的flashback_scn和flashback_time的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Cocos2dx 中 倒计时保留2位数
- 下一篇: secureCRT 小技巧