+ 1
How to set default value?
3 Antworten
+ 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)
);
+ 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.
+ 1
anything u want bro taking data type in consideration