mysql> SET @x = '刘王张赵李钱朱何孙曾陈吴黄刘邓周毛江胡';
Query OK, 0 rows affected (0.00 sec)
mysql> set @len1=char_length(@x);
Query OK, 0 rows affected (0.00 sec)
mysql> set @m1='依秋香巧花紫萱莉玉芳菊碧丽念雅红燕艳莲荷蕾紫莹颖琪';
Query OK, 0 rows affected (0.00 sec)
mysql> set @len2=char_length(@m1);
Query OK, 0 rows affected (0.00 sec)
mysql> set @m2='澄德海超阳昌瀚亮锋涵煦杰俊诚毅峰衍浩广邈言博畅';
Query OK, 0 rows affected (0.00 sec)
mysql> set @len3=char_length(@m2);
Query OK, 0 rows affected (0.00 sec)
mysql> set@xb=floor(rand()*2);
Query OK, 0 rows affected (0.01 sec)
mysql> set@xh='191100';
Query OK, 0 rows affected (0.00 sec)
mysql> set@xing=substring(@x,floor(rand()*@len1)+1,1);
Query OK, 0 rows affected (0.00 sec)
mysql> set@ming1=substring(@m1,floor(rand()*@len2)+1,1);
Query OK, 0 rows affected (0.00 sec)
mysql> set@xm1=concat(@xing,@ming1);
Query OK, 0 rows affected (0.01 sec)
mysql> set@xing=substring(@x,floor(rand()*@len1)+1,1);
Query OK, 0 rows affected (0.00 sec)
mysql> set@ming2=substring(@m2,floor(rand()*@len3)+1,1);
Query OK, 0 rows affected (0.00 sec)
mysql> set@xm2=concat(@xing,@ming2);
Query OK, 0 rows affected (0.00 sec)
mysql> create table xs1 as select 学号,姓名,性别 from xs where 1=2;
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> set @xm=if(@xb=0,@xm2,@xm1);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into xs1(学号,姓名,性别)values(@xh,@xm,if(@xb=0,'男','女'));
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> set@xing4=substring(@x,floor(rand()*@len1)+1,1);
Query OK, 0 rows affected (0.00 sec)
mysql> set@ming4=substring(@m2,floor(rand()*@len3)+1,1);
Query OK, 0 rows affected (0.00 sec)
mysql> set@xm3=concat(@xing4,@ming4);
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO xs1 (学号, 姓名, 性别) VALUES ('191101', @xm3, @xb);
Query OK, 1 row affected (0.00 sec)
mysql> select *from xs1;
+--------+------+------+
| 学号 | 姓名 | 性别 |
+--------+------+------+
| 191101 | 江言 | 0 |
| 191100 | 江俊 | 0 |
+--------+------+------+
2 rows in set (0.00 sec)
MySQL16
于 2024-05-20 17:05:51 首次发布