Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Aravind GovindarajRank #430 · 5.8K reputationPosted Nov 21, 2022, 8:55 AM EST
please refer this url https://www.w3schools.com/sql/sql_default.asp
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Nov 22, 2022, 1:18 AM EST
https://www.c-sharpcorner.com/UploadFile/f0b2ed/constraints-in-sql-server/
https://www.c-sharpcorner.com/blogs/sql-constraints
https://www.c-sharpcorner.com/article/an-easy-way-to-understand-constraints-in-sql-server/
Vishal YelveRank #178 · 13.6K reputationPosted Nov 25, 2022, 2:31 AM EST
The DEFAULT constraint provides a default value to a column when the INSERT INTO statement does not provide a specific value.
Example
For example, the following SQL creates a new table called CUSTOMERS and adds five columns. Here, the SALARY column is set to 5000.00 by default, so in case the INSERT INTO statement does not provide a value for this column, then by default this column would be set to 5000.00.
CREATE TABLE CUSTOMERS( ID INT NOT NULL, NAME VARCHAR (20) NOT NULL, AGE INT NOT NULL, ADDRESS CHAR (25) , SALARY DECIMAL (18, 2) DEFAULT 5000.00, PRIMARY KEY (ID) );If the CUSTOMERS table has already been created, then to add a DEFAULT constraint to the SALARY column, you would write a query like the one which is shown in the code block below.
ALTER TABLE CUSTOMERS
MODIFY SALARY DECIMAL (18, 2) DEFAULT 5000.00;Drop Default Constraint
To drop a DEFAULT constraint, use the following SQL query.
ALTER TABLE CUSTOMERS ALTER COLUMN SALARY DROP DEFAULT;Brahma Prakash ShuklaRank #633 · 3.8K reputationPosted Nov 25, 2022, 8:53 AM EST
https://www.w3schools.com/sql/sql_default.asp