SQL > Constraint > DEFAULT Constraint

The DEFAULT constraint provides a default value to a column when the INSERT INTO statement does not provide a specific value. For example, if we create a table as below:

(Student_ID integer Unique,
Last_Name varchar (30),
First_Name varchar (30),
Score Integer DEFAULT 80);

and execute the following SQL statement,

INSERT INTO Student (Student_ID, Last_Name, First_Name) VALUES (10, 'Johnson', 'Rick');

The table will look like the following:


Even though we didn't specify a value for the "Score" column in the INSERT INTO statement, it does get assigned the default value of 80 since we had already set 80 as the default value for this column.

Next: SQL UNIQUE Constraint

This page was last updated on April 13, 2022.

Copyright © 2022   1keydata.com   All Rights Reserved     Privacy Policy     About   Contact