建议 #1:
不要采用这种设计
建议 #2:
如果您必须采用这种设计,您可以使用文本索引来解析出索引值,例如
SQL> create table t ( cid int, mobs varchar2(1000));
Table created.
SQL>
SQL> insert into t
2 select c, listagg(num,',') within group ( order by num )
3 from
4 ( select mod(rownum,1000) c, trunc(dbms_random.value(1000000,9999999)) num from dual connect by level <= 4000 )
5 group by c;
1000 rows created.
SQL>
SQL> select * from t
2 where rownum <= 10;
CID MOBS
---------- --------------------------------------------------
710 1309670,2250891,2446498,6381871
711 6441062,7421544,8803290,8980956
712 5216092,6664995,7971562,8615836
713 2699908,4060187,7669498,8998292
714 2565735,2621571,4071919,9443984
715 1284533,2445570,6669291,8675917
716 2368712,4074744,7804389,9798070
717 1037619,4071820,4235448,7026192
718 2955831,6282004,7131543,9027507
719 4040856,4761599,4859829,9179022
10 rows selected.
SQL>
SQL> begin
2 ctx_ddl.drop_preference('my_lexer');
3 ctx_ddl.create_preference('my_lexer', 'BASIC_LEXER');
4 ctx_ddl.set_attribute('my_lexer', 'numgroup', '~');
5 end;
6 /
PL/SQL procedure successfully completed.
SQL>
SQL> create index ix on t ( mobs ) indextype is ctxsys.context PARAMETERS('lexer my_lexer');
Index created.
SQL> set autotrace on
SQL> select * from t
2 where contains(mobs,'7804389') > 0;
CID MOBS
---------- --------------------------------------------------
716 2368712,4074744,7804389,9798070
1 row selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 1339481741
------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 527 | 4 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 1 | 527 | 4 (0)| 00:00:01 |
|* 2 | DOMAIN INDEX | IX | | | 4 (0)| 00:00:01 |
------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("CTXSYS"."CONTAINS"("MOBS",'7804389')>0)
Note
-----
- dynamic statistics used: dynamic sampling (level=2)
Statistics
----------------------------------------------------------
196 recursive calls
0 db block gets
152 consistent gets
1 physical reads
0 redo size
640 bytes sent via SQL*Net to client
608 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>
SQL>