Primary Property

See Also   Applies To

Sets or returns a value that indicates whether a CdbIndex object represents a primary index for a table (Microsoft Jet workspaces only).

Syntax

VOIDSetPrimary(BOOL bFlag);

BOOLGetPrimary(VOID);

Parameters

Type Example Description
BOOL bFlag TRUE if the CdbIndex object represents a primary index.

Remarks

A primary index consists of one or more fields that uniquely identify all records in a table in a predefined order. Because the index field must be unique, the Unique property of the CdbIndex object is set to True. If the primary index consists of more than one field, each field can contain duplicate values, but each combination of values from all the indexed fields must be unique. A primary index consists of a key for the table and usually contains the same fields as the primary key.

The Primary property setting is read/write for a new CdbIndex object not yet appended to a collection and read-only for an existing CdbIndex object in an Indexes collection. If the CdbIndex object is appended to the CdbTableDef object but the CdbTableDef object isn't appended to the TableDefs collection, the Primary property is read/write.

Note You don't have to create indexes for tables, but in large, unindexed tables, accessing a specific record can take a long time. The Attributes property of each CdbField object in the CdbIndex object determines the order of records and consequently determines the access techniques to use for that index. When you create a new table in your database, it's a good idea to create an index on one or more fields that uniquely identify each record, and then set the Primary property of the CdbIndex object to True.

When you set a primary key for a table, the primary key is automatically defined as the primary index for the table.