Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Do we need to rebuild Text Index after every insert?

618435Jun 9 2008 — edited Jun 10 2008
Hi,

I am creating basic text index on a table. Buf after inserting rows index is not updating automatically. Do we need to rebuild index after each update?

Here is my practice :
 

SQL> CREATE TABLE quick (
  2               quick_id NUMBER PRIMARY KEY,
  3               text VARCHAR(80)
  4             );

Table created.

SQL> CREATE INDEX quick_text ON quick ( text )
  2     INDEXTYPE IS ctxsys.CONTEXT;

Index created.

SQL> INSERT INTO quick (quick_id, text )
  2       VALUES (1, 'The cat sat on the mat');

1 row created.

SQL> INSERT INTO quick (quick_id, text )
  2       VALUES (2, 'The quick brown fox jumped over the lazy dog');

1 row created.

SQL> COMMIT ;

Commit complete.

SQL> SELECT quick_id
  2    FROM quick
  3   WHERE contains (text, 'cat') > 0;

no rows selected

SQL> ALTER INDEX  quick_text REBUILD;

Index altered.

SQL> SELECT quick_id
  2    FROM quick
  3   WHERE contains (text, 'cat') > 0;

  QUICK_ID
----------
         1

1 row selected.

SQL> INSERT INTO quick (quick_id, text )
  2       VALUES (3, 'The fish is big.');

1 row created.

SQL> SELECT quick_id
  2    FROM quick
  3   WHERE contains (text, 'fish') > 0;

no rows selected

SQL> ALTER INDEX  quick_text REBUILD;

Index altered.

SQL> SELECT quick_id
  2    FROM quick
  3   WHERE contains (text, 'fish') > 0;

  QUICK_ID
----------
         3

1 row selected.
Please clarify my doubt.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 8 2008
Added on Jun 9 2008
3 comments
4,677 views