AdBlock Detected!
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.
SQL Default |
|
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: The SQL DEFAULT constraint automatically fills in a pre-set value for a column whenever an INSERT omits that column, preventing unintended NULLs and reducing the need for explicit values in every query.
and execute the following SQL statement, 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. Frequently Asked QuestionsQ: What is the SQL DEFAULT constraint? Q: Can you use a function as a DEFAULT value? Q: Can you change a DEFAULT constraint after a table is created? Q: Does DEFAULT override an explicit NULL insert? |
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.