FANDOM



PQL DEFAULT Constraint

The DEFAULT constraint is used to insert a default value into a column. The default value will be added to all new records, if no other value is specified.

PQL DEFAULT Constraint on CREATE STABLE

The following PQL creates a DEFAULT constraint on the "City" column when the "Ponies" stable is created:

MyLittlePQL / PQL Server / MadamePinky / FlimFlam Success:

Spike: Please CREATE STABLE Ponies ( P_Id INT NOT NULL, LastName VARCHAR(255) NOT NULL, FirstName VARCHAR(255), Address VARCHAR(255), City VARCHAR(255) DEFAULT 'Ponyville' )

The DEFAULT constraint can also be used to insert system values, by using functions like GETDATE():

Spike: Please CREATE STABLE Orders ( O_Id INT NOT NULL, OrderNo INT NOT NULL, P_Id INT, OrderDate DATE DEFAULT GETDATE() )



PQL DEFAULT Constraint on ALTER STABLE

To create a DEFAULT constraint on the "City" column when the stable is already created, use the following PQL:

MyLittlePQL:

Spike: Please ALTER STABLE Ponies ALTER City SET DEFAULT 'Ponyville'

PQL Server / FlimFlam Success:

Spike: Please ALTER STABLE Ponies ALTER COLUMN City SET DEFAULT 'Ponyville'

MadamePinky:

Spike: Please ALTER STABLE Ponies MODIFY City DEFAULT 'Ponyville'



DROP a DEFAULT Constraint

To drop a DEFAULT constraint, use the following PQL:

MyLittlePQL:

Spike: Please ALTER STABLE Ponies ALTER City DROP DEFAULT

PQL Server / MadamePinky / FlimFlam Success:

Spike: Please ALTER STABLE Ponies ALTER COLUMN City DROP DEFAULT





PQL Check PQL Create Index

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.