oracle實驗記錄 (函式index)
要求
QUERY_REWRITE_ENABLED=TRUE和QUERY_REWRITE_INTEGRITY=RUSTED
SQL> create table test (a varchar2(5));
Table created.
1 declare
2 begin
3 for i in 1..100 loop
4 insert into test values ('a');
5 end loop;
6 commit;
7* end;
SQL> explain plan for select * from test where upper(a)='A';
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 3836831076
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 100 | 400 | 2 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| TEST | 100 | 400 | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
1 - filter(UPPER("A")='A')**********************************
Note
-----
- dynamic sampling used for this statement ~~動態採集
SQL> create index test_fun on test(upper(a));
Index created.
SQL> explain plan for select * from test where upper(a)='A';
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1975250114
--------------------------------------------------------------------------------
--------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Ti
me |
--------------------------------------------------------------------------------
--------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 100 | 400 | 1 (0)| 00
:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| TEST | 100 | 400 | 1 (0)| 00
:00:01 |
|* 2 | INDEX RANGE SCAN | TEST_FUN | 1 | | 1 (0)| 00
:00:01 |
--------------------------------------------------------------------------------
--------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access(UPPER("A")='A')************************
Note
-----
- dynamic sampling used for this statement
18 rows selected.
SQL> select file_id,extent_id,block_id,blocks from dba_extents where segment_nam
e='TEST_FUN';
FILE_ID EXTENT_ID BLOCK_ID BLOCKS
---------- ---------- ---------- ----------
1 0 57393 8
SQL> alter system dump datafile 1 block 57394;
System altered.
row#0[8025] flag: ------, lock: 0, len=11
col 0; len 1; (1): 41
col 1; len 6; (6): 00 40 dd 7a 00 00~~~~~~~~~有6字的rowid
節的rowid
row#1[8014] flag: ------, lock: 0, len=11
col 0; len 1; (1): 41
col 1; len 6; (6): 00 40 dd 7a 00 01
row#2[8003] flag: ------, lock: 0, len=11
col 0; len 1; (1): 41
col 1; len 6; (6): 00 40 dd 7a 00 02
row#3[7992] flag: ------, lock: 0, len=11
col 0; len 1; (1): 41
col 1; len 6; (6): 00 40 dd 7a 00 03
row#4[7981] flag: ------, lock: 0, len=11
SQL> select chr(to_number(41,'xxxx')) from dual;
CH
--
A~~~~~~~~~~~~~~函式計算後的值存index中 成為一個虛擬列
函式index對 inser,update有影響 對應更新index有麻煩
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12020513/viewspace-611375/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle實驗記錄 (dump index b*tree)OracleIndex
- oracle實驗記錄(INDEX fast full scan 的成本計算)OracleIndexAST
- oracle實驗記錄 (oracle b*tree index訪問Cost計算(1))OracleIndex
- oracle實驗記錄 (flashback)Oracle
- oracle實驗記錄 (OMF)Oracle
- oracle實驗記錄 (NET)Oracle
- oracle實驗記錄 (audit)Oracle
- oracle實驗記錄 (oracle reset parameter)Oracle
- Oracle Data Redaction實驗記錄Oracle
- oracle實驗記錄 (block cleanout)OracleBloC
- oracle實驗記錄 (dump undo)Oracle
- oracle實驗記錄 (inlist card)Oracle
- oracle實驗記錄 (oracle 資料字典)Oracle
- Oracle檔案改名實驗記錄Oracle
- oracle實驗記錄 (選擇率)Oracle
- oracle實驗記錄 (dump logfile)Oracle
- oracle實驗記錄 (事務控制)Oracle
- oracle實驗記錄 (bigfile tablespace)Oracle
- oracle實驗記錄 (恢復-redo)Oracle
- oracle實驗記錄 (expdp/impdp使用)Oracle
- oracle實驗記錄 (transport tablespace(Rman))Oracle
- oracle實驗記錄 (使用exp/imp)Oracle
- 使用Oracle分析函式去除重複記錄Oracle函式
- 【函式】Oracle的常用字元函式實驗展示(一)函式Oracle字元
- 【函式】Oracle的常用字元函式實驗展示(二)函式Oracle字元
- oracle實驗記錄 (CKPT的觸發)Oracle
- oracle實驗記錄 (dump undo4)Oracle
- oracle實驗記錄 (dump undo3)Oracle
- oracle實驗記錄 (dump undo2)Oracle
- oracle實驗記錄 手工 duplicate database(1)OracleDatabase
- oracle實驗記錄Rman duplicate database(1)OracleDatabase
- oracle實驗記錄 (許可權,role)Oracle
- oracle實驗記錄 (SQL*PLUS 命令操作)OracleSQL
- oracle實驗記錄 (PFILE 啟動SPFILE)Oracle
- oracle實驗記錄 (SHARED server MODE)OracleServer
- oracle實驗記錄Rman duplicate database 2OracleDatabase
- oracle實驗記錄(恢復-checkpoint cnt)Oracle
- oracle實驗記錄 (可恢復session)OracleSession