环境模拟:
create directory d1 as '/home/oracle/scripts';
grant read,write on directory d1 to public;
create user apps identified by Apps1234;
grant dba ,ADMINISTER ANY SQL TUNING SET to apps;
conn apps/Apps1234
create table apps.ta_lhr as select * from dba_objects;
create table apps.tb_lhr as select * from dba_objects;
select * from apps.ta_lhr where object_id=100;
select * from apps.tb_lhr where object_name='TA_LHR';
使用EM创建system用户的PS_STS的调优集,然后导出使用system进行导出,否则报错:
Tue Nov 28 09:43:53 2017
Errors in file /u01/app/oracle/diag/rdbms/prod1/PROD1/trace/PROD1_j001_10289.trc:
ORA-12012: error on auto execute of job 78165
ORA-19381: cannot create staging table in SYS schema
ORA-06512: at "SYS.DBMS_SQLTUNE", line 3170
ORA-06512: at "SYS.DBMS_SQLTUNE", line 6397
ORA-06512: at line 1
MOS解释:
Error ORA-19381 When DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF IS EXECUTED as SYS (文档 ID 2131916.1)
This is expected behavior. STS staging tables cannot be created in SYS schema by design.
Any other user (with the right privileges) should be able to create the staging table and pack STS in it.
导入如果报错:
Errors in file
/u01/app/oracle/diag/rdbms/prod1/PROD1/trace/PROD1_j000_20653.trc:
ORA-12012: error on auto execute of job 78166
ORA-19377: no "SQL Tuning Set" with name like "%" exists for owner like "SYS"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.DBMS_SQLTUNE", line 6868
ORA-06512: at line 1
Errors in file /u01/app/oracle/diag/rdbms/prod1/PROD1/trace/PROD1_j000_9955.trc:
ORA-12012: error on auto execute of job 78689
ORA-00942: table or view does not exist
ORA-06512: at line 1
解决: 使用SYSTEM进行导入,或执行以下SQL后再导入:
impdp system/oracle directory=d1 dumpfile=appsstg.dmp
exec dbms_sqltune.remap_stgtab_sqlset(old_sqlset_name =>'STS_PS',old_sqlset_owner => 'SYSTEM', new_sqlset_name => 'STS_PS',new_sqlset_owner => 'SYS', staging_table_name => 'STS_PS_STGTAB',staging_schema_owner => 'SYSTEM');
----删除STS,staging table为STS_PS_STGTAB
SELECT * FROM Dba_Objects d WHERE d.object_name='STS_PS_STGTAB';
SELECT * FROM Dba_Sqlset;
SELECT *
FROM dba_sqlset_statements
WHERE sqlset_name = 'STS_PS';
DELETE FROM WRI$_SQLSET_DEFINITIONS;
DELETE FROM WRI$_SQLSET_STATEMENTS;
DELETE FROM WRI$_SQLSET_MASK;
DELETE FROM WRI$_SQLSET_STATISTICS;
COMMIT;
SELECT * FROM WRI$_SQLSET_STATEMENTS;
SELECT * FROM WRI$_SQLSET_MASK;
SELECT * FROM WRI$_SQLSET_STATISTICS;
SELECT * FROM WRI$_SQLSET_STATEMENTS;
In this Document
Goal |
Solution |
Actions to Perform the Transfer: |
Preliminary Setup: |
Actions to Perform the Transfer: Detail |
Create/load STS test_set owned by SYS |
Create stgtab sqlset_tab table in TEST schema: |
Pack test_set into the stgtab |
Transfer the table containing the SQL SET (SQLSET_TAB) table to the TEST system |
Export/import into test system, connect as scott |
Attempt to unpack an STS named 'testtarget_test_set' |
MAPPING |
UNPACK THE SQLSET_TAB TABLE IN THE TEST SYSTEM |
References |
This document explains how to transfer the SQL Tuning Set (STS) from one database to another and demonstrates some issues regarding the transfer of STS and their resolution.
If you are trying to rename the STS and change its owner before it is unpacked (reconstituted on the test system), use the remap_stgtab_sqlset API as follows, for example:
Here the staging table is imported to TEST schema of TEST system:
Now the SQL Tuning Set is transferred successfully to another database without any issues.
In this Document
Symptoms |
Cause |
Solution |
References |
This is expected behavior. STS staging tables cannot be created in SYS schema by design.
Any other user (with the right privileges) should be able to create the staging table and pack STS in it.
About Me
.............................................................................................................................................
● 本文作者:小麦苗,部分内容整理自网络,若有侵权请联系小麦苗删除
● 本文在itpub(http://blog.itpub.net/26736162/abstract/1/)、博客园(http://www.cnblogs.com/lhrbest)和个人微信公众号(xiaomaimiaolhr)上有同步更新
● 本文itpub地址:http://blog.itpub.net/26736162/abstract/1/
● 本文博客园地址:http://www.cnblogs.com/lhrbest
● 本文pdf版、个人简介及小麦苗云盘地址:http://blog.itpub.net/26736162/viewspace-1624453/
● 数据库笔试面试题库及解答:http://blog.itpub.net/26736162/viewspace-2134706/
● DBA宝典今日头条号地址:http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826
.............................................................................................................................................
● QQ群号:230161599(满)、618766405
● 微信群:可加我微信,我拉大家进群,非诚勿扰
● 联系我请加QQ好友(646634621),注明添加缘由
● 于 2017-11-01 09:00 ~ 2017-11-30 22:00 在魔都完成
● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解
● 版权所有,欢迎分享本文,转载请保留出处
.............................................................................................................................................
● 小麦苗的微店:https://weidian.com/s/793741433?wfr=c&ifr=shopdetail
● 小麦苗出版的数据库类丛书:http://blog.itpub.net/26736162/viewspace-2142121/
.............................................................................................................................................
使用微信客户端扫描下面的二维码来关注小麦苗的微信公众号(xiaomaimiaolhr)及QQ群(DBA宝典),学习最实用的数据库技术。
小麦苗的微信公众号 小麦苗的DBA宝典QQ群2 《DBA笔试面宝典》读者群 小麦苗的微店
.............................................................................................................................................
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26736162/viewspace-2147891/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26736162/viewspace-2147891/