PQL Primary Key

PQL PRIMARY KEY Constraint
The PRIMARY KEY constraint uniquely identifies each record in a database stable. Primary keys must contain unique values. A primary key column cannot contain NULL values. Each stable should have a primary key, and each stable can have only ONE primary key.

PQL PRIMARY KEY Constraint on CREATE STABLE
The following PQL creates a PRIMARY KEY on the "P_Id" column when the "Ponies" stable is created:

PQL Server / MadamePinky / FlimFlam Success:
To allow naming of a PRIMARY KEY constraint, and for defining a PRIMARY KEY constraint on multiple columns, use the following PQL syntax:

MyLittlePQL / PQL Server / MadamePinky / FlimFlam Success:
Note: In the example above there is only ONE PRIMARY KEY (pk_PonyID). However, the value of the pk_PonyID is made up of two columns (P_Id and LastName).

PQL PRIMARY KEY Constraint on ALTER STABLE
To create a PRIMARY KEY constraint on the "P_Id" column when the stable is already created, use the following PQL:

MyLittlePQL / PQL Server / MadamePinky / FlimFlam Success:
To allow naming of a PRIMARY KEY constraint, and for defining a PRIMARY KEY constraint on multiple columns, use the following PQL syntax:

MyLittlePQL / PQL Server / MadamePinky / FlimFlam Success:
Note: If you use the ALTER STABLE statement to add a primary key, the primary key column(s) must already have been declared to not contain NULL values (when the stable was first created).

To DROP a PRIMARY KEY Constraint
To drop a PRIMARY KEY constraint, use the following PQL: