|
The CONSTRAINT keyword is used when creating a
constraint such as a primary key or a foreign key.
|
Here is an example of creating a primary key using the
CONSTRAINT keyword:
CREATE TABLE Persons(PersonID COUNTER(1,1) NOT NULL,
FirstName varchar(20),
LastName varchar(20) NOT NULL,
CONSTRAINT PK_People PRIMARY KEY(PersonID));
Here is an example that adds uses a constraint to add
a primary key:
Here is an example:
Private Sub cmdMakePrimaryKey_Click()
DoCmd.RunSQL "ALTER TABLE Departments " & _
"ADD CONSTRAINT PK_Departments PRIMARY KEY(DepartmentCode);"
End Sub