天天看点

STS(SQL Tuning Set)导入导出过程及错误处理 STS导入或导出错误处理

环境模拟:

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解释:

<b>Error ORA-19381 When DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF IS EXECUTED as SYS (文档 ID 2131916.1)</b><b></b>

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

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

解决: 使用SYSTEM进行导入,或执行以下SQL后再导入:

impdp system/oracle directory=d1 dumpfile=appsstg.dmp

exec dbms_sqltune.remap_stgtab_sqlset(old_sqlset_name =&gt;'STS_PS',old_sqlset_owner =&gt; 'SYSTEM', new_sqlset_name =&gt; 'STS_PS',new_sqlset_owner =&gt; 'SYS', staging_table_name =&gt; 'STS_PS_STGTAB',staging_schema_owner =&gt; 'SYSTEM');

----删除STS,staging table为STS_PS_STGTAB

SELECT <b>*</b> FROM Dba_Objects d WHERE d.object_name<b>=</b>'STS_PS_STGTAB'<b>;</b><b></b>

<b></b>

SELECT <b>*</b> FROM Dba_Sqlset<b>;</b>

SELECT <b>*</b>

FROM dba_sqlset_statements  

WHERE sqlset_name <b>=</b> 'STS_PS'<b>;</b><b></b>

DELETE FROM WRI$_SQLSET_DEFINITIONS<b>;</b>

DELETE FROM WRI$_SQLSET_STATEMENTS<b>;</b>

DELETE FROM WRI$_SQLSET_MASK<b>;</b>

DELETE FROM WRI$_SQLSET_STATISTICS<b>;</b>

COMMIT;

 SELECT <b>*</b> FROM WRI$_SQLSET_STATEMENTS<b>;</b>

 SELECT <b>*</b> FROM WRI$_SQLSET_MASK<b>;</b>

 SELECT <b>*</b> FROM WRI$_SQLSET_STATISTICS<b>;</b>

How to Move a SQL Tuning Set from One Database to Another (文档 ID 751068.1)

<b>In this Document</b>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#GOAL">Goal</a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#FIX">Solution</a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#aref_section21">Actions to Perform the Transfer:</a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#aref_section22">Preliminary Setup:</a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#aref_section23">Actions to Perform the Transfer: Detail</a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#aref_section24">Create/load STS test_set owned by SYS</a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#aref_section25">Create stgtab sqlset_tab table in TEST schema:</a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#aref_section26">Pack test_set into the stgtab</a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#aref_section27">Transfer the table containing the SQL SET (SQLSET_TAB) table to the TEST system</a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#aref_section28">Export/import into test system, connect as scott</a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#aref_section29">Attempt to unpack an STS named 'testtarget_test_set'</a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#aref_section210">MAPPING</a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#aref_section211">UNPACK THE SQLSET_TAB TABLE IN THE TEST SYSTEM</a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282017287833625&amp;id=751068.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_4#REF">References</a>

Oracle Database - Enterprise Edition - Version 10.2.0.1 and later

Information in this document applies to any platform.

***Checked for relevance on 26-MAR-2013*** 

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.

<a></a>

Create/load STS test_set owned by SYS

Create stgtab SQLSET_TAB

Pack test_set into the stgtab

Export/import into test system, conn as scott

Attempt to unpack an STS named 'testtarget_test_set'

Create User,  Create and Populate the table and collect statistics

&gt; 

&lt; 

&gt;

&gt;&lt; 

&gt;&gt; 

&lt;&gt;&gt;

&gt;&gt;&gt;&gt;&gt;&gt;

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282124770169378&amp;id=2131916.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_58#SYMPTOM"></a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282124770169378&amp;id=2131916.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_58#CAUSE"></a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282124770169378&amp;id=2131916.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_58#FIX"></a>

<a href="https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=282124770169378&amp;id=2131916.1&amp;_afrWindowMode=0&amp;_adf.ctrl-state=1cdjyghok0_58#REF"></a>

&gt;&gt;

<a href="http://blog.itpub.net/26736162/abstract/1/" target="_blank"></a> <a href="http://www.cnblogs.com/lhrbest" target="_blank"></a> <a href="http://blog.itpub.net/26736162/viewspace-1624453/" target="_blank"></a> <a href="http://blog.itpub.net/26736162/viewspace-2134706/" target="_blank"></a> <a href="http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826" target="_blank"></a> <a href="https://weidian.com/s/793741433?wfr=c&amp;ifr=shopdetail%20" target="_blank">&amp;</a> <a href="http://blog.itpub.net/26736162/viewspace-2142121/" target="_blank"></a> <a href="http://mp.weixin.qq.com/s?__biz=MzIzOTA2NjEzNQ==&amp;mid=307287619&amp;idx=1&amp;sn=9149fab6ae1aecfd1288316c5edc3805&amp;scene=19#wechat_redirect" target="_blank"></a>
STS(SQL Tuning Set)导入导出过程及错误处理 STS导入或导出错误处理
STS(SQL Tuning Set)导入导出过程及错误处理 STS导入或导出错误处理
STS(SQL Tuning Set)导入导出过程及错误处理 STS导入或导出错误处理
STS(SQL Tuning Set)导入导出过程及错误处理 STS导入或导出错误处理
<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&amp;uin=646634621&amp;site=qq&amp;menu=yes"></a>
STS(SQL Tuning Set)导入导出过程及错误处理 STS导入或导出错误处理
STS(SQL Tuning Set)导入导出过程及错误处理 STS导入或导出错误处理
STS(SQL Tuning Set)导入导出过程及错误处理 STS导入或导出错误处理
STS(SQL Tuning Set)导入导出过程及错误处理 STS导入或导出错误处理