본문 바로가기
database/Mysql

Mysql 더미 데이터 만드는 쿼리

by 무대포 개발자 2017. 11. 24.
728x90
반응형

<b><span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;">주의사항 : CREATE PROCEDURE ~ END 까지 커서로 전체 선택해서 Ctrl + Enter 눌러야 생성됨.</span></b><br />

<span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;"><br /></span>

<span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;">DROP PROCEDURE IF EXISTS loopInsert</span><br />

<span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;"><br /></span>

<span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;">CREATE PROCEDURE loopInsert()&nbsp;</span><br />

<span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;">BEGIN</span><br />

<span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;"><span style="white-space: pre;"> </span>DECLARE i INT DEFAULT 1;</span><br />

<span style="white-space: pre;"><span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;">  </span></span><br />

<span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;"><span style="white-space: pre;"> </span>WHILE i &lt;= 500 DO</span><br />

<span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;"><span style="white-space: pre;">  </span>Insert into TABLE_NAME (ColumnA, ColumnB) VALUES(i, 컬럼 값);</span><br />

<span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;"><span style="white-space: pre;">  </span>SET i = i + 1;</span><br />

<span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;"><span style="white-space: pre;"> </span>END WHILE;</span><br />

<span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;">END</span><br />

<span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;"><br /></span>

<span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;">CALL loopInsert()</span><br />

<div style="font-family: &quot;맑은 고딕&quot;, sans-serif; font-size: 13px;">

<br /></div>



'database > Mysql' 카테고리의 다른 글

create mysql dummy data (MySQL 더미 데이터 만들기)  (0) 2020.07.10
Mysql recursive query (재귀쿼리)  (0) 2017.12.14

댓글