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

简介: STS导入或导出错误处理 环境模拟: create directory d1 as '/home/oracle/scripts'; grant read,write on  director...

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

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 tableSTS_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;



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

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


APPLIES TO:

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*** 

GOAL

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.

SOLUTION

Actions to Perform the Transfer:

  1. Create/load STS test_set owned by SYS
  2. Create stgtab SQLSET_TAB
  3. Pack test_set into the stgtab
  4. Export/import into test system, conn as scott
  5. Attempt to unpack an STS named 'testtarget_test_set'

Preliminary Setup:

  • Create User,  Create and Populate the table and collect statistics



     
     

     
     
     

     
     
     
     
     


     

    >
  • >< 

     
     
     



     
     
     



     
     


  1.  

    >> 

     
     
     
     
     
    <>>
              

    >> 
     



  2.  



     

  3.  




     
  4.  

     
  5. >



  6.  





     

     

     
     
     
     
     
     
     

  7.  


    >> 
    >> 
    >

    >>>>>>
  8.  





     






  9. >
    >
    >
    >


     








  • >>




  






&

          

img_e3029f287d989cd04bd75432ecc1c172.png
DBA笔试面试讲解群
《DBA宝典》读者群 欢迎与我联系



目录
相关文章
|
SQL Java 数据库连接
springboot-maven项目+jpa 运行过程中执行resources下sql脚本文件-ClassPathResource和ScriptUtils.executeSqlScript的使用
springboot-maven项目+jpa 运行过程中执行resources下sql脚本文件-ClassPathResource和ScriptUtils.executeSqlScript的使用
485 0
springboot-maven项目+jpa 运行过程中执行resources下sql脚本文件-ClassPathResource和ScriptUtils.executeSqlScript的使用
|
10月前
Java.sql.SQLException: Illegal operation on empty result set.
Java.sql.SQLException: Illegal operation on empty result set.
109 0
|
11月前
|
SQL 测试技术
MyBatis-13MyBatis动态SQL之【where、set、trim】
MyBatis-13MyBatis动态SQL之【where、set、trim】
57 0
|
11月前
|
SQL 数据库 数据库管理
sql数据定义语句(cascade,set,null,no action的区别)
sql数据定义语句(cascade,set,null,no action的区别)
221 0
|
11月前
|
Java 关系型数据库 MySQL
java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@27ce24aa is still active
java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@27ce24aa is still active
297 0
|
SQL XML Java
Mybatis中$ {} 和 # {}的区别,动态SQL之if、where、set、trim、foreach标签的使用
Mybatis中$ {} 和 # {}的区别,动态SQL之if、where、set、trim、foreach标签的使用
148 0
Mybatis中$ {} 和 # {}的区别,动态SQL之if、where、set、trim、foreach标签的使用
|
SQL 存储 关系型数据库
Navicat for MySQL资源分享和下载以及SQL文件的导入导出
Navicat for MySQL资源分享和下载以及SQL文件的导入导出
443 0
Navicat for MySQL资源分享和下载以及SQL文件的导入导出
|
SQL 存储 自然语言处理
MySql基础-笔记12 -重复数据处理、SQL注入、导入导出数据
MySql基础-笔记12 -重复数据处理、SQL注入、导入导出数据
122 0
MySql基础-笔记12 -重复数据处理、SQL注入、导入导出数据
|
SQL 存储 Oracle
数据库小技能:PL/SQL(Procedure Language/SQL,过程化SQL语言)预备知识
过程化SQL语言(Procedural Language/SQL)是Oracle数据库对SQL语句的扩展:在普通SQL语句的使用上增加了编程语言的特点,把数据操作和查询语句组织在PL/SQL代码的过程性单元中,通过逻辑判断、循环等操作实现复杂的功能或者计算的程序语言。
228 1