Skip to main content

PrimaryKey (Index Keyword)

Specifies whether this index defines the primary key for the table.

Usage

To specify that the primary key for this table is formed by the properties on which this index is based, use the following syntax:

Index name On property_expression_list [ PrimaryKey ];

Where:

  • name is the name of the index. It is useful to follow a naming convention so that indexes can be easily distinguished from properties. For example, you could include IDX at the end of all index names.

  • property_expression_list is either a single property name or a comma-separated list of properties, enclosed in parentheses.

Otherwise, omit this keyword or place the word Not immediately before the keyword.

Details

This keyword specifies that this index should be reported, via SQL, as being the primary key for this class (table).

A PrimaryKey index also behaves like a unique index. That is, for the property (or the combination of properties) that you use in this index, InterSystems IRIS enforces uniqueness. It is permitted, but redundant, to specify the Unique keyword as true in this index definition.

For a primary key index, InterSystems IRIS generates methods that you can use to open objects, check existence of objects, and delete objects; see Open, Exists, and Delete Methods.

Example

Index EmpIDX On EmployeeID [ PrimaryKey] ;

Default

If you omit this keyword, the primary key for this table is not formed by the properties on which this index is based.

See Also

FeedbackOpens in a new tab