标签:varchar rem ref username 数据 for date sign div
--由于users_info表创建的时候,添加了外键约束,所以,小伙伴们测试的话,建议先建个角色表roles CREATE TABLE roles( role_id smallint unsigned primary key auto_increment, #角色id role_name varchar(20) not null unique #角色名称 )ENGINE=InnoDB DEFAULT CHARSET=utf8; -- 创建用户信息表 role_id字段没设默认值 CREATE TABLE `users_info` ( `user_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(20) NOT NULL, `passwd` char(60) NOT NULL, `phone_number` varchar(11) DEFAULT NULL, `email` varchar(60) DEFAULT NULL, `role_id` smallint(5) unsigned, `create_time` datetime NOT NULL default now(), PRIMARY KEY (`user_id`), UNIQUE KEY `username` (`username`), KEY `fk_role_id` (`role_id`), CONSTRAINT `fk_role_id` FOREIGN KEY (`role_id`) REFERENCES `roles` (`role_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- 插入几条测试数据 insert into roles(role_name) values(‘初始注册角色‘); insert into users(username,passwd,phone_number,email) values(‘张三‘,md5(‘123456‘),‘13700008888‘,‘7654321@qq.com‘)
标签:varchar rem ref username 数据 for date sign div
原文地址:https://www.cnblogs.com/zyh0430/p/11921317.html