oracle域索引简介(Oracle域索引简介)
oracle域索引简介(Oracle域索引简介)
Oracle全文检索
王力2009-08-06
Oracle从8i之前,就有了全文检索功能。到9i之后,基本可以放心使用。
建立的Oracle Text索引被称为域索引(域索引),包括4种索引类型:语境,ctxcat,ctxrule或ctxxpath。
在4种索引中,最常用的就是语境索引,使用最通用的包含操作符进行查询。
下面通过简单案例介绍一下使用的方法。
1。准备工作
康恩/数据库
创建表空间的数据文件的do_ind /债券/应用程序/ Oracle / oradata /测试/ do_ind1 DBF大小;
用户应该使用帐户解锁确定应该使用;
连接应该使用/应该使用
授予执行ctx_ddl史葛;
康恩史葛/老虎
——普通表
创建表T1
(name varchar2(10),
姓名日期,
信息VARCHAR2(500))
——分区表
创建表T2
(name varchar2(10),
姓名日期,
信息VARCHAR2(500))
按范围分区(姓名)
(分区p2007值小于(to_date(','yyyymmdd ')),
分区2008的值小于(to_date(','yyyymmdd ')),
分区p2009值小于(to_date(','yyyymmdd ')));
2。定义域索引参数
开始
--ctx_ddl.drop_preference('my_lexer”);
--ctx_ddl.drop_preference('mystore”);
——语法分析
ctx_ddl.create_preference('my_lexer ',' chinese_lexer”);
——存储参数
ctx_ddl.create_preference('mystore ',' basic_storage”);
ctx_ddl.set_attribute('mystore ',' i_table_clause ','表do_ind”);
ctx_ddl.set_attribute('mystore ',' i_index_clause ','表do_ind压缩2);
ctx_ddl.set_attribute('mystore ',' k_table_clause ','表do_ind”);
ctx_ddl.set_attribute('mystore ',' r_table_clause ','表do_ind”);
ctx_ddl.set_attribute('mystore ',' n_table_clause ','表do_ind”);
结束;
/
3。建立索引
语法如下:
创建索引[架构。]在[模式指标。]表(列)的索引类型是
ctxsys.context [在线]
本地分区[分区] [([参数('paramstring”)]
【[分区] [参数,分区('paramstring ')] ])]
([参数] [ paramstring)n ] [使用]平行;
创建索引ctx_ind_t1 T1(信息)的索引类型是CTXSYS.CONTEXT
参数('lexer my_lexer存储MyStore”);
创建索引ctx_ind_t2 T2(信息)的索引类型是CTXSYS.CONTEXT
地方的
参数('lexer my_lexer存储MyStore”);
4。简单查询
SELECT * FROM T1在包含(信息,“吃了吗”)> 0
5。索引的同步和优化
背景类型的域索引并不随着DML操作同步索引,需要定期同步索引。同步的方法有三种,使用ctxctl命令、系统包以及SQL语句。使用ctxctl命令已经不再推荐,就介绍包和SQL语句的同步方法。
?同步索引
对于分区索引,无法整个进行同步
1。使用ctx_ddl.sync_index
程序sync_index
参数名称类型在/输出默认值?
------------------------------ ----------------------- ------ --------
idx_name VARCHAR2违约
在默认的内存空
part_name VARCHAR2违约
在默认parallel_degree数
执行ctx_ddl.sync_index
(idx_name = >的ctx_ind_t2 ',part_name = >“2008,parallel_degree = > 2);
或者
改变指数ctx_ind_t2重建分区参数(2008 'sync”);
?优化索引
同样,分区索引也不能整个优化
使用ctx_ddl.optimize_index
程序optimize_ind