Chapter 53 Index key – PrimaryKey
Specifies whether this index defines a primary key for the table.
usage
To specify that the primary key of the table consists of the attributes on which the index is based, use the following syntax:
Index name On property_expression_list [ PrimaryKey ];
Copy the code
Otherwise, omit this keyword or place the word Not before it.
Break down
This keyword specifies that this index should be reported through SQL as the primary key of this class (table).
A PrimaryKey index also behaves like a unique index. That is, InterSystems IRIS enforces uniqueness for attributes (or combinations of attributes) used in this index. In this index definition, the Unique keyword is allowed to be specified as true, but this is redundant.
The sample
Index EmpIDX On EmployeeID [ PrimaryKey] ;
Copy the code
The default
If you omit this keyword, the primary key of the table is not made up of the attributes on which the index is based.
Chapter 54 Index keyword – ShardKey
Specifies the shard key for this class.
usage
Until the shard class is fully implemented, InterSystems recommends creating shard tables from SQL, not from the object side. However, if you look at a class generated by creating a shard table, you might see code like this:
/// ShardKey Indicates the index of the shard table, which is automatically generated by the DDL CREATE table statement
Index ShardKey On DeptNum [ Abstract, CoshardWith = User.Department, ShardKey, SqlName = %ShardKey ];
Copy the code
In this case, the DeptNum attribute is the shard key for the current class.
Chapter 55 Index keyword – SqlName
Specify the SQL alias for the index.
usage
To override the default name of the index when referencing it through SQL, use the following syntax:
Index name On property_expression_list [ SqlName = sqlindexname];
Copy the code
Where sqlindexName is an SQL identifier.
Break down
When the keyword is referenced through SQL, you can define an alternative name for the index.
The default
If this keyword is ignored, the SQL name of the index is the indexName given in the index definition.
Chapter 56 Index keyword – Type
Specifies the type of index.
usage
To specify the type of index, use the following syntax:
Index name On property_expression_list [ Type = indextype ];
Copy the code
Indextype is one of the following types:
-
Bitmap – A bitmap index
-
Bitslice – Bitslice index
-
Index – Standard index (default)
-
The key – abandoned
Break down
This keyword specifies the type of index, whether it is implemented as a bitmap index or as a standard (regular, non-bitmap) index.
Bitmap indexes cannot be marked as unique.
The default
If this keyword is omitted, the index is a standard index.