模拟行迁移试验
1、創建scott模式
[oracle@std dbs]$ sqlplus '/as sysdba'SQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 17 14:59:02 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining optionsSQL> select user_id,username from dba_users;USER_ID USERNAME ---------- ------------------------------11 OUTLN0 SYS5 SYSTEM24 DBSNMP21 TSMSYS19 DIP6 rows selected.SQL> @?/rdbms/admin/utlsampl.sql Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options?
2、備份EMP表
[oracle@std dbs]$ sqlplus scott/tigerSQL*Plus: Release 10.2.0.1.0 - Production on Mon Feb 17 15:02:50 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.Error accessing PRODUCT_USER_PROFILE Warning: Product user profile information not loaded! You may need to run PUPBLD.SQL as SYSTEMConnected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining optionsSQL> select * from tab;TNAME TABTYPE CLUSTERID ------------------------------ ------- ---------- DEPT TABLE EMP TABLE BONUS TABLE SALGRADE TABLESQL> select constraint_name,constraint_type,table_name from user_constraints;CONSTRAINT_NAME C TABLE_NAME ------------------------------ - ------------------------------ FK_DEPTNO R EMP PK_DEPT P DEPT PK_EMP P EMPSQL> alter table emp drop constraints pk_emp;Table altered.?
3、分析行連接
SQL> @?/rdbms/admin/utlchain.sqlTable created.SQL> select * from tab;TNAME TABTYPE CLUSTERID ------------------------------ ------- ---------- DEPT TABLE EMP TABLE CHAINED_ROWS TABLE BONUS TABLE SALGRADE TABLE EMP2 TABLE6 rows selected.SQL> analyze table emp list chained rows into chained_rows;Table analyzed.SQL> select count(*) from chained_rows where table_name='EMP';COUNT(*) ----------04、模擬產生行連接
SQL> truncate table emp;Table truncated.SQL> alter table emp pctfree 0;Table altered.SQL> insert into emp select * from emp2;14 rows created.SQL> insert into emp select * from emp;14 rows created.SQL> /28 rows created.SQL> /56 rows created.SQL> /112 rows created.SQL> /224 rows created.SQL> /448 rows created.SQL> /896 rows created.SQL> /1792 rows created.SQL> commit;Commit complete.SQL> desc empName Null? Type----------------------------------------- -------- ----------------------------EMPNO NUMBER(4)ENAME VARCHAR2(10)JOB VARCHAR2(9)MGR NUMBER(4)HIREDATE DATESAL NUMBER(7,2)COMM NUMBER(7,2)DEPTNO NUMBER(2)SQL> update emp set ename='AAAAAAAAAA' where empno=7844;256 rows updated.SQL> commit;Commit complete.SQL> analyze table emp list chained rows into chained_rows;Table analyzed.SQL> select count(*) from chained_rows where table_name='EMP';COUNT(*) ----------305、消除行遷移
SQL> create table emp_old as select * from emp where rowid in2 (select head_rowid from chained_rows3 where table_name='EMP');Table created.SQL> delete from emp where rowid in 2 (select head_rowid from chained_rows3 where table_name='EMP');30 rows deleted.SQL> insert into emp select * from emp_old;30 rows created.SQL> drop table emp_old;Table dropped.SQL> delete from chained_rows where table_name='EMP';30 rows deleted.SQL> commit;Commit complete.SQL> analyze table emp list chained rows into chained_rows;Table analyzed.SQL> select count(*) from chained_rows where table_name='EMP';COUNT(*) ----------0?
轉載于:https://www.cnblogs.com/myrunning/p/3989554.html
總結
- 上一篇: [转]22 个精美的网站管理后台模板推荐
- 下一篇: firebird mysql_Fireb