Loading lesson path
Concept visual
Start at both ends
❮ SQL Keywords
constraint provides a default value for a column. The default value will be added to all new records if no other value is specified.
The following SQL sets a DEFAULT value for the "City" column when the "Persons" table is created:
Formula
My SQL / SQL Server / Oracle / MS Access:(
);
The DEFAULT constraint can also be used to insert system values, by using functions like GETDATE():(
);To create a DEFAULT constraint on the "City" column when the table is already created, use the following SQL:
ALTER City SET DEFAULT 'Sandnes';ADD CONSTRAINT df_City
DEFAULT 'Sandnes' FOR City;ALTER COLUMN City SET DEFAULT 'Sandnes';MODIFY City DEFAULT 'Sandnes';To drop a DEFAULT constraint, use the following SQL:
ALTER City DROP DEFAULT;Formula
SQL Server / Oracle / MS Access:ALTER COLUMN City DROP DEFAULT;❮ SQL Keywords