Adding a key

A key is an identifying field in a file, used when queries are processed so all fields in a record do not need to be searched for set criteria. A field or fields in a key must be defined as a field or fields in the database dictionary record. A key may be added in a production system without a system restart.

When a database dictionary file is created through Forms Designer, Service Manager automatically uses the first field defined on the associated format to create a Unique key. Manually modify the database dictionary record to add the necessary keys to support on-line and reporting queries, as well as sort sequences. Many other default system files, set up in the base system, may need to be changed, based on your individual search and reporting requirements. This section details the manual addition and manipulation of database dictionary record/file keys.

Note: If records already exist in the file when you add a key, updating the database dictionary record will cause Service Manager to automatically perform an index regeneration.

If you add keys to a file that contains records, be careful when defining key types. For example, do not define a new key as No Nulls (no blank values) if records exist in the file that contain no data in the particular field(s) comprising the key.

Each record not containing a value in the key field would require an update, populating the field with data. The updates must be performed prior to adding the No Nulls key in order to satisfy the new key definition.

A CREATE INDEX statement is generated when a new key is defined in the dbdict.

Note: If Service Manager determines it does not have rights to CREATE a TABLE it writes all database definition language (DDL) into files in the <RUN directory>/ddl folder and accepts changes to the dbdict without performing the CREATE INDEX operation.

Related topics

Modifying a key
Deleting a key
Arrayed structures
Alias fields
Methods for updating database dictionary records
Methods for deleting database dictionary records

Delete a key
Add a key as the first key
Insert a key between other keys
Add keys to bottom of the key list
Modify keys: Nulls and duplicates to unique