当我们升级数据库的时候,老的数据库做的SQL profile优化 需要迁移到新的是数据库中,保证执行计划稳定,系统稳定,迁移脚本如下:
--1.创建表stage 属于用户sgpm
begin
DBMS_SQLTUNE.CREATE_STGTAB_SQLPROF(table_name => 'STAGE',
schema_name => 'SGPM');
end;
--2.吧dba_sql_profiles数据导入到表stage中
begin
for i in (select t.NAME from dba_sql_profiles t) loop
DBMS_SQLTUNE.PACK_STGTAB_SQLPROF(staging_table_name => 'STAGE',
profile_name => i.name);
end loop;
end;
--3.使用 exp导出
exp sgpm/xxx tables=STAGE log=stage.log
--4.使用imp导入
imp sgpm/xxx tables=STAGE log=stage.log ignore=y
--5.吧stage中的数据导入到dba_sql_profiles
begin
DBMS_SQLTUNE.UNPACK_STGTAB_SQLPROF(replace => TRUE,
staging_table_name => 'STAGE');
end;
--6.验证 SQL PROFILE 生效
explain plan for sql;
select * from table(dbms_xplan.display());
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31134212/viewspace-2086610/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31134212/viewspace-2086610/