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

SQL Anywhere 11.0.0 » SQL Anywhere Server - SQL Usage » Designing and Creating Databases » Working with database objects » Working with indexes


Rebuilding indexes

Sometimes it is necessary to rebuild an index because it has become fragmented or skewed due to extensive insertion and deletion operations on the table. When you rebuild an index, you rebuild the physical index. All logical indexes that use the physical index benefit from the rebuild operation. You do not need to perform a rebuild on logical indexes. See Index sharing using logical indexes.

You can rebuild indexes in Sybase Central, or by executing an ALTER INDEX ... REBUILD statement. You can also rebuild indexes as part of an effort to remove table fragmentation using the REORGANIZE TABLE statement. This section describes how to rebuild indexes using Sybase Central and the ALTER INDEX ... REBUILD statement. For more information about using the REORGANIZE TABLE statement, see REORGANIZE TABLE statement.

To rebuild an index (Sybase Central)

  1. Connect to the database as a user with DBA authority, or as the owner of the table on which the index is created.

  2. In the left pane, double-click Indexes.

  3. Right-click the index and choose Rebuild.

  4. Click OK.

To rebuild an index (SQL)

  1. Connect to the database as a user with DBA authority, or as the owner of the table associated with the index.

  2. Execute an ALTER INDEX ... REBUILD statement.


The following statement rebuilds the IX_customer_name index on the Customers table:

ALTER INDEX IX_customer_name ON Customers REBUILD;
See also

For more information about index fragmentation and skew, and how to reduce them, see Reducing index fragmentation and skew.

For more information about how to detect index fragmentation and skew, see Application Profiling Wizard, and sa_index_density system procedure.

For more information about the syntax for the ALTER INDEX statement, see ALTER INDEX statement.