Default Constraint | DEFAULT Constraint in SQL - sql - sql tutorial - learn sql

 default constraint
  • The DEFAULT constraint is used to provide a default value for a column.
  • The default value will be added to all new records IF no other value is specified.
  • The DEFAULT constraint provides a default value to a column when the INSERT INTO does not provide a specific value.
  • For example, if we create a table as below:
(Employee_ID integer Unique, 
Last_Name varchar (30), 
First_Name varchar (30), 	
Score Integer DEFAULT 80);
  • and execute the following SQL statement
INSERT INTO Employee (Employee_ID, Last_Name, First_Name) VALUES (10, 'Johnson', 'Rick');
  • The table will look like the following
Employee _ID Last_Name First_Name Score
10 Johnson Rick 80
  • 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.

This tutorial provides more the basic needs and informations on sql tutorial , pl sql tutorial , mysql tutorial , sql server , sqlcode , sql queries , sql , sql formatter , sql join , w3schools sql , oracle tutorial , mysql , pl sql , learn sql , sql tutorial for beginners , sql server tutorial , sql query tutorial , oracle sql tutorial , t sql tutorial , ms sql tutorial , database tutorial , sql tutorial point , oracle pl sql tutorial , oracle database tutorial , oracle tutorial for beginners , ms sql server tutorial , sql tutorial pdf

Related Searches to DEFAULT Constraint in SQL