上次说到每张表示例数据100条左右,用sql语句给我
时间: 2024-05-05 19:16:02 浏览: 103
生成100条数据的示例,可以使用以下SQL语句:
```sql
SELECT
t1.id,
CONCAT('user', t1.id) AS username,
CONCAT('user', t1.id, '@example.com') AS email,
CONCAT('123', t1.id) AS password,
t1.gender,
t1.age,
t1.address,
t1.phone_number,
t1.created_at,
t1.updated_at
FROM (
SELECT 1 AS id, 'male' AS gender, 20 AS age, 'Beijing' AS address, '12345678901' AS phone_number, NOW() AS created_at, NOW() AS updated_at
UNION ALL
SELECT 2 AS id, 'female' AS gender, 22 AS age, 'Shanghai' AS address, '12345678902' AS phone_number, NOW() AS created_at, NOW() AS updated_at
) t1
CROSS JOIN (
SELECT 1 AS n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10
) t2
ORDER BY t1.id, t2.n;
```
以上SQL语句会生成两条示例数据,其中一条id为1,另一条id为2。每条数据会生成10条重复数据,以生成100条数据。可以根据需要修改其中的字段和数据。
阅读全文