Mysql一条快速插入测试数据的sql
Mysql快速插入测试数据
真的很好用很方便,复制到sqlyog
把F9
(执行sql的快捷点)往死里按吧!
INSERT INTO `sys_project` ( `proj_name`, `dept_val`, `created`, `updated` ) VALUES (SUBSTRING(MD5(RAND()),1,10), (SELECT dval FROM sys_dept ORDER BY RAND() LIMIT 1), NOW(), NOW());
上面的sql的表结构是这样的:
[sys_dept] [sys_project] dval----\ proj_id \ proj_name \-------dept_val created updated
(SUBSTRING(MD5(RAND()),1,10)
用来产生一个长度为10的随机字符串
(SELECT dval FROM sys_dept ORDER BY RAND() LIMIT 1)
用来从sys_dept
表随机抽取一个dval
的值作为sys_project
的外键
相关推荐
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11
世樹 2020-11-11