DIRECTORY_DATASTORE Example
This example shows you how to create an index with DIRECTORY_DATASTORE type by securely accessing files under an Oracle directory object.
Create an Oracle directory object to store the path of the files. You must have the CREATE ANY DIRECTORY privilege to create an Oracle directory object.
create directory myhome as 'directory_path';
Create a directory datastore preference called MYDS and set the directory attribute with myhome, which is the Oracle directory object:
exec ctx_ddl.create_preference('MYDS','DIRECTORY_DATASTORE')
exec ctx_ddl.set_attribute('MYDS','DIRECTORY','myhome')
Create a table named mytable and populate it with file names only. The directory attribute tells the system where to look during the indexing operation.
create table mytable(id number primary key, docs varchar2(2000));
insert into mytable values(111555,'first.txt');
insert into mytable values(111556,'second.txt');
Create the index as follows:
create index myindex on mytable(docs)
indextype is ctxsys.context
parameters ('datastore MYDS');