测试环境是:DB: 11.2.0.3 ,10.2.0.4 OS:RHEL 4.8
把10G中的stored outline数据迁移到11G中
1,导出测试表中的数据
- [oracle10g@rhel4 sql]$ expdp scott/oracle tables=test1 directory=test dumpfile=test1.dmp;
- Export: Release 10.2.0.4.0 - 64bit Production on Saturday, 06 April, 2013 21:14:00
- Copyright (c) 2003, 2007, Oracle. All rights reserved.
- Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- Starting "SCOTT"."SYS_EXPORT_TABLE_01": scott/******** tables=test1 directory=test dumpfile=test1.dmp
- Estimate in progress using BLOCKS method...
- Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
- Total estimation using BLOCKS method: 2.875 GB
- Processing object type TABLE_EXPORT/TABLE/TABLE
- Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
- Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
- Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
- . . exported "SCOTT"."TEST1" 4.636 MB 50091 rows
- Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
- ******************************************************************************
- Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
- /tmp/test1.dmp
- Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 21:14:18
2,导出stored outline,name为new_outline_1
- [oracle10g@rhel4 tmp]$ expdp outln/oracle directory=test TABLES=(OL\$,OL\$HINTS,OL\$NODES) dumpfile=outln.dmp parfile=query.par
- Export: Release 10.2.0.4.0 - 64bit Production on Saturday, 06 April, 2013 21:46:18
- Copyright (c) 2003, 2007, Oracle. All rights reserved.
- Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- Starting "OUTLN"."SYS_EXPORT_TABLE_02": outln/******** directory=test TABLES=(OL$,OL$HINTS,OL$NODES) dumpfile=outln.dmp parfile=query.par
- Estimate in progress using BLOCKS method...
- Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
- Total estimation using BLOCKS method: 640 KB
- Processing object type TABLE_EXPORT/TABLE/TABLE
- Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
- Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
- Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
- Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
- Processing object type TABLE_EXPORT/TABLE/POST_TABLE_ACTION
- . . exported "OUTLN"."OL$HINTS" 11.59 KB 5 rows
- . . exported "OUTLN"."OL$" 9.070 KB 1 rows
- . . exported "OUTLN"."OL$NODES" 7.078 KB 1 rows
- Master table "OUTLN"."SYS_EXPORT_TABLE_02" successfully loaded/unloaded
- ******************************************************************************
- Dump file set for OUTLN.SYS_EXPORT_TABLE_02 is:
- /tmp/outln.dmp
- Job "OUTLN"."SYS_EXPORT_TABLE_02" successfully completed at 21:46:23
- [oracle10g@rhel4 tmp]$ cat query.par
- query=ol$:"where ol_name=upper('new_outline_1')",OL$HINTS:"where ol_name=upper('new_outline_1')",OL$NODES:"where ol_name=upper('new_outline_1')"
- [oracle10g@rhel4 tmp]$
3,把测试数据导入到11G SCOTT用户下面
- [oracle11g@rhel4 sql]$ impdp scott/oracle directory=dump dumpfile=test1.dmp TABLE_EXISTS_ACTION=append logfile=imdp.log
- Import: Release 11.2.0.3.0 - Production on Sat Apr 6 21:51:08 2013
- Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
- Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- Master table "SCOTT"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
- Starting "SCOTT"."SYS_IMPORT_FULL_01": scott/******** directory=dump dumpfile=test1.dmp TABLE_EXISTS_ACTION=append logfile=imdp.log
- Processing object type TABLE_EXPORT/TABLE/TABLE
- Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
- . . imported "SCOTT"."TEST1" 4.636 MB 50091 rows
- Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
- Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
- Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
- Job "SCOTT"."SYS_IMPORT_FULL_01" successfully completed at 21:51:12
4,把stored outline数据导入到11G OUTLN用户中
- [oracle11g@rhel4 sql]$ impdp outln/oracle directory=dump dumpfile=outln.dmp TABLE_EXISTS_ACTION=append
- Import: Release 11.2.0.3.0 - Production on Sat Apr 6 21:51:52 2013
- Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
- Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- Master table "OUTLN"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
- Starting "OUTLN"."SYS_IMPORT_FULL_01": outln/******** directory=dump dumpfile=outln.dmp TABLE_EXISTS_ACTION=append
- Processing object type TABLE_EXPORT/TABLE/TABLE
- Table "OUTLN"."OL$" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append
- Table "OUTLN"."OL$NODES" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append
- Table "OUTLN"."OL$HINTS" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append
- Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
- . . imported "OUTLN"."OL$HINTS" 11.59 KB 5 rows
- . . imported "OUTLN"."OL$" 9.070 KB 1 rows
- . . imported "OUTLN"."OL$NODES" 7.078 KB 1 rows
- Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
- Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
- Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
- Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
- Processing object type TABLE_EXPORT/TABLE/POST_TABLE_ACTION
- Job "OUTLN"."SYS_IMPORT_FULL_01" successfully completed at 21:52:00
- 查看是否已经生成new_outline_1
- SQL> @sql_outline
- Wrote file sqlplusset
- CATEGORY
- ---------------
- DEFAULT
- Enter value for owner: scott
- Enter value for category: default
- Enter value for used:
- CREATE
- NAME OWNER CATEGORY USED TIME COMPATIBLE ENABLED FORMAT SQL_TEXT
- ----------------------------- --------------- --------------- ------ -------- ------------ -------- ------ ----------------------------------------------------------------------
- NEW_OUTLINE_1 SCOTT DEFAULT USED 13 04-06 COMPATIBLE ENABLED NORMAL select /*+ full(t)*/ count(*) from test1 t where object_id=1
5,测试是否生产
- 修改参数
- SQL> ALTER SYSTEM SET USE_STORED_OUTLINES = TRUE;
- System altered.
- SQL> conn scott/oracle
- Connected.
- SQL> set autotrace traceonly;
- 测试是否生效
- SQL> select /*+ full(t)*/ count(*) from test1 t where object_id=1;
- Execution Plan
- ----------------------------------------------------------
- Plan hash value: 4017242292
- ------------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- ------------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 1 | 3 | 1 (0)| 00:00:01 |
- | 1 | SORT AGGREGATE | | 1 | 3 | | |
- |* 2 | INDEX RANGE SCAN| TEST1_ID | 1 | 3 | 1 (0)| 00:00:01 |
- ------------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- 2 - access("OBJECT_ID"=1)
- Note
- -----
- - outline "NEW_OUTLINE_1" used for this statement
- Statistics
- ----------------------------------------------------------
- 222 recursive calls
- 130 db block gets
- 199 consistent gets
- 2 physical reads
- 116 redo size
- 526 bytes sent via SQL*Net to client
- 520 bytes received via SQL*Net from client
- 2 SQL*Net roundtrips to/from client
- 27 sorts (memory)
- 0 sorts (disk)
- 1 rows processed
- 已经成功