mysql 랜덤 데이터 넣기 프로시저

6
/* 1만 */
DELIMITER $$

DROP PROCEDURE IF EXISTS TEST_INSERT_DATA$$

CREATE TABLE `t_contents` (
  `c_no` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `c_title` varchar(100) DEFAULT NULL,
  `c_text` text,
  PRIMARY KEY (`c_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE PROCEDURE TEST_INSERT_DATA()

BEGIN

DECLARE i INT DEFAULT 1;
WHILE i <= 10000 DO
INSERT INTO `t_contents` VALUE(NULL,CONCAT(DATE_FORMAT(NOW(), "%Y %c/%e %r"),'_',RAND()*899999999+100000000),CONCAT(DATE_FORMAT(NOW(), "%Y %c/%e %r"),'_',RAND()*899999999+100000000,'_',RAND()*899999999+100000000,'_',RAND()*899999999+100000000));
SET i = i + 1;
END WHILE;
END$$
DELIMITER $$

CALL TEST_INSERT_DATA();

/* 5만 */

CREATE TABLE `t_tags` (
  `t_no` int(10) unsigned DEFAULT NULL,
  `c_no` int(10) unsigned DEFAULT NULL,
  `t_tag` varchar(100) DEFAULT NULL,
  KEY `t_no` (`t_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8


DELIMITER $$

DROP PROCEDURE IF EXISTS TEST_INSERT_TAGS$$

CREATE PROCEDURE TEST_INSERT_DATA()

BEGIN

DECLARE i INT DEFAULT 1;
WHILE i <= 50000 DO
INSERT INTO `t_tags` VALUE(NULL,RAND()*10000,CONCAT('tag_',RAND()*100));
SET i = i + 1;
END WHILE;
END$$
DELIMITER $$

CALL TEST_INSERT_TAGS();


루프 1만번, 5만번

댓글
  • No Nickname
    No Comment
  • 권한이 없습니다.
    {{m_row.m_nick}}
    -
목록형 📅 달력형