DELIMITER $$
CREATE PROCEDURE insert_user (IN i_no CHAR(11),i_id CHAR,i_open CHAR(64))
BEGIN
INSERT INTO user (id, open, no) VALUES (i_id, i_open, i_no);
END $$
DELIMITER;
DELIMITER $$
CREATE PROCEDURE delete_user ( IN i_id CHAR ) BEGIN
DELETE FROM user WHERE id = i_id;
END $$
DELIMITER;
DELIMITER $$
CREATE PROCEDURE update_user (IN i_no CHAR(11),i_id CHAR,i_open CHAR(64))
BEGIN
UPDATE user SET id = i_id,no = i_no WHERE open = i_open;
END $$
DELIMITER;
DELIMITER $$
CREATE PROCEDURE select_user (IN i_no CHAR(11))
BEGIN
SELECT * FROM user WHERE no = i_no;
END $$
DELIMITER;
call insert_user(13497944000,0,'2aBmONorQK5YunfWN1AK');
call delete_user(0);
call update_user(13497944111,0,'2aBmONorQK5YunfWN1AF');
call select_user(13497944000);
DROP PROCEDURE IF EXISTS create_table_proc;
DELIMITER ;;
CREATE PROCEDURE create_table_proc(IN n INT)
BEGIN
DECLARE i INT DEFAULT(1);
WHILE (i <= n) DO
SET @sqlStr:=CONCAT("CREATE TABLE `student",i,"` (
`id` int(11) NOT NULL DEFAULT '0',
`nm` varchar(32) NOT NULL DEFAULT '',
`sub` varchar(32) NOT NULL DEFAULT '',
`grade` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
PREPARE stmt from @sqlStr;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET i = i + 1;
END WHILE;
END
;;
DELIMITER ;
CALL create_table_proc(3)