默认约束 default

default :初始值设置,插入记录时,如果没有明确为字段赋值,则自动赋予默认值。 
例子:
create table tb6(
   id int primary key auto_increment,
   name varchar(20) not null,
   age int not null default 18
);
#删除default
mysql> alter table tb6
    -> modify age int;

mysql> alter table tb6
    -> modify age int default 20;

猜你喜欢

转载自www.cnblogs.com/mariobear/p/9180181.html