How to set Default value of table field to 0.00?
I have created a table named "salary_mst" in MySql database.开发者_StackOverflow 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 ?
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 |
+----+------+--------+
精彩评论