建表示例:
create table user(`id` bigint(11) not null auto_increment,`user_id` bigint(11) not null comment '用户 ID',`username` varchar(45) not null comment '登录名',`email` varchar(30) not null comment '邮箱',`nickname` varchar(45) not null comment '昵称',`avatar` int(11) not null comment '头像',`birthday` date not null comment '生日',`gender` tinyint(4) default '0' comment '性别',`intro` varchar(150) default null comment '简介',`resume_url` varchar(300) not null comment '简历存放地址',`register_ip` int not null comment '用户注册时的源 IP',`review_status` tinyint not null comment '审核状态,1-通过,2-审核中,3-未通过,4-尚未提交审核',`create_time` timestamp not null comment '记录创建的时间',`update_time` timestamp not null comment '资料修改的时间',primary key (`id`),unique key `idx_user_id` (`user_id`),key `idx_username`(`username`),key `idx_create_time`(`create_time`, `review_status`))engine = InnoDBdefault charset = utf8comment = '用户基本信息';
字符集
| ASCII | 单字节编码,7位表示一个字符,共128字符 |
|---|---|
| GBK | 双字节编码,共收录21003个汉字 |
| UTF-8 | Unicode标准的可变长度字符编码,使用1-3个字节为每个字符编码 |
| uttf8mb4 | 四字节编码,应用场景用于存储四字节编码的emoji表情 |
