--Log in with sys user, unlock Ctxsys user
Alter user Ctxsys account unlock;
--Authorization to the corresponding user
Grant execute on CTX_DDL to yw;
--Log in with YW user
--Create a word breaker named My_lexer
exec ctx_ddl.create_preference (' my_lexer ', ' chinese_lexer ');
--Create an index
Create INDEX Idx_addr_view on M_addr_view2 (ADDR) Indextype is Ctxsys. CONTEXT parameters (' lexer my_lexer ');
--Rebuilding the index
ALTER INDEX idx_addr_view REBUILD PARAMETERS (' Replace lexer my_lexer ');
--Synchronous index
Begin
Ctx_ddl.sync_index (' Idx_addr_view ');
End
--Optimized indexing
Begin
Ctx_ddl.optimize_index (' Idx_addr_view ', ' full ');
End
--Create a synchronous stored procedure to synchronize the information in a table field
Create or replace procedure Proc_sync_addr_view as
Begin
Ctx_ddl.sync_index (' Idx_addr_view ');
End
--Create a task, perform a synchronous index
VARIABLE jobno number;
BEGIN
Dbms_job. SUBMIT (: Jobno, ' Proc_sync_addr_view (); ', Sysdate, ' sysdate + 7 ');
Commit
END;
--Create an optimized stored procedure
Create or replace procedure Proc_opti_addr_view as
Begin
Ctx_ddl.optimize_index (' Idx_addr_view ', ' full ');
End
--Create a task, perform a synchronous index
VARIABLE jobno number;
BEGIN
Dbms_job. SUBMIT (: Jobno, ' Proc_opti_addr_view (); ', Sysdate, ' sysdate + 7 ');
Commit
END; --View all Jobselect Job,what,failures,broken from User_jobs in the database--View the running job
SELECT * FROM dba_jobs_running--delete Jobbegin
Dbms_job.broken (4,true); --true = stop false means pause
Dbms_job.remove (4);
Commit
END;
Oracle Full-text index-related commands