One of the disadvantages
of using LONG or RAW columns in Oracle is that they're difficult to search
using conventional means and you cannot create indexes on them in the usual
manner (using the CREATE INDEX statement).
Oracle's ConText cartridge
solves this problem. Using the ConText Option allows the creation of indexes
on LONG columns which in turn allows them to be searched
Installing
Oracle ConText: CREATE TABLE
MESSAGE
And you want to enable ConTexT to search the text column.
Well, if you're here,
you probably know all that, you just want to know how to install this thing.
The Steps for installing Context are:
The script will
prompt you for four values of the user to create:
[username] [password] [default tablespace]
[temp tablespace]
Set the default tablespace to be one created in step 2.
$ORACLE_HOME/ctx/admin/dr0inst
as CTXSYS
user.
ctxsrv -user ctxsys/<ctxsys pw> -personality QDML
Note: this process must be running for ConTexT to work.
EXECUTECTX_DDL.CREATE_POLICY('<policyname>','<tablename>.<column>');
EXECUTE CTX_DDL.CREATE_INDEX('<policyname>');
For example,say you have the following table DDL:
(
MESSAGE_ID NUMBER,
TEXT LONG
);
You would then run the following(after granting CTXADMIN to this table's schema
owner):
Note that the policy name can by anything you want as long as it is unique.
EXECUTE CTX_DDL.CREATE_POLICY('MY_POLICY','MESSAGE.TEXT');
EXECUTE CTX_DDL.CREATE_INDEX('MY_POLICY');
Note that the ctxsrv process MUST first be running for this to work.
Once you get everything setup, you'll probably want to put
Step 8 into the background, and redirect output to
/dev/null2>&1
EXECUTING SEARCHES:
Once CONTEXT is running, you are set to perform searchs
on LONG Columns. The Syntax is as follows:
SELECT * FROM <TABLE> WHERECONTAINS(<LONG
COLUMN>,'<SEARCHPHRASE>') >0
Using the MESSAGE table above as an example, the syntax
for a search on the TEXT column for the phrase 'DBA Service" would be as follows:
SELECT * FROM MESSAGE WHERE CONTAINS(TEXT,'DBA Service') >
0;