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的使用
531 0
springboot-maven项目+jpa 运行过程中执行resources下sql脚本文件-ClassPathResource和ScriptUtils.executeSqlScript的使用
|
1天前
|
SQL 分布式计算 前端开发
MaxCompute操作报错合集之SQL脚本设置参数set odps.mapred.reduce.tasks=18;没有生效,是为什么
MaxCompute是阿里云提供的大规模离线数据处理服务,用于大数据分析、挖掘和报表生成等场景。在使用MaxCompute进行数据处理时,可能会遇到各种操作报错。以下是一些常见的MaxCompute操作报错及其可能的原因与解决措施的合集。
|
1月前
|
SQL Oracle 关系型数据库
Oracle SQL*Plus的SET命令:你的数据库会话“调色板”
【4月更文挑战第19天】Oracle SQL*Plus的SET命令是数据库会话的“调色板”,用于设置输出格式、反馈信息和各种偏好。它能调整PAGESIZE和LINESIZE以优化显示,控制ECHO和FEEDBACK开关以定制反馈,以及统计命令执行时间(TIMING)和调试SQL(VERIFY)。更高级的选项如HEADING和COLSEP可改善输出的可读性。通过灵活运用SET命令,能提升工作效率和体验,是数据库管理员和开发者的必备工具。
|
1月前
|
SQL 关系型数据库 MySQL
使用Navicat导入和导出sql语句
使用Navicat导入和导出sql语句
116 0
Java.sql.SQLException: Illegal operation on empty result set.
Java.sql.SQLException: Illegal operation on empty result set.
160 0
|
SQL 测试技术
MyBatis-13MyBatis动态SQL之【where、set、trim】
MyBatis-13MyBatis动态SQL之【where、set、trim】
60 0
|
SQL 数据库 数据库管理
sql数据定义语句(cascade,set,null,no action的区别)
sql数据定义语句(cascade,set,null,no action的区别)
240 0
|
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
317 0
|
SQL XML Java
Mybatis中$ {} 和 # {}的区别,动态SQL之if、where、set、trim、foreach标签的使用
Mybatis中$ {} 和 # {}的区别,动态SQL之if、where、set、trim、foreach标签的使用
158 0
Mybatis中$ {} 和 # {}的区别,动态SQL之if、where、set、trim、foreach标签的使用