use school;
create table if not exists info (
id int(4) zerofill primary key auto_increment,
#指定主键的第二种方式
name varchar(10) not null,
cardid int(18) not null unique key,
hobby varchar(50));
#if not exists:表示检测要创建的表是否存在,如果不存在就继续创建
#int(4) zerofill:表示若数值不满四位数,则前面用“0”填充,如0001
#auto_increment:表示此字段为自增长字段,即每条记录自动递增1,默认从1开始递增,自增长字段不可以重复,自增长字段必须是主键,如添加的记录数据没有指定此字段的值且添加失败也会自动递增
#unique key:表示此字段唯一键约束,此字段不可以重复:一张表中只能有一个主键,但是一张表中可以有多个唯一键
#not null:表示此字段不允许为null
mysql指定主键的第二种方式
最新推荐文章于 2025-03-20 21:09:02 发布