Indexed Virtual
Column
It is
an alternative to a function based index.
Add a Virtual Column to the table, and create an index on it.
Add a Virtual Column to the table, and create an index on it.
Eg :
CREATE TABLE EMP
(
EMPNO NUMBER,
ENAME VARCHAR(20),
SAL NUMBER(7,2),
COMM NUMBER(7,2),
TOTALSAL GENERATED ALWAYS AS (SAL +NVL(COMM,0))
);
CREATE TABLE EMP
(
EMPNO NUMBER,
ENAME VARCHAR(20),
SAL NUMBER(7,2),
COMM NUMBER(7,2),
TOTALSAL GENERATED ALWAYS AS (SAL +NVL(COMM,0))
);
CREATE INDEX IDX_EMP_TOTALSAL ON EMP(TOTALSAL);
Virtual Index
You can
instruct Oracle to create an index and that will never be used and won't have
any extents allocated to it via NOSEGMENT clause
Eg : CREATE INDEX IDX_EMP ON EMP(EMPNO) NOSEGMENT;
Even
though the index is not physically instantiated, you can instruct Oracle to determine if the
index might be used by the optimizer via _USE_NOSEGMENT_INDEXES initialization
parameter
Eg : ALTER SESSION SET "_USE_NOSEGMENT_INDEXES" = true
Invisible Indexes
Optimizer
doesn't use the index when retrieving data for a query. However Insex structure
is still maintained as the underlying table has records inserted, updated or deleted.
This feature is used if you want to test the viability of an index without impacting
existing application code
Eg : CREATE INDEX IDX ON EMP(EMPNO) INVISIBLE ;
Note: Virtual Columns & Invisible Indexes are only available
in 11g and higher versions
No comments:
Post a Comment