Hidden
Column Created by Function Based Index
(Thanks to Daniel
Harron to provide valuable information for this tip)
When you create a function based
index, oracle creates a hidden column on a base table. Oracle creates this
column as
Here I am demonstrating this by a
simple test
Step1 : Connect as SYS to Grant
Query Rewrite to scott
SQL>
connect sys/oracle as sysdba
Connected.
SQL>
grant query rewrite to scott;
Grant
succeeded.
Step2: Connect as Scott to create a test table
SQL>
connect scott/tiger
Connected.
SQL>
create table FBITEST (EMPNO NUMBER,ENAME VARCHAR2(10),EMPSTATUS
VARCHAR2(10));
SQL> create index
FBITESTIND on FBITEST(InitCap(ENAME));
Index
created.
Step 3: Connect as SYS to query the data dictionary
SQL>
select col#,name from SYS.col$ where obj# in (select object_id from dba_objects where object_name='FBITEST' and owner='SCOTT') order by col#;
----------
------------------------------
0 SYS_NC00003$
1 EMPNO
2 ENAME
3 EMPSTATUS
Let
us create another function based index on SCOTT.FBITEST table and
query the data dictionary
SQL>
create index fbitestind02 on scott.fbitest(lower(empstatus));
Index
created.
----------
------------------------------
0 SYS_NC00003$
0 SYS_NC00005$
1 EMPNO
2 ENAME
3 EMPSTATUS
Now
Oracle created another hidden column with a col# and
name as SYS_NC00005$
***
End of Tip
Author
©
Oracle Techniques