建表语句是CREATE TABLE users ( id INT(11) NOT NULL AUTO_INCREMENT, username VARCHAR(50) NOT NULL, password VARCHAR(255) NOT NULL, email VARCHAR(100) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (id), UNIQUE KEY username (username), UNIQUE KEY email (email)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;。你插入的这个语句报错了,请重新写
时间: 2023-12-16 22:03:40 浏览: 188
非常抱歉,我的回答有误。以下是一个可以向上面的users表插入200000条数据的SQL语句,它与之前的SQL语句略有不同:
```
INSERT INTO users (username, password, email, created_at, updated_at)
SELECT
CONCAT('user', LPAD(n, 6, '0')),
MD5(CONCAT('password', LPAD(n, 6, '0'))),
CONCAT('user', LPAD(n, 6, '0'), '@example.com'),
NOW(),
NOW()
FROM
(SELECT @row_number:=@row_number+1 AS n FROM
(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t1,
(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t2,
(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t3,
(SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) t4,
(SELECT @row_number:=0) AS x
) numlist
LIMIT 200000;
```
这个SQL语句使用了一个嵌套的SELECT语句,生成了从1到200000的序列号,然后根据序列号生成了随机的用户名、密码和电子邮件信息,并将这些信息插入到users表中。这个SQL语句也增加了一个LIMIT子句,以限制插入的行数为200000行。
阅读全文