如何创建一个临时表并使用一列和100000行,并使用像473824hdhdas这样的唯一随机值填充每一行?
谢谢!
答案 0 :(得分:3)
您可以使用:
SELECT REPLACE(UUID(), '-', '')
FROM
(SELECT
(two_1.id + two_2.id + two_4.id +
two_8.id + two_16.id) AS id
FROM
(SELECT 0 AS id UNION ALL SELECT 1 AS id) AS two_1
CROSS JOIN (SELECT 0 id UNION ALL SELECT 2 id) AS two_2
CROSS JOIN (SELECT 0 id UNION ALL SELECT 4 id) AS two_4
CROSS JOIN (SELECT 0 id UNION ALL SELECT 8 id) AS two_8
CROSS JOIN (SELECT 0 id UNION ALL SELECT 16 id) AS two_16
) AS init
-- set your limit to needed count of rows
LIMIT 100000
-it will generate字母数字唯一的行集。要创建表格,只需使用corresponding syntax。
更新。由于对十六进制生成的值有一些疑问,只需修改:
SELECT
CONCAT(
CONV(SUBSTR(uuid, 1, 8), 16, 36),
CONV(SUBSTR(uuid, 9, 8), 16, 36),
CONV(SUBSTR(uuid, 17, 8), 16, 36),
CONV(SUBSTR(uuid, 25, 8), 16, 36)
) as rnd
FROM
(SELECT
REPLACE(UUID(), '-', '') AS uuid,
(two_1.id + two_2.id + two_4.id +
two_8.id + two_16.id) AS id
FROM
(SELECT 0 AS id UNION ALL SELECT 1 AS id) AS two_1
CROSS JOIN (SELECT 0 id UNION ALL SELECT 2 id) AS two_2
CROSS JOIN (SELECT 0 id UNION ALL SELECT 4 id) AS two_4
CROSS JOIN (SELECT 0 id UNION ALL SELECT 8 id) AS two_8
CROSS JOIN (SELECT 0 id UNION ALL SELECT 16 id) AS two_16
) AS init
LIMIT 100000
-now all 36 letters:0-9
,A-Z