An index provides quick access to data in a table, based on the values in specified columns. A table can have more than one index. Indexes are transparent when accessing data from that table; SAP ASE automatically determines when to use the indexes.
Indexes speed data retrieval by pointing to the location of a table column’s data on disk.
create index stor_id_ind on stores (stor_id)
The stor_id_ind index goes into effect automatically the next time you query the stor_id column in stores. In other words, indexes are transparent to users. SQL includes no syntax for referring to an index in a query. You can only create or drop indexes from a table; SAP ASE determines whether to use the indexes for each query submitted for that table. As the data in a table changes over time, SAP ASE may change the table’s indexes to reflect those changes. Again, these changes are transparent to users.
Composite indexes – these indexes involve more than one column. Use this type of index when two or more columns are best searched as a unit because of their logical relationship.
Unique indexes – these indexes do not permit any two rows in the specified columns to have the same value. SAP ASE checks for duplicate values when the index is created (if data already exists) and each time data is added.
Clustered or nonclustered indexes – clustered indexes force SAP ASE to continually sort and re-sort the rows of a table so that their physical order is always the same as their logical (or indexed) order. You can have only one clustered index per table. Nonclustered indexes do not require the physical order of rows to be the same as their indexed order. Each nonclustered index can provide access to the data in a different sort order.
local indexes – local indexes are an index subtree that indexes only one data partition. They can be partitioned, and they are supported on all types of partitioned tables.
Global indexes – global indexes index span all data partitions in a table. Nonpartitioned, global clustered indexes are supported on round-robin-partitioned tables, and nonclustered global indexes are supported on all types of partitioned tables. You cannot partition global indexes.Clustered and nonclustered global indexes on partitioned tables can only be created using syntax supported in SAP ASE version 12.5.x and earlier.
For information on how you can design indexes to improve performance, see the Performance and Tuning Series: Locking and Concurrency Control.