<b><span style="font-family: "courier new" , "courier" , monospace;">주의사항 : CREATE PROCEDURE ~ END 까지 커서로 전체 선택해서 Ctrl + Enter 눌러야 생성됨.</span></b><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">DROP PROCEDURE IF EXISTS loopInsert</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">CREATE PROCEDURE loopInsert() </span><br />
<span style="font-family: "courier new" , "courier" , monospace;">BEGIN</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>DECLARE i INT DEFAULT 1;</span><br />
<span style="white-space: pre;"><span style="font-family: "courier new" , "courier" , monospace;"> </span></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>WHILE i <= 500 DO</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>Insert into TABLE_NAME (ColumnA, ColumnB) VALUES(i, 컬럼 값);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>SET i = i + 1;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>END WHILE;</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">END</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">CALL loopInsert()</span><br />
<div style="font-family: "맑은 고딕", 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 |
댓글