What is the use of default in SQL?

Last Update: Apr 27, 2024 |

V

Vikram Reddy

Use of Default in SQL

DEFAULT is used to provide a default value to a column in SQL that case when there is no value specified by the user, in SQL DEFAULT is a constraint.


Default Example With Query

Here we are going to make the SQL DEFAULT constraint more understanding with the query example. Let's suppose, we are creating a SQL TABLE with the name of Employee with DEFAULT.


CREATE TABLE Employee  (

   E_ID int NOT NULL,

   E_NAME varchar (100) NOT NULL,

   E_EMAIL varchar (100),

   E_ADDRESS char (200),

   E_SALARY decimal (100, 3) DEFAULT 10000,

   E_AGE Int NOT NULL,

   PRIMARY KEY(E_ID)

);

1 votes

Your Answer

Email Us: advertise@gdatamart.com

Donate Us: Support to GDATAMART

LifeStyle & Fun

© 2024 GDATAMART.COM (All Rights Reserved)