Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » SQL Anywhere Server - SQL Reference » SQL statements » Alphabetical list of SQL statements


Refreshes a text index.

REFRESH TEXT INDEX text-index-name ON [ owner.]table-name
[ WITH { 
      ISOLATION LEVEL isolation-level 
      | SHARE MODE } ]
  • WITH clause

    Use the WITH clause to specify what kind of locks to obtain on the underlying base tables during the refresh. The types of locks obtained determine how the text index is populated and how concurrency for transactions is affected. If you do not specify the WITH clause, the default is WITH ISOLATION LEVEL READ UNCOMMITTED, regardless of any isolation level set for the connection.

    You can specify the following WITH clause options:

    • ISOLATION LEVEL isolation-level

      Use WITH ISOLATION LEVEL to change the isolation level for the execution of the refresh operation.

      The original isolation level of the connection is restored at the end of the statement execution.


      Use WITH EXCLUSIVE MODE if you do not want to change the isolation level, but want to guarantee that the data is updated to be consistent with committed data in the underlying table. When using WITH EXCLUSIVE MODE, exclusive table locks are placed on the underlying base table and no other transaction can execute queries, updates, or any other action against the underlying table(s) until the refresh operation is complete. If table locks cannot be obtained, the refresh operation fails and an error is returned.


      Use WITH SHARE MODE to give read access on the underlying table to other transactions while the refresh operation takes place. When this clause is specified, shared table locks are obtained on the underlying base table before the refresh operation is performed and are held until the refresh operation completes.

  • FORCE clause

    Use this clause to specify the refresh method. If this clause is not specified, the database server decides whether to do an incremental update or a full rebuild based on how much of the table has changed.

    • FORCE BUILD clause

      Refreshes the text index by recreating it. Use this clause to force a complete rebuild of the text index.


      Refreshes the text index based only on what has changed in the underlying table. An incremental refresh takes less time to complete if there have not been a significant amount of updates to the underlying table. Use this clause to force an incremental update of the text index.

      An incremental refresh does not remove deleted entries from the text index. As a result, the size of the text index may be larger than expected to contain the current and historic data. Typically, this issue occurs with text indexes that are always manually refreshed with the FORCE INCREMENTAL clause. On automatically refreshed text indexes, historic data is automatically deleted when it makes up 50% of the total size of the text index.


This statement can only be used on text indexes defined as MANUAL REFRESH or AUTO REFRESH.

When using the FORCE clause, you can examine the results of the sa_text_index_stats system procedure to decide whether a complete rebuild (FORCE BUILD), or incremental update (FORCE INCREMENTAL) is most appropriate.

You cannot execute the REFRESH TEXT INDEX statement on a text index that is defined as IMMEDIATE REFRESH.

For MANUAL REFRESH text indexes, use the sa_text_index_stats system procedure to determine whether the text index should be refreshed. Divide pending_length by doc_length, and use the percentage as a guide for deciding whether a refresh is required. To determine the type of rebuild required, use the same process for deleted_length and doc_count.

This statement cannot be executed when there are cursors opened with the WITH HOLD clause that use either statement or transaction snapshots.


You must be the owner of the table, or have one of the following privileges:

  • REFERENCES privilege on the table
  • CREATE ANY INDEX system privilege
  • ALTER ANY INDEX system privilege
  • CREATE ANY OBJECT system privilege
  • ALTER ANY OBJECT system privilege
Side effects

Automatic commit.

  • ANSI/ISO SQL Standard

    Not in the standard.


The following statement refreshes a fictitious text index called MarketingTextIndex, forcing it to be rebuilt.

REFRESH TEXT INDEX MarketingTextIndex ON GROUPO.MarketingInformation