■テーブル構造
create table story(
author varchar2(100) primary key,
body varchar2(1000)
);
■検索用ユーザーの作成
create user user
identified by password
default tablespace users
temporary tablespace temp;
grant connect,resource to user;
■ールctxappをuserに与える。
grant ctxapp to user;
■プリファレンスの作成
begin ctx_ddl.create_preference(
'english_lexer', 'basic_lexer');
--日本語は
--ctx_ddl.set_attribute(
-- 'japanese_lexer', 'JAPANESE_VGRAM_LEXER');
--など
ctx_ddl.set_attribute(
'english_lexer', 'index_themes', 'no');
end;
/
■インデックスの作成
body列へのインデックスが作成可能となる。
create index song_index on story(body)
indextype is ctxsys.context
parameters('LEXER english_lexer STOPLIST ctxsys.default_stoplist');
このインデックスをSQL文で使用することができる。
select author from story where contains('body', 'database system', 1) > 0;
|
Oracleでテキストインデックスを使用す
Oracleのテクニックを記
VARCHAR2をNUMBERに変換する際、桁数で怒られるときに桁数を無視するfunction
SQLのテクニックを記
|