建表示例:

    1. create table user
    2. (
    3. `id` bigint(11) not null auto_increment,
    4. `user_id` bigint(11) not null comment '用户 ID',
    5. `username` varchar(45) not null comment '登录名',
    6. `email` varchar(30) not null comment '邮箱',
    7. `nickname` varchar(45) not null comment '昵称',
    8. `avatar` int(11) not null comment '头像',
    9. `birthday` date not null comment '生日',
    10. `gender` tinyint(4) default '0' comment '性别',
    11. `intro` varchar(150) default null comment '简介',
    12. `resume_url` varchar(300) not null comment '简历存放地址',
    13. `register_ip` int not null comment '用户注册时的源 IP',
    14. `review_status` tinyint not null comment '审核状态,1-通过,2-审核中,3-未通过,4-尚未提交审核',
    15. `create_time` timestamp not null comment '记录创建的时间',
    16. `update_time` timestamp not null comment '资料修改的时间',
    17. primary key (`id`),
    18. unique key `idx_user_id` (`user_id`),
    19. key `idx_username`(`username`),
    20. key `idx_create_time`(`create_time`, `review_status`)
    21. )
    22. engine = InnoDB
    23. default charset = utf8
    24. comment = '用户基本信息';

    字符集

    ASCII 单字节编码,7位表示一个字符,共128字符
    GBK 双字节编码,共收录21003个汉字
    UTF-8 Unicode标准的可变长度字符编码,使用1-3个字节为每个字符编码
    uttf8mb4 四字节编码,应用场景用于存储四字节编码的emoji表情