前提:sql profile工具的相关视图
dba_sql_profile
10g: sys.sqlprof$attr  &  sqlprof$
11g: sys.sqlobj$data  &  sys.sqlobj$

1、主要完毕四个演示样例,例如以下
  • 使用dbms_sqltune.import_sql_profile过程手工指定提示的方式,这样的方式要求很高(查询块名等),一般不会使用
  • 使用create_sql_profile.sql脚本固定内存中已经有的SQL的运行计划,通过指定sql_id
  • 使用create_sql_profile_awr脚本来还原AWR里面保存的SQL语句的运行计划(临时没环境測试)...
  • 将提示集手工移入到另外一条SQL语句的sql profile中(通过move_sql_profile.sql脚本实现);


演示样例:
一、使用dbms_sqltune.import_sql_profile过程手工指定提示的方式,这样的方式要求很高(查询块名等),一般不会使用
[oracle@192oracle ~]$ sqlplus dbmon/dbmon_123
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 11 16:37:06 2014
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
SQL> create table dh_sql as select rownum id,object_name name ,object_type type from dba_objects;
Table created.
SQL> create index ind_dh_sql on dh_sql(id);
Index created.

SQL> exec DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>'dbmon',TABNAME=>'dh_sql',ESTIMATE_PERCENT=>30,METHOD_OPT=>'FOR ALL COLUMNS SIZE 1',NO_INVALIDATE=>FALSE,CASCADE=>TRUE,DEGREE => 1); 
PL/SQL procedure successfully completed.

SQL> set linesize 200 pagesize 9999
SQL> select /* test1 */ id,name from dh_sql where id=771;

        ID NAME
---------- --------------------------------------------------------------------------------------------------------------------------------
       771 RULESET$

SQL> @sql_profiles.sql               --该脚本查看当前使用sql profile的语句
Enter value for sql_text: 
old   3: where sql_text like nvl('&sql_text','%')
new   3: where sql_text like nvl('','%')
Enter value for name: 
old   4: and name like nvl('&name',name)
new   4: and name like nvl('',name)
no rows selected

SQL> col name format a30 
SQL> col type format a30
SQL> col sql_text format a40
SQL> select sql_text,sql_id,hash_value,child_number from v$sql a where sql_text like '%test1%' and sql_text not like '%v$sql%';
SQL_TEXT                                 SQL_ID        HASH_VALUE CHILD_NUMBER
---------------------------------------- ------------- ---------- ------------
select /* test1 */ id,name from dh_sql w 90nh2m7a3gsvf 3560432494            0

SQL> select * from table(dbms_xplan.display_cursor('90nh2m7a3gsvf','',''));

PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------
SQL_ID  90nh2m7a3gsvf, child number 0
-------------------------------------
select /* test1 */ id,name from dh_sql where id=:"SYS_B_0"
Plan hash value: 1731829956
------------------------------------------------------------------------------------------
| Id  | Operation                   | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |            |       |       |     2 (100)|          |
|   1 |  TABLE ACCESS BY INDEX ROWID| DH_SQL     |     1 |    30 |     2   (0)| 00:00:09 |
|*  2 |   INDEX RANGE SCAN          | IND_DH_SQL |     1 |       |     1   (0)| 00:00:05 |
------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   2 - access("ID"=:SYS_B_0)
19 rows selected.

SQL> @create_1_hint_sql_profile.sql
Enter value for sql_id: 90nh2m7a3gsvf
Enter value for profile_name (PROFILE_sqlid_MANUAL): 
Enter value for category (DEFAULT): 
Enter value for force_matching (false): true
old  16: sql_id = '&&sql_id';
new  16: sql_id = '90nh2m7a3gsvf';
old  18: select decode('&&profile_name','X0X0X0X0','PROFILE_'||'&&sql_id'||'_MANUAL','&&profile_name')
new  18: select decode('X0X0X0X0','X0X0X0X0','PROFILE_'||'90nh2m7a3gsvf'||'_MANUAL','X0X0X0X0')
Enter value for hint: FULL(DH_SQL@SEL$1)           --手工输入指定提示
old  24: profile => sqlprof_attr('&hint'),
new  24: profile => sqlprof_attr('FULL(DH_SQL@SEL$1)'),
old  25: category => '&&category',
new  25: category => 'DEFAULT',
old  31: force_match => &&force_matching
new  31: force_match => true
PL/SQL procedure successfully completed.

SQL> select /* test1 */ id,name from dh_sql where id=771;                  
        ID NAME
---------- ------------------------------
       771 RULESET$
SQL> select * from table(dbms_xplan.display_cursor('90nh2m7a3gsvf','',''));

PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------
SQL_ID  90nh2m7a3gsvf, child number 0
-------------------------------------
select /* test1 */ id,name from dh_sql where id=:"SYS_B_0"
Plan hash value: 1575588977
----------------------------------------------------------------------------
| Id  | Operation         | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |        |       |       |   112 (100)|          |
|*  1 |  TABLE ACCESS FULL| DH_SQL |     1 |    30 |   112   (0)| 00:07:50 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter("ID"=:SYS_B_0)
Note
-----
   - SQL profile PROFILE_90nh2m7a3gsvf_MANUAL used for this statement
22 rows selected.

SQL> @sql_profiles.sql   --能够看到确实已经使用!
Enter value for sql_text: 
old   3: where sql_text like nvl('&sql_text','%')
new   3: where sql_text like nvl('','%')
Enter value for name: 
old   4: and name like nvl('&name',name)
new   4: and name like nvl('',name)
NAME                           CATEGORY        STATUS   SQL_TEXT                                                               FOR
------------------------------ --------------- -------- ---------------------------------------------------------------------
PROFILE_90nh2m7a3gsvf_MANUAL   DEFAULT         ENABLED  select /* test1 */ id,name from dh_sql where id=:"SYS_B_0"             YES


SQL> conn /as sysdba
Connected.
SQL> set serveroutput on size 9999
SQL> @profile_hint.sql
Enter value for profile_name: PROFILE_90nh2m7a3gsvf_MANUAL
old  19:    'and name like (''&&profile_name'') '||
new  19:    'and name like (''PROFILE_90nh2m7a3gsvf_MANUAL'') '||
old  38:    'and p.name like (''&&profile_name'')) '||
new  38:    'and p.name like (''PROFILE_90nh2m7a3gsvf_MANUAL'')) '||
HINT
-----------------------------------------------------------------------------------------------------------------------------
FULL(DH_SQL@SEL$1)               --能够看到sql profile的基表里面保存了我们指定的提示





二、使用create_sql_profile.sql脚本固定内存中已经有的SQL的运行计划。通过指定sql_id
SQL> conn dbmon/dbmon_123 
Connected.
SQL> select * from dh_sql where name='DBA_TABLES';
        ID NAME                           TYPE
---------- ------------------------------ ------------------------------
      3167 DBA_TABLES                     VIEW
      3168 DBA_TABLES                     SYNONYM
2 rows selected.
SQL> select /* test2 */ * from dh_sql where name='DBA_TABLES';
        ID NAME                           TYPE
---------- ------------------------------ ------------------------------
      3167 DBA_TABLES                     VIEW
      3168 DBA_TABLES                     SYNONYM
2 rows selected.
SQL> select sql_text,sql_id,hash_value,child_number from v$sql a where sql_text like '%test2%' and sql_text not like '%v$sql%';
SQL_TEXT                                                               SQL_ID        HASH_VALUE CHILD_NUMBER
---------------------------------------------------------------------- ------------- ---------- ------------
select /* test2 */ * from dh_sql where name=:"SYS_B_0"                 0xy0uj562r893 1277927715            0
1 row selected.
SQL> select * from table(dbms_xplan.display_cursor('0xy0uj562r893','',''));
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------
SQL_ID  0xy0uj562r893, child number 0
-------------------------------------
select /* test2 */ * from dh_sql where name=:"SYS_B_0"
Plan hash value: 1575588977
----------------------------------------------------------------------------
| Id  | Operation         | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |        |       |       |   112 (100)|          |
|*  1 |  TABLE ACCESS FULL| DH_SQL |     2 |    76 |   112   (0)| 00:07:50 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter("NAME"=:SYS_B_0)
18 rows selected.

SQL> @create_sql_profile.sql    --使用这个脚本固定内存中指定SQL_ID的运行计划
Enter value for sql_id: 0xy0uj562r893
Enter value for child_no (0): 
Enter value for profile_name (PROF_sqlid_planhash): 
Enter value for category (DEFAULT): 
Enter value for force_matching (FALSE): TRUE
old  19: sql_id = '&&sql_id'
new  19: sql_id = '0xy0uj562r893'
old  20: and child_number = &&child_no
new  20: and child_number = 0
old  27: decode('&&profile_name','X0X0X0X0','PROF_&&sql_id'||'_'||plan_hash_value,'&&profile_name')
new  27: decode('X0X0X0X0','X0X0X0X0','PROF_0xy0uj562r893'||'_'||plan_hash_value,'X0X0X0X0')
old  33: sql_id = '&&sql_id'
new  33: sql_id = '0xy0uj562r893'
old  34: and child_number = &&child_no;
new  34: and child_number = 0;
old  39: category => '&&category',
new  39: category => 'DEFAULT',
old  41: force_match => &&force_matching
new  41: force_match => TRUE
old  52:   dbms_output.put_line('ERROR: sql_id: '||'&&sql_id'||' Child: '||'&&child_no'||' not found in v$sql.');
new  52:   dbms_output.put_line('ERROR: sql_id: '||'0xy0uj562r893'||' Child: '||'0'||' not found in v$sql.');
SQL> 
SQL> select /* test2 */ * from dh_sql where name='DBA_TABLES';

        ID NAME                           TYPE
---------- ------------------------------ ------------------------------
      3167 DBA_TABLES                     VIEW
      3168 DBA_TABLES                     SYNONYM
2 rows selected.
SQL> select * from table(dbms_xplan.display_cursor('0xy0uj562r893','',''));
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------
SQL_ID  0xy0uj562r893, child number 0
-------------------------------------
select /* test2 */ * from dh_sql where name=:"SYS_B_0"
Plan hash value: 1575588977
----------------------------------------------------------------------------
| Id  | Operation         | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |        |       |       |   112 (100)|          |
|*  1 |  TABLE ACCESS FULL| DH_SQL |     2 |    76 |   112   (0)| 00:07:50 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter("NAME"=:SYS_B_0)
Note
-----
   - SQL profile PROF_0xy0uj562r893_1575588977 used for this statement   --能够看到sql profile确实已经生效
22 rows selected.
--新建一个索引。确认已经固定运行计划的语句不会由于訪问路径而改变运行计划
SQL> create index ind_dh_sql2 on dh_sql(name) compute statistics;   
Index created.
SQL> select /* test2 */ * from dh_sql a where name='DBA_TABLES';
        ID NAME                           TYPE
---------- ------------------------------ ------------------------------
      3167 DBA_TABLES                     VIEW
      3168 DBA_TABLES                     SYNONYM
2 rows selected.
SQL> select sql_text,sql_id,hash_value,child_number from v$sql a where sql_text like '%test2%' and sql_text not like '%v$sql%';
SQL_TEXT                                                               SQL_ID        HASH_VALUE CHILD_NUMBER
---------------------------------------------------------------------- ------------- ---------- ------------
select /* test2 */ * from dh_sql a where name=:"SYS_B_0"               bp7gpwq6w88nv 2378441371            0
select /* test2 */ * from dh_sql where name=:"SYS_B_0"                 0xy0uj562r893 1277927715            0
2 rows selected.
SQL> select * from table(dbms_xplan.display_cursor('bp7gpwq6w88nv','',''));
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------
SQL_ID  bp7gpwq6w88nv, child number 0
-------------------------------------
select /* test2 */ * from dh_sql a where name=:"SYS_B_0"
Plan hash value: 3828038811
-------------------------------------------------------------------------------------------
| Id  | Operation                   | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |             |       |       |     4 (100)|          |
|   1 |  TABLE ACCESS BY INDEX ROWID| DH_SQL      |     2 |    76 |     4   (0)| 00:00:17 |
|*  2 |   INDEX RANGE SCAN          | IND_DH_SQL2 |     2 |       |     3   (0)| 00:00:13 |  --没有固定的语句使用索引计划
-------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   2 - access("NAME"=:SYS_B_0)
19 rows selected.

SQL> select /* test2 */ * from dh_sql where name='DBA_TABLES';

        ID NAME                           TYPE
---------- ------------------------------ ------------------------------
      3167 DBA_TABLES                     VIEW
      3168 DBA_TABLES                     SYNONYM
2 rows selected.
SQL> select * from table(dbms_xplan.display_cursor('0xy0uj562r893','',''));
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------
SQL_ID  0xy0uj562r893, child number 0
-------------------------------------
select /* test2 */ * from dh_sql where name=:"SYS_B_0"
Plan hash value: 1575588977
----------------------------------------------------------------------------
| Id  | Operation         | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |        |       |       |   112 (100)|          |
|*  1 |  TABLE ACCESS FULL| DH_SQL |     2 |    76 |   112   (0)| 00:07:50 |   --已经固定的运行计划还是使用全表扫描
----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter("NAME"=:SYS_B_0)
Note
-----
   - SQL profile PROF_0xy0uj562r893_1575588977 used for this statement
22 rows selected.

SQL> conn /as sysdba
Connected.
SQL> set serveroutput on size 99999
SQL> @sql_profile_hints.sql
Enter value for profile_name: PROF_0xy0uj562r893_1575588977
old  19:    'and name like (''&&profile_name'') '||
new  19:    'and name like (''PROF_0xy0uj562r893_1575588977'') '||
old  38:    'and p.name like (''&&profile_name'')) '||
new  38:    'and p.name like (''PROF_0xy0uj562r893_1575588977'')) '||
HINT
-----------------------------------------------------------------------------------------------------------------------------
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('11.2.0.1')
DB_VERSION('11.2.0.1')
OPT_PARAM('_optim_peek_user_binds' 'false')
OPT_PARAM('_optimizer_null_aware_antijoin' 'false')
OPT_PARAM('_bloom_filter_enabled' 'false')
OPT_PARAM('_optimizer_extended_cursor_sharing' 'none')
OPT_PARAM('_gby_hash_aggregation_enabled' 'false')
OPT_PARAM('_bloom_pruning_enabled' 'false')
OPT_PARAM('_optimizer_extended_cursor_sharing_rel' 'none')
OPT_PARAM('_optimizer_adaptive_cursor_sharing' 'false')
OPT_PARAM('_optimizer_use_feedback' 'false')
ALL_ROWS
OUTLINE_LEAF(@"SEL$1")
FULL(@"SEL$1" "DH_SQL"@"SEL$1")
15 rows selected.



三、使用create_sql_profile_awr脚本来还原AWR里面保存的SQL语句的运行计划(临时没环境測试)...

四、将提示集手工移入到另外一条SQL语句的sql profile中(通过move_sql_profile.sql脚本实现);方法例如以下:
1、运行一条与须要固定运行计划的SQL语句结构一致的语句
2、通过各种方法来实现将第一步执行的SQL语句,得到自己预期的执行计划(加入提示,改动參数等等)
3、通过这个语句执行产生的提示集合(v$sql_plan.other_xml列),来为须要固定的SQL语句创建sql profile从而固定执行计划
SQL> select * from table(dbms_xplan.display_cursor('bp7gpwq6w88nv','',''));
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------
SQL_ID  bp7gpwq6w88nv, child number 0
-------------------------------------
select /* test2 */ * from dh_sql a where name=:"SYS_B_0"
Plan hash value: 3828038811
-------------------------------------------------------------------------------------------
| Id  | Operation                   | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |             |       |       |     4 (100)|          |
|   1 |  TABLE ACCESS BY INDEX ROWID| DH_SQL      |     2 |    76 |     4   (0)| 00:00:17 |
|*  2 |   INDEX RANGE SCAN          | IND_DH_SQL2 |     2 |       |     3   (0)| 00:00:13 |  --须要固定的SQL的运行计划
-------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   2 - access("NAME"=:SYS_B_0)
19 rows selected.
SQL> select /* test2 */ /*+ full(a) */ *from dh_sql a where name='DBA_TABLES';

        ID NAME                           TYPE
---------- ------------------------------ ------------------------------
      3167 DBA_TABLES                     VIEW
      3168 DBA_TABLES                     SYNONYM
2 rows selected.
SQL> select sql_text,sql_id,hash_value,child_number from v$sql a where sql_text like '%test2%' and sql_text not like '%v$sql%';
SQL_TEXT                                                               SQL_ID        HASH_VALUE CHILD_NUMBER
---------------------------------------------------------------------- ------------- ---------- ------------
select /* test2 */ * from dh_sql a where name=:"SYS_B_0"               bp7gpwq6w88nv 2378441371            0
select /* test2 */ * from dh_sql where name=:"SYS_B_0"                 0xy0uj562r893 1277927715            0
select /* test2 */ /*+ full(a) */ *from dh_sql a where name=:"SYS_B_0" 6vq4tjw38m8hk  109683218            0
3 rows selected.
SQL> select * from table(dbms_xplan.display_cursor('6vq4tjw38m8hk','',''));
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------
SQL_ID  6vq4tjw38m8hk, child number 0
-------------------------------------
select /* test2 */ /*+ full(a) */ *from dh_sql a where name=:"SYS_B_0"
Plan hash value: 1575588977

----------------------------------------------------------------------------
| Id  | Operation         | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |        |       |       |   112 (100)|          |
|*  1 |  TABLE ACCESS FULL| DH_SQL |     2 |    76 |   112   (0)| 00:07:50 |   --我们指定的预期运行计划
----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter("NAME"=:SYS_B_0)
18 rows selected.

SQL> @create_sql_profile.sql     ---为这个预期的SQL运行计划创建sql profile
Enter value for sql_id: 6vq4tjw38m8hk
Enter value for child_no (0): 
Enter value for profile_name (PROF_sqlid_planhash): 
Enter value for category (DEFAULT): 
Enter value for force_matching (FALSE): TRUE
old  19: sql_id = '&&sql_id'
new  19: sql_id = '6vq4tjw38m8hk'
old  20: and child_number = &&child_no
new  20: and child_number = 0
old  27: decode('&&profile_name','X0X0X0X0','PROF_&&sql_id'||'_'||plan_hash_value,'&&profile_name')
new  27: decode('X0X0X0X0','X0X0X0X0','PROF_6vq4tjw38m8hk'||'_'||plan_hash_value,'X0X0X0X0')
old  33: sql_id = '&&sql_id'
new  33: sql_id = '6vq4tjw38m8hk'
old  34: and child_number = &&child_no;
new  34: and child_number = 0;
old  39: category => '&&category',
new  39: category => 'DEFAULT',
old  41: force_match => &&force_matching
new  41: force_match => TRUE
old  52:   dbms_output.put_line('ERROR: sql_id: '||'&&sql_id'||' Child: '||'&&child_no'||' not found in v$sql.');
new  52:   dbms_output.put_line('ERROR: sql_id: '||'6vq4tjw38m8hk'||' Child: '||'0'||' not found in v$sql.');
SQL> select /* test2 */ /*+ full(a) */ *from dh_sql a where name='DBA_TABLES';
        ID NAME                           TYPE
---------- ------------------------------ ------------------------------
      3167 DBA_TABLES                     VIEW
      3168 DBA_TABLES                     SYNONYM
2 rows selected.
SQL> select * from table(dbms_xplan.display_cursor('6vq4tjw38m8hk','',''));
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------
SQL_ID  6vq4tjw38m8hk, child number 0
-------------------------------------
select /* test2 */ /*+ full(a) */ *from dh_sql a where name=:"SYS_B_0"
Plan hash value: 1575588977
----------------------------------------------------------------------------
| Id  | Operation         | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |        |       |       |   112 (100)|          |
|*  1 |  TABLE ACCESS FULL| DH_SQL |     2 |    76 |   112   (0)| 00:07:50 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter("NAME"=:SYS_B_0)
Note
-----
   - SQL profile PROF_6vq4tjw38m8hk_1575588977 used for this statement
22 rows selected.

SQL> @move_sql_profile.sql           --须要一些权限,建议用SYS用户运行
Enter value for profile_name: PROF_6vq4tjw38m8hk_1575588977
Enter value for sql_id: bp7gpwq6w88nv
Enter value for category (DEFAULT): 
Enter value for force_matching (false): TRUE
old  18:    'and name like (''&&profile_name'') '||
new  18:    'and name like (''PROF_6vq4tjw38m8hk_1575588977'') '||
old  36:    'and p.name like (''&&profile_name'')) '||
new  36:    'and p.name like (''PROF_6vq4tjw38m8hk_1575588977'')) '||
old  55: and name like ('&&profile_name')
new  55: and name like ('PROF_6vq4tjw38m8hk_1575588977')
old  66: sql_id = '&&sql_id';
new  66: sql_id = 'bp7gpwq6w88nv';
old  71: , category => '&&category'
new  71: , category => 'DEFAULT'
old  72: , name => 'PROFILE_'||'&&sql_id'||'_moved'
new  72: , name => 'PROFILE_'||'bp7gpwq6w88nv'||'_moved'
old  77: , force_match => &&force_matching
new  77: , force_match => TRUE
declare
*
ERROR at line 1:
ORA-00942: table or view does not exist
ORA-06512: at line 26


SQL> conn /as sysdba
Connected.
SQL> set verify off
SQL> @move_sql_profile.sql
Enter value for profile_name: PROF_6vq4tjw38m8hk_1575588977
Enter value for sql_id: bp7gpwq6w88nv
Enter value for category (DEFAULT): 
Enter value for force_matching (false): 
PL/SQL procedure successfully completed.
SQL> conn dbmon/dbmon_123
Connected.
SQL> select /* test2 */ * from dh_sql a where name='DBA_TABLES';

        ID NAME                           TYPE
---------- ------------------------------ ------------------------------
      3167 DBA_TABLES                     VIEW
      3168 DBA_TABLES                     SYNONYM
2 rows selected.
SQL> select * from table(dbms_xplan.display_cursor('bp7gpwq6w88nv','',''));
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------------
SQL_ID  bp7gpwq6w88nv, child number 0
-------------------------------------
select /* test2 */ * from dh_sql a where name=:"SYS_B_0"
Plan hash value: 1575588977
----------------------------------------------------------------------------
| Id  | Operation         | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |        |       |       |   112 (100)|          |
|*  1 |  TABLE ACCESS FULL| DH_SQL |     2 |    76 |   112   (0)| 00:07:50 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter("NAME"=:SYS_B_0)
Note
-----
   - SQL profile PROFILE_bp7gpwq6w88nv_moved used for this statement   --目的达成!
22 rows selected.

版权声明:本文博客原创文章,博客,未经同意,不得转载。

SQL Profile (总结4)--使用演示示例的更多相关文章

  1. Oracle 通过sql profile为sql语句加hint

    sql profile最大的优点是在不修改sql语句和会话执行环境的情况下去优化sql的执行效率,适合无法在应用程序中修改sql时.sql profile最常用方法大概是:--创建产生sql tuni ...

  2. SQL Profile 总结(一)

    一.前提概述 在介绍SQL Profile之前,不得不说的一个工具就是SQL Tuning Advisor:这个工具是从Oracle 10g開始引入,它的任务就是分析一个指定的SQL语句,并建议怎样使 ...

  3. 为什么需要SQL Profile

    为什么需要SQL Profile Why oracle need SQL Profiles,how it work and what are SQL Profiles... 使用DBMS_XPLAN. ...

  4. Selenium2学习-002-Selenium2 Web 元素定位及 XPath 编写演示示例

    此文主要对 Selenium2 的 Web 元素定位及 XPath 编写示例,敬请各位亲们参阅,共同探讨.若有不足之处,敬请各位大神指正,不胜感激! 通过 Firefox(火狐)浏览器的插件 Fire ...

  5. SQL profile纵览(10g)

    第一篇:介绍         10g开始,查询优化器(Query optimizer)扩展成自动调整优化器(Automatic Tuning Optimizer).也就是扩展了功能.此时,我们就可以让 ...

  6. nginx subrequest演示示例程序

    只有简单subrequest应用演示示例. nginx.conf文件: #user nobody; worker_processes 1; #error_log logs/error.log; #er ...

  7. java 添加一个线程、创建响应的用户界面 。 演示示例代码

    javajava 添加一个线程.创建响应的用户界面 . 演示示例代码 来自thinking in java 4 21章  部分的代码  夹21.2.11 thinking in java 4免费下载: ...

  8. 使用COE脚本绑定SQL Profile

    日常运维中,经常会遇到需要绑定好的执行计划的场景. 简单来说,就是将一个sql_id绑定好的plan_hash_value.如果没有使用到绑定变量,还需要把force_match设置为true. 用到 ...

  9. [视频]K8飞刀 SQL注入点脱库演示教程

    K8飞刀 SQL注入点脱库演示动画教程 链接:https://pan.baidu.com/s/15gLTxiv9v1Te5QNFZnfV4A 提取码:eaa1

随机推荐

  1. mysql 插入Emoji表情报错

    今天做的了个获取微信粉丝的功能,发现将昵称插入数据库报错.长度肯定是够的 Incorrect string value: '\xF0\x9F\x98\x84\xF0\x9F 找了点资料发现UTF-8编 ...

  2. Oracle trunc()函数

    Oracle trunc()函数的用法   --Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysd ...

  3. 轻量级的内部测试过程r \\ u0026研发团队

    对于一个r \\ u0026研发团队的目的,标准化的工作流程资产不可或缺的一部分,特别是对于初创的r \\ u0026研发团队方面.很多r \\ u0026研发管理是不够完整.如何理解的研发团队中的各 ...

  4. UVA 1291 Dance Dance Revolution(DP)

    意甲冠军:跳舞机有一个上5积分,分别central, top, bottom, left, right分,区区足站立还是需要1点物理,从一个单纯的脚central点上须要2点体力,从一个点上移动到相邻 ...

  5. 玩转Web之Jsp(三)-----Jsp+SQLServer 用sql语句实现分页

    在BBS的实现里,jsp与sqlserver 结合的操作中,怎样实现分页,使每页显示根帖的名字,并按发表时间降序排列? 在这里举例说明,page_size为每页显示的条数,pageNo为当前页数,st ...

  6. This Android SDK requires Android Developer Toolkit version 22.6.2 or above.

    今天,在android SDK升级时间,我遇到上述错误,经过一番努力仍克服. 解决方法:android-sdk-windows\tools\lib中间plugin.prop在文档 plugin.ver ...

  7. 【软件使用技巧】PL/SQL Developer实现双击table询

    二手plsql都知道,在表名默认双击[开展/关闭]. 习惯了MySql Workbench要么Sqlserver Management Studio无法适应其他管理工具. 直接在溶液: Tools - ...

  8. Mybatis之ResultMap一个简短的引论,关联对象

    基础部分能够查看我的还有一篇博客http://blog.csdn.net/elim168/article/details/40622491 MyBatis中在查询进行select映射的时候.返回类型能 ...

  9. sqlserver system object type

    select distinct s.type, s.type_desc from sys.objects as s inner join (select distinct type from sys. ...

  10. Oracle与Sql Server复制表结构和数据

    1.Oracle create table 新表名 AS SELECT * FROM 源表名 2.Sql Server SELECT * into 新表名 from 源表名 版权声明:笔者:jiank ...