• When any index is created, it is marked as being “owned” by the user, the integrity
constraint, or both. A user cannot delete an index that is also owned by an integrity
constraint and vice versa. If an index is owned by both, the index is deleted only
after both the integrity constraint and the user have requested the index's deletion. A
note in the log indicates when an index cannot be deleted.
Locking Integrity Constraints
Integrity constraints support both member-level and record-level locking. You can
override the default locking level with the CNTLLEV= data set option. For more
information, see the “CNTLLEV= Data Set Option” in SAS Data Set Options:
Reference.
Encryption and Integrity Constraints
There are two types of algorithms that SAS uses for encrypting:
• SAS Proprietary encryption is implemented with the ENCRYPT=YES data set
option.
• AES (Advanced Encryption Standard) encryption is implemented with the
ENCRYPT=AES data set option.
SAS Proprietary encryption has no restrictions when using integrity constraints.
AES encryption requires that all primary key and foreign key data files must use the
same encryption key that opens all referencing foreign key and primary key data files.
You must specify the ENCRYPTKEY= data set option when using ENCRYPT=AES.
For more information, see “ENCRYPT= Data Set Option” in SAS Data Set Options:
Reference and “ENCRYPTKEY= Data Set Option” in SAS Data Set Options: Reference.
If an encryption key was not recorded for the metadata-bound library, then the
encryption key must be the same for the primary key data file and the referencing
encrypted foreign key data file. For more information about metadata-bound libraries,
see “Metadata-Bound Library” in Base SAS Procedures Guide.
Specifying Integrity Constraints
You can create integrity constraints in the SQL procedure, the DATASETS procedure, or
in SCL (SAS Component Language). The constraints can be specified when the data file
is created or can be added to an existing data file. When you add integrity constraints to
an existing file, SAS verifies that the existing data values conform to the constraints that
are being added.
When you specify integrity constraints, you must specify a separate statement for each
constraint. In addition, you must specify a separate statement for each variable to which
you want to assign the not-null integrity constraint. When multiple variables are included
in the specification for a primary key, foreign key, or a unique integrity constraint, a
composite index is created and the integrity constraint enforces the combination of
variable values. The relationship between SAS indexes and integrity constraints is
described in “Indexes and Integrity Constraints” on page 659. For more information,
see “Understanding SAS Indexes” on page 638.
When you add an integrity constraint in SCL, open the data set in utility mode. See
“Creating Integrity Constraints By Using SCL” on page 633 for an example. Integrity
constraints must be deleted in utility open mode. For detailed syntax information, see
SAS Component Language: Reference.
630 Chapter 26 • SAS Data Files