DEFAULT

SQL DEFAULT Keyword

The DEFAULT constraint provides a default value for a column. The default value will be added to all new records if no other value is specified.

SQL DEFAULT on CREATE TABLE Syntax

SQL

Tutorials dojo strip

SQL DEFAULT on CREATE TABLE Example

MySQL / SQL Server / Oracle / MS Access / SQLite:

This sets a default value of 'General' for the specialty column.

SQL

SQL DEFAULT with System Functions Example

SQL Server:

This sets the default value of order_date to the current system date using GETDATE().

SQL

Note: This example will not work in SQLite including our TechKubo playground. SQLite does not support system functions like GETDATE() as default values.

SQL DEFAULT on ALTER TABLE Examples

MySQL:

SQL

SQL Server:

SQL

MS Access:

SQL

Oracle:

SQL

Note: These commands will not work in SQLite. In SQLite, the default value must be defined when the table is created.

SQL DEFAULT DROP a DEFAULT Constraint Examples

MySQL:

SQL

SQL Server / Oracle / MS Access:

SQL

Note: Dropping a DEFAULT constraint is not supported in SQLite. To change a default value in SQLite, you must recreate the table with the new definition.

SQL DEFAULT Labs

Tutorials dojo strip