Home >Database >Mysql Tutorial >How to set default value in mysql
Mysql method of setting the default value: Use mysql to create a data table and set the default value. The code is [stuSex varchar(2) default 'male' check(stuSex in('male', 'female'))].
Mysql method to set the default value:
create table stu( stuId varchar(30) primary key, stuName varchar(50) not null, stuSex varchar(2) default '男' check(stuSex in('男', '女')), stuJg varchar(30), stuDept varchar(40) )
Use mysql to create a data table and set the default value:
int type: default 1; (add the value directly)
varchar type: default 'aaa' (use single quotes)
Another: After testing, in mysql, default should be written in before checking, otherwise an error will be reported
More related free learning recommendations:mysql tutorial(Video)
The above is the detailed content of How to set default value in mysql. For more information, please follow other related articles on the PHP Chinese website!