|
上完1Z0-053的第11章
1Z0-051共12章(上完10章),1Z0-052共19章(上完10章),1Z0-053共21章(上完4章)
总共上完全部52章中的24章
PL/SQL Developer课堂执行的命令:
- create flashback archive fda1
- tablespace users quota 10M retention 2 year;
- grant flashback archive on fda1 to hr;
- select * from dba_flashback_archive_tables;
- begin
- dbms_flashback_archive.disassociate_fba('HR','T05311_A');
- end;
- begin
- dbms_flashback_archive.reassociate_fba('HR','T05311_A');
- end;
- select * from dba_tab_partitions tp
- where tp.table_owner='HR' and tp.table_name='PART1';
- --------------------------------------
- select * from dba_tables t where t.owner='HR' and t.table_name='T05311_C';
- select * from dba_indexes i where i.owner='HR' and i.table_name='T05311_C';
- select * from dba_constraints c
- where c.owner='HR' and c.table_name='T05311_C';
-
- select * from dba_recyclebin;
-
- alter user dbsnmp identified by oracle_4U account unlock;
-
- alter user sysman identified by oracle_4U account unlock;
-
- create table hr.t_big tablespace users as select * from dba_source;
-
- alter user sh identified by oracle_4U account unlock;
-
- ---
-
- purge tablespace users user sh;
-
-
- purge tablespace users;
-
- select * from dba_recyclebin;
复制代码 sqlplus课堂执行的命令:
- [root@station90 ~]# su - oracle
- [oracle@station90 ~]$ sqlplus /nolog
- SQL*Plus: Release 11.2.0.1.0 Production on Wed May 3 19:39:20 2017
- Copyright (c) 1982, 2009, Oracle. All rights reserved.
- SQL> conn hr/oracle_4U
- ERROR:
- ORA-28002: the password will expire within 7 days
- Connected.
- SQL> create table t05311_a ( a number , b varchar2(20)) ;
- Table created.
- SQL> insert into t05311_a values ( 1 ,'A') ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> alter table t05311_a flashback archive fda1 ;
- Table altered.
- SQL> update t05311_a set a=2 where a=1;
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL> select versions_xid, versions_startscn , versions_operation , a, b from t05311_a
- 2 versions between scn minvalue and maxvalue;
- VERSIONS_XID VERSIONS_STARTSCN V A B
- ---------------- ----------------- - ---------- --------------------
- 09000E0068030000 1087634 U 2 A
- 0300020069030000 1087552 I 1 A
- SQL> alter table t05311_A drop ( b) ;
- Table altered.
- SQL> select versions_xid, versions_startscn , versions_operation , a, b from t05311_a
- 2 versions between scn minvalue and maxvalue;
- VERSIONS_XID VERSIONS_STARTSCN V A B
- ---------------- ----------------- - ---------- --------------------
- 09000E0068030000 1087634 U 2 A
- 0300020069030000 1087552 I 1 A
- 1087813 U 2
- SQL> select a, b from t05311_a
- 2 as of scn 1087552;
- A B
- ---------- --------------------
- 1 A
- SQL> alter table t05311_a enable row movement ;
- Table altered.
- SQL> flashback table t05311_a to scn 1087552;
- flashback table t05311_a to scn 1087552
- *
- ERROR at line 1:
- ORA-01466: unable to read data - table definition has changed
- SQL> create table part1 ( a number )
- 2 partition by range ( a )
- 3 ( parttion p_1 values less than ( 50),
- 4 partition p_2 values less than (maxvalue) ) ;
- ( parttion p_1 values less than ( 50),
- *
- ERROR at line 3:
- ORA-14004: missing PARTITION keyword
- SQL> create table part1 ( a number )
- 2 partition by range ( a )
- 3 ( partition p_1 values less than ( 50),
- 4 partition p_2 values less than (maxvalue) ) ;
- Table created.
- SQL> insert into part1 values (50) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> select * from part1;
- A
- ----------
- 50
- SQL> insert into part1 values (1) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> select * from part1;
- A
- ----------
- 1
- 50
- SQL> select * from part1 partition (p_1);
- A
- ----------
- 1
- SQL> select * from part1 partition (p_2);
- A
- ----------
- 50
- SQL> alter table part1 drop partition p_2 ;
- Table altered.
- SQL> alter table part1 add partition p_2 values less than ( maxvalue) ;
- Table altered.
- SQL> insert into part1 values (50);
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> alter table part1 flashback archive fda1 ;
- Table altered.
- SQL> update part1 set a=2 where a=1;
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL> alter table part1 drop partition p_2 ;
- Table altered.
- SQL> select versions_xid, versions_startscn , versions_operation , a
- 2 from part1
- 3 versions between scn minvalue and maxvalue;
- VERSIONS_XID VERSIONS_STARTSCN V A
- ---------------- ----------------- - ----------
- 50
- 1
- 0A00160096020000 1089265 U 2
- SQL> select a from part
- 2 as of scn 1089264 ;
- select a from part
- *
- ERROR at line 1:
- ORA-00942: table or view does not exist
- SQL> select a from part1
- 2 as of scn 1089264 ;
- A
- ----------
- 50
- 1
- SQL> select * from part1;
- A
- ----------
- 2
- SQL> alter table part1 truncate partition p_1 ;
- Table truncated.
- SQL> select versions_xid, versions_startscn , versions_operation , a
- 2 from part1
- 3 versions between scn minvalue and maxvalue;
- VERSIONS_XID VERSIONS_STARTSCN V A
- ---------------- ----------------- - ----------
- 50
- 0A00160096020000 1089265 U 2
- 1
- SQL> select a from part1;
- no rows selected
- SQL> select a from part1
- 2 as of scn 1089264;
- A
- ----------
- 50
- 1
- SQL> select * from part1;
- no rows selected
- SQL> insert into part1 values ( 50) ;
- insert into part1 values ( 50)
- *
- ERROR at line 1:
- ORA-14400: inserted partition key does not map to any partition
- SQL> insert into part1 values ( 10) ;
- 1 row created.
- SQL> insert into part1 values ( 20) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> alter table part1 split partition p_1 at ( 10) into ( partition p_1a , partition p_1b) ;
- alter table part1 split partition p_1 at ( 10) into ( partition p_1a , partition p_1b)
- *
- ERROR at line 1:
- ORA-55610: Invalid DDL statement on history-tracked table
- SQL> update part1 set a=21 where a=20'
- 2 ;
- ERROR:
- ORA-01756: quoted string not properly terminated
- SQL> update part1 set a=21 where a=20;
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL> select versions_xid, versions_startscn , versions_operation , a
- 2 versions between scn minvalue and maxvalue;
- versions between scn minvalue and maxvalue
- *
- ERROR at line 2:
- ORA-00923: FROM keyword not found where expected
- SQL> select versions_xid, versions_startscn , versions_operation , a
- 2 from part1
- 3 versions between scn minvalue and maxvalue;
- VERSIONS_XID VERSIONS_STARTSCN V A
- ---------------- ----------------- - ----------
- 50
- 0A00160096020000 1089265 U 2
- 1
- 09001D006B030000 1089763 I 10
- 09001D006B030000 1089763 I 20
- 030004006C030000 1090158 U 21
- 6 rows selected.
- SQL> begin
- 2
- 3 ;
- 4
- SQL>
- SQL> alter table part1 split partition p_1 at (9) into ( partition p_1a , partition p_1b) ;
- Table altered.
- SQL> select * from SYS_FBA_HIST_74604;
- RID
- --------------------------------------------------------------------------------
- STARTSCN ENDSCN XID O A
- ---------- ---------- ---------------- - ----------
- AAASNvAAEAAAAI8AAA
- 1089365 50
- AAASNtAAEAAAAI0AAA
- 1089265 1089563 0A00160096020000 U 2
- AAASNtAAEAAAAI0AAA
- 1089265 1
- RID
- --------------------------------------------------------------------------------
- STARTSCN ENDSCN XID O A
- ---------- ---------- ---------------- - ----------
- AAASN3AAEAAAAI0AAB
- 1089763 1090158 09001D006B030000 I 20
- SQL> update SYS_FBA_HIST_74604 set a=30 where a=20 ;
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL> select versions_xid, versions_startscn , versions_operation , a
- 2 from part1
- 3 versions between scn minvalue and maxvalue;
- VERSIONS_XID VERSIONS_STARTSCN V A
- ---------------- ----------------- - ----------
- 10
- 21
- SQL> select a from part1
- 2 as of scn 1090158 ;
- A
- ----------
- 10
- 21
- SQL> update part1 set a=40 where a=21;
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL> select versions_xid, versions_startscn , versions_operation , a
- 2 from part1
- 3 versions between scn minvalue and maxvalue;
- VERSIONS_XID VERSIONS_STARTSCN V A
- ---------------- ----------------- - ----------
- 01001000A9020000 1090827 U 40
- 10
- 21
- SQL> update SYS_FBA_HIST_74604 set a=30 where a=20 ;
- update SYS_FBA_HIST_74604 set a=30 where a=20
- *
- ERROR at line 1:
- ORA-55622: DML, ALTER and CREATE UNIQUE INDEX operations are not allowed on
- table "HR"."SYS_FBA_HIST_74604"
- SQL> update SYS_FBA_HIST_74604 set a=30 where a=21;
- 0 rows updated.
- SQL> select * from SYS_FBA_HIST_74604;
- RID
- --------------------------------------------------------------------------------
- STARTSCN ENDSCN XID O A
- ---------- ---------- ---------------- - ----------
- AAASNvAAEAAAAI8AAA
- 1089365 50
- AAASNtAAEAAAAI0AAA
- 1089265 1089563 0A00160096020000 U 2
- AAASNtAAEAAAAI0AAA
- 1089265 1
- RID
- --------------------------------------------------------------------------------
- STARTSCN ENDSCN XID O A
- ---------- ---------- ---------------- - ----------
- AAASN3AAEAAAAI0AAB
- 1089763 1090158 09001D006B030000 I 30
- SQL> commit;
- Commit complete.
- SQL> select * from SYS_FBA_HIST_74604;
- RID
- --------------------------------------------------------------------------------
- STARTSCN ENDSCN XID O A
- ---------- ---------- ---------------- - ----------
- AAASNvAAEAAAAI8AAA
- 1089365 50
- AAASNtAAEAAAAI0AAA
- 1089265 1089563 0A00160096020000 U 2
- AAASNtAAEAAAAI0AAA
- 1089265 1
- RID
- --------------------------------------------------------------------------------
- STARTSCN ENDSCN XID O A
- ---------- ---------- ---------------- - ----------
- AAASN3AAEAAAAI0AAB
- 1089763 1090158 09001D006B030000 I 30
- SQL> select versions_xid, versions_startscn , versions_operation , a
- 2 from part1
- 3 versions between scn minvalue and maxvalue;
- VERSIONS_XID VERSIONS_STARTSCN V A
- ---------------- ----------------- - ----------
- 01001000A9020000 1090827 U 40
- 10
- 21
- SQL>
- SQL> conn / as sysdba
- Connected.
- SQL> shutdown immediate
- Database closed.
- Database dismounted.
- ORACLE instance shut down.
- SQL> startup
- ORACLE instance started.
- Total System Global Area 6680915968 bytes
- Fixed Size 2213936 bytes
- Variable Size 3556771792 bytes
- Database Buffers 3087007744 bytes
- Redo Buffers 34922496 bytes
- Database mounted.
- Database opened.
- SQL> conn hr/oracle_4U
- ERROR:
- ORA-28002: the password will expire within 7 days
- Connected.
- SQL> select * from SYS_FBA_HIST_74604;
- RID
- --------------------------------------------------------------------------------
- STARTSCN ENDSCN XID O A
- ---------- ---------- ---------------- - ----------
- AAASNvAAEAAAAI8AAA
- 1089365 50
- AAASNtAAEAAAAI0AAA
- 1089265 1089563 0A00160096020000 U 2
- AAASNtAAEAAAAI0AAA
- 1089265 1
- RID
- --------------------------------------------------------------------------------
- STARTSCN ENDSCN XID O A
- ---------- ---------- ---------------- - ----------
- AAASN3AAEAAAAI0AAB
- 1089763 1090158 09001D006B030000 I 30
- SQL> select * from 40
- 2
- SQL> select * from SYS_FBA_HIST_74596;
- RID
- --------------------------------------------------------------------------------
- STARTSCN ENDSCN XID O A D_1087817_B
- ---------- ---------- ---------------- - ---------- --------------------
- AAASNkAAEAAAAIMAAA
- 1087634 1087813 09000E0068030000 U 2 A
- AAASNkAAEAAAAIMAAA
- 1087552 1087634 0300020069030000 I 1 A
- SQL> select * from t05311_A;
- A
- ----------
- 2
- SQL> select * from t05311_A
- 2 as of scn 1087634 ;
- A B
- ---------- --------------------
- 2 A
- SQL> as of scn 1087633 ;
- SP2-0734: unknown command beginning "as of scn ..." - rest of line ignored.
- SQL> select * from t05311_A
- 2 as of scn 1087633 ;
- A B
- ---------- --------------------
- 1 A
- SQL> update SYS_FBA_HIST_74596 set a=10 where a=1;
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL> select * from t05311_A
- 2 as of scn 1087633 ;
- B A
- -------------------- ----------
- A 10
- SQL> select versions_startscn , a ,b
- 2 from t05311_A
- 3 versions between scn minvalue and maxvalue ;
- select versions_startscn , a ,b
- *
- ERROR at line 1:
- ORA-00904: "B": invalid identifier
- SQL> select versions_startscn , a
- 2 from t05311_A
- 3 versions between scn minvalue and maxvalue ;
- VERSIONS_STARTSCN A
- ----------------- ----------
- 2
- SQL> conn / as sysdba
- Connected.
- SQL> show parameter recycle
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- buffer_pool_recycle string
- db_recycle_cache_size big integer 0
- recyclebin string on
- SQL> conn hr/oracle_4U
- ERROR:
- ORA-28002: the password will expire within 7 days
- Connected.
- SQL> create table t05311_b ( a number ) ;
- Table created.
- SQL> insert into t05311_b values (1) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> drop table t05311_b;
- Table dropped.
- SQL> flashback table t05311_b to before drop;
- Flashback complete.
- SQL> select * from t05311_b;
- A
- ----------
- 1
- SQL> create table t05311_c ( a number constraint pk_t05311_c primary key ) ;
- Table created.
- SQL> insert into t05311_c values (1) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> drop table t05311_c;
- Table dropped.
- SQL> select * from "BIN$Tp8V55Xuh9bgUKjAWgACtA==$0";
- A
- ----------
- 1
- SQL>
- SQL> select * from BIN$Tp8V55Xuh9bgUKjAWgACtA==$0;
- select * from BIN$Tp8V55Xuh9bgUKjAWgACtA==$0
- *
- ERROR at line 1:
- ORA-00933: SQL command not properly ended
- SQL> select * from "BIN$Tp8V55Xuh9bgUKjAWgACtA==$0";
- A
- ----------
- 1
- SQL> flashback table "BIN$Tp8V55Xuh9bgUKjAWgACtA==$0" to before drop;
- Flashback complete.
- SQL> alter index "BIN$Tp8V55Xth9bgUKjAWgACtA==$0" rename to pk_t05311_c;
- Index altered.
- SQL>
- SQL> rename t05311_c to t05311_c2;
- Table renamed.
- SQL> drop table t05311_c2;
- Table dropped.
- SQL> select * from user_recyclebin;
- OBJECT_NAME ORIGINAL_NAME OPERATION
- ------------------------------ -------------------------------- ---------
- TYPE TS_NAME CREATETIME
- ------------------------- ------------------------------ -------------------
- DROPTIME DROPSCN PARTITION_NAME CAN CAN
- ------------------- ---------- -------------------------------- --- ---
- RELATED BASE_OBJECT PURGE_OBJECT SPACE
- ---------- ----------- ------------ ----------
- BIN$Tp8V55Xwh9bgUKjAWgACtA==$0 PK_T05311_C DROP
- INDEX USERS 2017-05-03:20:54:05
- 2017-05-03:21:03:17 1096412 NO YES
- 74627 74627 74628 8
- OBJECT_NAME ORIGINAL_NAME OPERATION
- ------------------------------ -------------------------------- ---------
- TYPE TS_NAME CREATETIME
- ------------------------- ------------------------------ -------------------
- DROPTIME DROPSCN PARTITION_NAME CAN CAN
- ------------------- ---------- -------------------------------- --- ---
- RELATED BASE_OBJECT PURGE_OBJECT SPACE
- ---------- ----------- ------------ ----------
- BIN$Tp8V55Xxh9bgUKjAWgACtA==$0 T05311_C2 DROP
- TABLE USERS 2017-05-03:20:54:05
- 2017-05-03:21:03:17 1096415 YES YES
- 74627 74627 74627 8
- SQL> show recyclebin
- ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
- ---------------- ------------------------------ ------------ -------------------
- T05311_C2 BIN$Tp8V55Xxh9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:03:17
- SQL> show recyclebin
- SQL> flashback table T05311_C2 to before drop;
- flashback table T05311_C2 to before drop
- *
- ERROR at line 1:
- ORA-38305: object not in RECYCLE BIN
- SQL> create table t05311_d ( a number ) ;
- Table created.
- SQL> insert into t05311_d values ( 123456) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> drop table t05311_d purge;
- Table dropped.
- SQL> flashback table t05311_d to before drop;
- flashback table t05311_d to before drop
- *
- ERROR at line 1:
- ORA-38305: object not in RECYCLE BIN
- SQL> create table t05311_e ( a number ) ;
- Table created.
- SQL> insert into t05311_e values ( 123456 ) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> drop table t05311_e ;
- Table dropped.
- SQL> show recyclebin
- ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
- ---------------- ------------------------------ ------------ -------------------
- T05311_E BIN$Tp8V55Xyh9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:10:55
- SQL> create table t05311_f ( a number ) ;
- Table created.
- SQL> insert into t05311_f values ( 987654) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> drop table t05311_f;
- Table dropped.
- SQL> show recyclebin;
- ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
- ---------------- ------------------------------ ------------ -------------------
- T05311_E BIN$Tp8V55Xyh9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:10:55
- T05311_F BIN$Tp8V55Xzh9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:11:31
- SQL> create table t05311_e ( a number ) ;
- Table created.
- SQL> insert into t05311_e values ( 99999 ) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> drop table t05311_e;
- Table dropped.
- SQL> show recyclebin;
- ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
- ---------------- ------------------------------ ------------ -------------------
- T05311_E BIN$Tp8V55X0h9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:12:20
- T05311_E BIN$Tp8V55Xyh9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:10:55
- T05311_F BIN$Tp8V55Xzh9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:11:31
- SQL> select * from "BIN$Tp8V55Xyh9bgUKjAWgACtA==$0";
- A
- ----------
- 123456
- SQL> purge table "BIN$Tp8V55Xyh9bgUKjAWgACtA==$0";
- Table purged.
- SQL> show recyclebin;
- ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
- ---------------- ------------------------------ ------------ -------------------
- T05311_E BIN$Tp8V55X0h9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:12:20
- T05311_F BIN$Tp8V55Xzh9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:11:31
- SQL> select * from "BIN$Tp8V55X0h9bgUKjAWgACtA==$0";
- A
- ----------
- 99999
- SQL> purge user_recyclebin ;
- Recyclebin purged.
- SQL> show recyclebin;
- SQL> create table t05311_g( a number ) ;
- Table created.
- SQL> insert into t05311_g values ( 1 ) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> show recyclebin;
- SQL> drop table t05311_g;
- Table dropped.
- SQL> show recyclebin
- ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
- ---------------- ------------------------------ ------------ -------------------
- T05311_G BIN$Tp8V55X1h9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:15:42
- SQL> show recyclebin
- ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
- ---------------- ------------------------------ ------------ -------------------
- T05311_G BIN$Tp8V55X1h9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:15:42
- SQL> create table T05311_h ( a number ) ;
- Table created.
- SQL> insert into T05311_h values ( 1 ) ;
- 1 row created.
- SQL> drop table T05311_h;
- Table dropped.
- SQL> create table T05311_h ( a date ) ;
- Table created.
- SQL> insert into T05311_h values ( sysdate ) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> drop table T05311_h;
- Table dropped.
- SQL> create table T05311_h ( a varchar2(20)) ;
- Table created.
- SQL> insert into T05311_h values ( 'A');
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> drop table T05311_h ;
- Table dropped.
- SQL> show recyclebin
- ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
- ---------------- ------------------------------ ------------ -------------------
- T05311_G BIN$Tp8V55X1h9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:15:42
- T05311_H BIN$Tp8V55X4h9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:20:12
- T05311_H BIN$Tp8V55X3h9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:19:47
- T05311_H BIN$Tp8V55X2h9bgUKjAWgACtA==$0 TABLE 2017-05-03:21:19:23
- SQL> flashback table T05311_H to before drop ;
- Flashback complete.
- SQL> select * from t05311_h;
- A
- --------------------
- A
- SQL> flashback table T05311_H to before drop ;
- flashback table T05311_H to before drop
- *
- ERROR at line 1:
- ORA-38312: original name is used by an existing object
- SQL> flashback table T05311_H to before drop rename to T05311_I;
- Flashback complete.
- SQL> select * from T05311_I;
- A
- ------------------
- 03-MAY-17
- SQL>
复制代码
|
|