明天在19c上又做了一次SqlPatch,发现上次写的在11gR2的办法总是报错,于是又看了19c的Online Documents。更新了一下SqlPatch的做成办法。
- 做成TEST用户和Table,Index。
SQL> grant connect,resource,unlimited tablespace to test3 identified by test3; 権限付与が胜利しました。 SQL> grant administer sql management object to test3; 権限付与が胜利しました。 SQL> conn test3/test3@localhost:1521/pdb 接続されました。 SQL> create table tab2(c1 number, c2 number, c3 varchar2(10)); 表が作成されました。 SQL> declare a number; begin a := 1; for i in 1 .. 50 loop for j in 1 .. 100 loop insert into tab2 values(a,j,'a'); commit; a := a+1; end loop; end loop; end; / PL/SQLプロシージャが失常に完了しました。 SQL> create index ind2_2 on tab2(c2); 索引が作成されました。
2. 做成SQLPATCH。
SQL> var cnt varchar2(200);SQL> exec :cnt := DBMS_SQLDIAG.CREATE_SQL_PATCH (sql\_text => TO_CLOB('select \* from tab2 where c2=1'),hint_text => TO_CLOB('INDEX_RS_ASC(@"SEL$1" "TAB2"@"SEL$1" ("TAB2"."C2"))'));PL/SQLプロシージャが失常に完了しました。
- 验证SQLPATCH。
SQL> set autot traceonly expSQL> set lin 120 pages 999SQL> select * from tab2 where c2=1;実行計画----------------------------------------------------------Plan hash value: 616764305----------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |----------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT||50 | 1650 |11 (0)| 00:00:01 || 1 | TABLE ACCESS BY INDEX ROWID BATCHED| TAB2 |50 | 1650 |11 (0)| 00:00:01 ||* 2 | INDEX RANGE SCAN | IND2_2 |50 | | 1 (0)| 00:00:01 |----------------------------------------------------------------------------------------------Predicate Information (identified by operation id):---------------------------------------------------2 - access("C2"=1)Note------ dynamic statistics used: dynamic sampling (level=2)- SQL patch "SYS_SQLPTCH_0178349b7d430005" used for this statement