Working with indexes

Creating an index

You can create as many single- or multi-valued indexes for a database table as you need, and you can drop indexes that are no longer needed.

NoteUpdate limitation You can update a table in a DataWindow object only if it has a unique index or primary key.

In SQL Anywhere databases, you should not define an index on a column that is defined as a foreign key, because foreign keys are already optimized for quick reference.

In UltraLite databases, the ascending or descending attribute is applied to each column in the index. UltraLite supports the ability to have an ascending index column and a descending index column in the same index.

StepsTo create an index:

  1. Do one of the following:

    The Index’s properties display in the Object Details view.

  2. Enter a name for the index in the Index box.

  3. Select whether or not to allow duplicate values for the index.

  4. Specify any other information required for your database

    For SQL Anywhere, specify the order of the index.

  5. Click the names of the columns that make up the index.

  6. Select Save Changes from the pop-up menu.

  7. Right-click on the Object Details view and select Save Changes from the pop-up menu.

    Any changes you made in the view are immediately saved to the table definition.

Modifying an index

You can modify an index.

StepsTo modify an index:

  1. Do one of the following:

  2. In the Object Details view, select or deselect columns as needed.

  3. Right-click on the Object Details view and select Save Changes from the pop-up menu.

    Any changes you made in the view are immediately saved to the table definition.

Dropping an index

Dropping an index removes it from the database.

StepsTo drop an index from a table:

  1. In the Database painter workspace, display the pop-up menu for the index you want to drop.

  2. Select Drop Index and click Yes.