+ 1

How to set default value?

28th Mar 2016, 3:20 PM
tarun kumar
tarun kumar - avatar
3 odpowiedzi
+ 3
You can assign a default value when creating the fields to a table incase an insert statement is ran and a value is not assigned to that field(eg Salary in my query ) 5000 will be assigned to the field. Also ID cannot be left blank in a insert statement on the example below 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) );
28th Apr 2016, 8:40 AM
Brian Kamau
Brian Kamau - avatar
+ 2
To add to what Brian Kamau has said, if you don't set a default value and if NOT NULL is **not** mentioned, then the default value will be NULL.
4th Sep 2016, 7:09 AM
Nagarajan Chinnasamy
Nagarajan Chinnasamy - avatar
+ 1
anything u want bro taking data type in consideration
14th Jul 2016, 7:46 PM
manish rawat
manish rawat - avatar