在存储过程中创建一个表,并使用INSERT-mysql> DELIMITER //
mysql> CREATE PROCEDURE create_TableDemo(id int,name varchar(100),age int)
BEGIN
CREATE TABLE DemoTable
(
ClientId int NOT NULL,
ClientName varchar(30),
ClientAge int,
PRIMARY KEY(ClientId)
);
INSERT INTO DemoTable VALUES(id,name,age);
SELECT *FROM DemoTable;
END
//
mysql> DELIMITER ;
使用CALL命令调用存储过程-mysql> CALL create_TableDemo(100,'Robert',28);
这将产生以下输出-+----------+------------+-----------+
| ClientId | ClientName | ClientAge |
+----------+------------+-----------+
| 100 | Robert | 28 |
+----------+------------+-----------+
1 row in set (0.76 sec)