题解 | #创建一张新表#
创建一张新表
https://www.nowcoder.com/practice/a61ee5519d14444aa99e530309a8e043
create table
if not exists user_info_vip (
id int (11) primary key auto_increment comment '自增ID',
uid int (11) unique not null comment '用户ID',
nick_name varchar(64) comment '昵称',
achievement int (11) default 0 comment '成就值',
level int (11) comment '用户等级',
job varchar(32) comment '职业方向',
register_time datetime default current_timestamp comment '注册时间'
) character set utf8 collate utf8_general_ci
--创建新表,如果存在则覆盖 drop table [if exists] 表名; --创建新表,如果存在则返回 create table [if not exists] 表名 -- 不存在才创建,存在就跳过 (<列名1> <数据类型> -- 列名和类型必选 [ primary key -- 可选的约束,主键 | foreign key -- 外键,引用其他表的键值 | auto_increment -- 自增ID | comment <注释> -- 列注释(评论) | default <值> -- 默认值 | unique -- 唯一性约束,不允许两条记录该列值相同 | not null -- 该列非空,输入空会报错 | current_timestamp -- 当前时间戳 ], ... ) [character set <字符集名>] -- 字符集编码 [collate <校对规则名>] -- 列排序和比较时的规则(是否区分大小写等)
没啥好说的,复习一下建表的语句
查看11道真题和解析
顺丰集团工作强度 293人发布