帮我用Mysql创建一个名为user的表,共有六个字段分别为id、name、age、phone、address、or
时间: 2023-05-20 11:07:28 浏览: 112
der,其中id为自增主键,name为varchar类型,age为int类型,phone为varchar类型,address为varchar类型,order为int类型。以下是创建表的 SQL 语句:
CREATE TABLE `user` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户ID',
`name` varchar(20) DEFAULT NULL COMMENT '用户名',
`age` int(11) DEFAULT NULL COMMENT '年龄',
`phone` varchar(20) DEFAULT NULL COMMENT '电话号码',
`address` varchar(50) DEFAULT NULL COMMENT '地址',
`order` int(11) DEFAULT NULL COMMENT '排序',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
相关问题
帮我用Mysql生成user的表的20条测试数据,user表共有六个字段分别为id、name、age、phone、address、or
der,可以使用以下SQL语句生成:
INSERT INTO `user` (`id`, `name`, `age`, `phone`, `address`, `order`) VALUES
(1, 'John', 25, '12345678901', 'Beijing', 1),
(2, 'Alice', 30, '13987654321', 'Shanghai',2),
(3, 'Mike', 23, '15876543210', 'Guangzhou', 3),
(4, 'Sarah', 27, '13798765432', 'Chengdu', 4),
(5, 'Tom', 29, '15009876543', 'Hangzhou', 5),
(6, 'Kate', 26, '13345678901', 'Nanjing', 6),
(7, 'Bob', 28, '18909876543', 'Shenzhen', 7),
(8, 'Lucy', 32, '13876543210', 'Xi\'an', 8),
(9, 'David', 24, '15109876543', 'Wuhan', 9),
(10, 'Julia', 31, '13698765432', 'Chongqing', 10),
(11, 'Jack', 22, '13309876543', 'Tianjin', 11),
(12, 'Lily', 33, '18676543210', 'Changsha', 12),
(13, 'Alex', 29, '13809876543', 'Nanning', 13),
(14, 'Eva', 27, '13598765432', 'Harbin', 14),
(15, 'Nick', 28, '13709876543', 'Urumqi', 15),
(16, 'Grace', 25, '15276543210', 'Lanzhou', 16),
(17, 'Jason', 24, '13609876543', 'Kunming', 17),
(18, 'Kelly', 30, '13498765432', 'Xiamen', 18),
(19, 'Will', 32, '15309876543', 'Zhengzhou', 19),
(20, 'Oliver', 31, '13909876543', 'Nanchang', 20);
这段SQL语句将会生成20条user表的示例数据,你可以将其复制粘贴到你的MySQL客户端中执行。
阅读全文