|
本帖最后由 botang 于 2015-8-27 15:48 编辑
上完1Z0-053第10章 (52-40)
2015-08-26a.sql:
- select d.SUPPLEMENTAL_LOG_DATA_MIN, d.SUPPLEMENTAL_LOG_DATA_PK
- from v_$database d ;
-
-
- select * from flashback_transaction_query
- where table_name='T05310_FLASHBACK2' and table_owner='HR' order by commit_scn ;
-
- begin
- dbms_flashback.transaction_backout(numtxns => 1,
- xids => xid_array('0700130070050000'),
- options => dbms_flashback.cascade);
- end;
-
-
-
-
- commit;
- select * from DBA_FLASHBACK_TXN_STATE ;
- select * from DBA_FLASHBACK_TXN_REPORT ;
-
- select * from flashback_transaction_query
- where table_name='T05310_FLASHBACK3' and table_owner='HR' order by commit_scn ;
-
-
- begin
- dbms_flashback.transaction_backout(numtxns => 1,
- xids => xid_array('0300010000060000'),
- options => dbms_flashback.nocascade_force);
- end;
-
- commit;
-
- -----
- select * from flashback_transaction_query
- where table_name='T05310_FLASHBACK5' and table_owner='HR' order by commit_scn ;
-
-
- begin
- dbms_flashback.transaction_backout(numtxns => 1,
- xids => xid_array('070002004A050000'),
- options => dbms_flashback.nocascade_force);
- end;
- commit;
-
-
- begin
- dbms_flashback.transaction_backout(numtxns => 1,
- xids => xid_array('0300070006060000'),
- options => dbms_flashback.nonconflict_only);
- end;
- commit;
-
- select * from DBA_FLASHBACK_TXN_REPORT order by commit_time;
-
-
-
-
-
复制代码
2015-08-26b.sql:
- select * from dba_flashback_archive;
- select * from dba_flashback_archive_tables;
- select * from dba_flashback_archive_ts;
- create tablespace tbs05311 datafile size 20M autoextend on ;
- create flashback archive fda1
- tablespace tbs05311 quota 500M retention 2 year;
- create flashback archive fda2
- tablespace tbs05311 quota 500M retention 1 year;
- alter flashback archive fda1 set default;
- create flashback archive default fda3
- tablespace tbs05311 quota 500M retention 10 year;
- grant flashback archive on fda1 to hr;
- select * from hr.SYS_FBA_HIST_73953;
- create undo tablespace undotbs2 datafile size 20M autoextend on;
- alter system set undo_tablespace=undotbs2;
- drop tablespace undotbs1;
- select * from dba_Tablespaces;
- select * from v$transaction;
复制代码
t05310.sql
- undefine s1
- create table &&s1( id number ) ;
- ! sleep 5
- insert into &&s1 values (1) ;
- insert into &&s1 values (2) ;
- insert into &&s1 values (3) ;
- commit;
- update &&s1 set id=11 where id=1;
- update &&s1 set id=22 where id=2;
- update &&s1 set id=33 where id=3;
- commit;
- update &&s1 set id=222 where id=22;
- update &&s1 set id=333 where id=33;
- commit;
- update &&s1 set id=22 where id=222;
- commit;
复制代码
HR:
[root@station90 ~]# su - oracle
[oracle@station90 ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.3.0 Production on Wed Aug 26 20:44:01 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
SQL> conn hr/oracle_4U
ERROR:
ORA-28002: the password will expire within 5 days
Connected.
SQL> select salary from employees where employee_id=100;
SALARY
----------
34002
SQL> alter table employees flashback archive;
alter table employees flashback archive
*
ERROR at line 1:
ORA-55620: No privilege to use Flashback Archive
SQL> /
Table altered.
SQL> update employees set salary=50000 where employee_id=100;
1 row updated.
SQL> commit;
Commit complete.
SQL> select salary from employees where employee_id=100
2 ;
SALARY
----------
50000
SQL> sselect salary from employees
SP2-0734: unknown command beginning "sselect s..." - rest of line ignored.
SQL>
SQL>
SQL> select salary from employees
2 versions
SQL>
SQL>
SQL> select versions_xid , salary
2 from employees
3 versions between scn minvalue and maxvalue
4 where employee_id=100;
VERSIONS_XID SALARY
---------------- ----------
34002
0600060031060000 50000
SQL> select versions_xid , salary
2 from employees
3 versions between scn minvalue and maxvalue
4 where employee_id=100;
VERSIONS_XID SALARY
---------------- ----------
34002
0600060031060000 50000
SQL> select versions_xid , versions_startscn , salary
2 from employees
3 versions between scn minvalue and maxvalue
4 where employee_id=100;
VERSIONS_XID VERSIONS_STARTSCN SALARY
---------------- ----------------- ----------
34002
0600060031060000 2247793 50000
SQL> select salary from employees
2 as of scn 2247792
3 where employee_id=100;
SALARY
----------
34002
SQL> alter table employees enable row movement ;
Table altered.
SQL> flashback table employees to scn 2247792;
Flashback complete.
SQL> select salary from employees where employee_id=100;
SALARY
----------
34002
SQL> alter table departments flashback archive fda2 ;
alter table departments flashback archive fda2
*
ERROR at line 1:
ORA-55620: No privilege to use Flashback Archive
SQL> /
Table altered.
SQL> select salary from employees where employee_id=100;
SALARY
----------
34002
SQL> update employees set salary=60000 where employee_id=100;
1 row updated.
SQL> commit;
Commit complete.
SQL> select salary from employees
2 as of scn 2247792
3 where employee_id=100;
SALARY
----------
34002
SQL> select salary from employees
2 as of scn 2247792
3 where employee_id=100;
SALARY
----------
34002
SQL> alter table employees flashback archive none;
alter table employees flashback archive none
*
ERROR at line 1:
ORA-55605: Incorrect Flashback Archive is specified
SQL> alter table employees no flashback archive
2 ;
alter table employees no flashback archive
*
ERROR at line 1:
ORA-55620: No privilege to use Flashback Archive
SQL> alter table employees no flashback archive fda1 ;
alter table employees no flashback archive fda1
*
ERROR at line 1:
ORA-01735: invalid ALTER TABLE option
SQL> alter table employees no flashback archive ;
alter table employees no flashback archive
*
ERROR at line 1:
ORA-55620: No privilege to use Flashback Archive
SQL> select salary from employees
2 as of scn 2247792
3 where employee_id=100;
select salary from employees
*
ERROR at line 1:
ORA-01555: snapshot too old: rollback segment number with name "" too small
SQL> alter table employees flashback archive ;
Table altered.
SQL> select salary from employees where employee_id=100;
SALARY
----------
60000
SQL> select to_char(sysdate,'YYYY-MM-DD:HH24:MI:SS') from dual;
TO_CHAR(SYSDATE,'YY
-------------------
2015-08-26:21:36:22
SQL> update employees set salary=70000;
107 rows updated.
SQL> rollback;
Rollback complete.
SQL> update employees set salary=70000 where employee_id=100;
1 row updated.
SQL>
SQL> commit;
Commit complete.
SQL> select * from employees where employee_id=100;
EMPLOYEE_ID FIRST_NAME LAST_NAME
----------- -------------------- -------------------------
EMAIL PHONE_NUMBER HIRE_DATE JOB_ID
------------------------- -------------------- ------------------ ----------
SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
---------- -------------- ---------- -------------
100 Steven King
SKING 515.123.4567 17-JUN-03 AD_PRES
70000 90
SQL> select salary from employees
2 as of timestamp to_timestamp('2015-08-26:21:36:22','YYYY-MM-DD:HH24:MI:SS')
3 where employee_id=100;
SALARY
----------
60000
SQL> /
SALARY
----------
40000
SQL> flashback table employees to timestamp to_timestamp('2015-08-26:21:36:22','YYYY-MM-DD:HH24:MI:SS');
Flashback complete.
SQL> select salary from employees
2 where employee_id=100;
SALARY
----------
40000
SQL> insert into part1 values ( 1 , 'A' ) ;
1 row created.
SQL> insert into part1 values ( 50 , 'B' ) ;
1 row created.
SQL> insert into part1 values ( 500 , 'C' ) ;
1 row created.
SQL> commit;
Commit complete.
SQL> select * from part1;
A B
---------- --------------------
1 A
50 B
500 C
SQL> select * from part1 partition (part1_p1) ;
A B
---------- --------------------
1 A
50 B
SQL> alter table part1 flashback archive;
Table altered.
SQL> alter table part1 split partition part1_p1 at (50)
2 into ( partition part1_p11, partition part1_p12) ;
alter table part1 split partition part1_p1 at (50)
*
ERROR at line 1:
ORA-55610: Invalid DDL statement on history-tracked table
SQL> /
Table altered.
SQL> select * from part1 partition (part1_p11) ;
A B
---------- --------------------
1 A
SQL> select * from part1 partition (part1_p12) ;
A B
---------- --------------------
50 B
SQL> select * from part1 partition (part1_p2) ;
A B
---------- --------------------
500 C
SQL>
[root@station90 ~]# su - oracle
[oracle@station90 ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.3.0 Production on Wed Aug 26 20:44:01 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
SQL> conn hr/oracle_4U
ERROR:
ORA-28002: the password will expire within 5 days
Connected.
SQL> select salary from employees where employee_id=100;
SALARY
----------
34002
SQL> alter table employees flashback archive;
alter table employees flashback archive
*
ERROR at line 1:
ORA-55620: No privilege to use Flashback Archive
SQL> /
Table altered.
SQL> update employees set salary=50000 where employee_id=100;
1 row updated.
SQL> commit;
Commit complete.
SQL> select salary from employees where employee_id=100
2 ;
SALARY
----------
50000
SQL> sselect salary from employees
SP2-0734: unknown command beginning "sselect s..." - rest of line ignored.
SQL>
SQL>
SQL> select salary from employees
2 versions
SQL>
SQL>
SQL> select versions_xid , salary
2 from employees
3 versions between scn minvalue and maxvalue
4 where employee_id=100;
VERSIONS_XID SALARY
---------------- ----------
34002
0600060031060000 50000
SQL> select versions_xid , salary
2 from employees
3 versions between scn minvalue and maxvalue
4 where employee_id=100;
VERSIONS_XID SALARY
---------------- ----------
34002
0600060031060000 50000
SQL> select versions_xid , versions_startscn , salary
2 from employees
3 versions between scn minvalue and maxvalue
4 where employee_id=100;
VERSIONS_XID VERSIONS_STARTSCN SALARY
---------------- ----------------- ----------
34002
0600060031060000 2247793 50000
SQL> select salary from employees
2 as of scn 2247792
3 where employee_id=100;
SALARY
----------
34002
SQL> alter table employees enable row movement ;
Table altered.
SQL> flashback table employees to scn 2247792;
Flashback complete.
SQL> select salary from employees where employee_id=100;
SALARY
----------
34002
SQL> alter table departments flashback archive fda2 ;
alter table departments flashback archive fda2
*
ERROR at line 1:
ORA-55620: No privilege to use Flashback Archive
SQL> /
Table altered.
SQL> select salary from employees where employee_id=100;
SALARY
----------
34002
SQL> update employees set salary=60000 where employee_id=100;
1 row updated.
SQL> commit;
Commit complete.
SQL> select salary from employees
2 as of scn 2247792
3 where employee_id=100;
SALARY
----------
34002
SQL> select salary from employees
2 as of scn 2247792
3 where employee_id=100;
SALARY
----------
34002
SQL> alter table employees flashback archive none;
alter table employees flashback archive none
*
ERROR at line 1:
ORA-55605: Incorrect Flashback Archive is specified
SQL> alter table employees no flashback archive
2 ;
alter table employees no flashback archive
*
ERROR at line 1:
ORA-55620: No privilege to use Flashback Archive
SQL> alter table employees no flashback archive fda1 ;
alter table employees no flashback archive fda1
*
ERROR at line 1:
ORA-01735: invalid ALTER TABLE option
SQL> alter table employees no flashback archive ;
alter table employees no flashback archive
*
ERROR at line 1:
ORA-55620: No privilege to use Flashback Archive
SQL> select salary from employees
2 as of scn 2247792
3 where employee_id=100;
select salary from employees
*
ERROR at line 1:
ORA-01555: snapshot too old: rollback segment number with name "" too small
SQL> alter table employees flashback archive ;
Table altered.
SQL> select salary from employees where employee_id=100;
SALARY
----------
60000
SQL> select to_char(sysdate,'YYYY-MM-DD:HH24:MI:SS') from dual;
TO_CHAR(SYSDATE,'YY
-------------------
2015-08-26:21:36:22
SQL> update employees set salary=70000;
107 rows updated.
SQL> rollback;
Rollback complete.
SQL> update employees set salary=70000 where employee_id=100;
1 row updated.
SQL>
SQL> commit;
Commit complete.
SQL> select * from employees where employee_id=100;
EMPLOYEE_ID FIRST_NAME LAST_NAME
----------- -------------------- -------------------------
EMAIL PHONE_NUMBER HIRE_DATE JOB_ID
------------------------- -------------------- ------------------ ----------
SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
---------- -------------- ---------- -------------
100 Steven King
SKING 515.123.4567 17-JUN-03 AD_PRES
70000 90
SQL> select salary from employees
2 as of timestamp to_timestamp('2015-08-26:21:36:22','YYYY-MM-DD:HH24:MI:SS')
3 where employee_id=100;
SALARY
----------
60000
SQL> /
SALARY
----------
40000
SQL> flashback table employees to timestamp to_timestamp('2015-08-26:21:36:22','YYYY-MM-DD:HH24:MI:SS');
Flashback complete.
SQL> select salary from employees
2 where employee_id=100;
SALARY
----------
40000
SQL> insert into part1 values ( 1 , 'A' ) ;
1 row created.
SQL> insert into part1 values ( 50 , 'B' ) ;
1 row created.
SQL> insert into part1 values ( 500 , 'C' ) ;
1 row created.
SQL> commit;
Commit complete.
SQL> select * from part1;
A B
---------- --------------------
1 A
50 B
500 C
SQL> select * from part1 partition (part1_p1) ;
A B
---------- --------------------
1 A
50 B
SQL> alter table part1 flashback archive;
Table altered.
SQL> alter table part1 split partition part1_p1 at (50)
2 into ( partition part1_p11, partition part1_p12) ;
alter table part1 split partition part1_p1 at (50)
*
ERROR at line 1:
ORA-55610: Invalid DDL statement on history-tracked table
SQL> /
Table altered.
SQL> select * from part1 partition (part1_p11) ;
A B
---------- --------------------
1 A
SQL> select * from part1 partition (part1_p12) ;
A B
---------- --------------------
50 B
SQL> select * from part1 partition (part1_p2) ;
A B
---------- --------------------
500 C
SQL>
|
|