I have created a table named "salary_mst" in MySql database. Table fields are
id -> auto increment
name -> varchar(50)
salary -> double
Now if someone don't insert value in salary, it should store default 0.00 How can I do that ?
right click on your database -- select design--select required column--in column properties, general tab you will see the "default value or binding". Mention 0 here.
ALTER TABLE `table` ADD COLUMN `column` FLOAT(10,2) NOT NULL DEFAULT '0.00'
create table salary_mst (
id int not null primary key auto_increment,
name varchar(50),
salary double not null default 0
);
To test:
insert into salary_mst (name) values ('foo');
select * from salary_mst;
+----+------+--------+
| id | name | salary |
+----+------+--------+
| 1 | foo | 0 |
+----+------+--------+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With