Gblog

おもにTips

同じ列に索引を作成できるらしい

全く知らなかったのですが、VISIBLE / INVISIBLE を使えば、同じ列に複数の索引をはれるらしいです。19c で確認。

SQL> create table t1 as select * from v$parameter;

Table created.

SQL> create index t1_ind1 on t1(num);

Index created.

SQL> create index t1_ind2 on t1(num) global partition by hash (num) partitions 4;
create index t1_ind2 on t1(num) global partition by hash (num) partitions 4
                           *
ERROR at line 1:
ORA-01408: such column list already indexed


SQL> create index t1_ind2 on t1(num) global partition by hash (num) partitions 4 invisible;

Index created.

SQL> 

 

これ、もっと早く知りたかった....

optimizer_use_invisible_indexes もあるので、ちょっと注意しないとトラブルになりそうですが、何かの理由で索引を作り変えたいときは使えそう。