mysql批量生成测试数据

mysql通过存储过程可以生成海量数据:

代码如下:

-- 创建测试表

DROP TABLE t1;

CREATE TABLE t1(

id INT unsigned NOT NULL AUTO_INCREMENT,

name VARCHAR(20) NOT NULL,

status TINYINT unsigned NOT NULL DEFAULT 1,

PRIMARY KEY(id)

);

-- 添加数据

DROP PROCEDURE insert_t1;

DELIMITER //

CREATE PROCEDURE insert_t1()

BEGIN

DECLARE num INT;

SET num=1;

SET autocommit=0;

WHILE num < 10000000 DO

IF (num{46ef1d7cfbdffc0db57029f974d30095d18ea60dba1d7b2ffaf442b213727085}10000=0) THEN

COMMIT;

END IF;

INSERT INTO t1 VALUES(NULL, 'XXXXXXXX', 1);

SET num=num+1;

END WHILE;

COMMIT;

SET autocommit=1;

END //

DELIMITER ;

CALL insert_t1();

你可能感兴趣的:(oracle,mysql,redis,sqlserver)