mysql存储过程中创建表的例子,内容如下:
mysql> delimiter $$ mysql> mysql> mysql> CREATE PROCEDURE myProc() //创建存储过程myProc -> BEGIN -> DECLARE i INT DEFAULT 1; -> -> SET autocommit=0; -> -> DROP TABLE IF EXISTS test_table ; //删除存在的表 -> CREATE TABLE test_table ( //创建表 -> id INT PRIMARY KEY, -> some_data VARCHAR(30)) -> ENGINE=innodb; -> -> END$$ Query OK, 0 rows affected (0.00 sec) mysql> mysql> delimiter ; mysql> call myProc(); Query OK, 0 rows affected, 1 warning (0.08 sec) mysql> drop procedure myProc; Query OK, 0 rows affected (0.00 sec) mysql> desc test_table; +-----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+-------+ | id | int(11) | NO | PRI | | | | some_data | varchar(30) | YES | | NULL | | +-----------+-------------+------+-----+---------+-------+ 2 rows in set (0.00 sec) mysql> drop table test_table; Query OK, 0 rows affected (0.03 sec) mysql>