您好,欢迎访问一九零五行业门户网

在 MySQL 过程中创建临时表?

在mysql存储过程中创建临时表的语法如下:
create procedure yourprocedurename() begin create temporary table yourtemporarytablename select yourvalue; end
let us implement the above syntax to create a temporary table and insert some records in the table. following is the query to create a stored procedure and a temporary table in it −
mysql> delimiter //mysql> create procedure create_temporary_table() -> begin -> create temporary table tmpdemotable select 500; -> end//query ok, 0 rows affected (0.15 sec)
以下是在表中插入记录的查询:
mysql> create procedure insert_record_intemptable() -> begin -> insert into tmpdemotable values (300); -> end//query ok, 0 rows affected (0.06 sec)
mysql> delimiter
现在您可以调用上述存储过程来创建一个临时表 −
mysql> call create_temporary_table();query ok, 1 row affected (0.00 sec)mysql> call insert_record_intemptable();query ok, 1 row affected (0.00 sec)
使用select语句显示表中的所有记录 −
mysql> select *from tmpdemotable;
输出这将产生以下输出 −
+-----+| 500 |+-----+| 500 || 300 |+-----+2 rows in set (0.00 sec)
以上就是在 mysql 过程中创建临时表?的详细内容。
其它类似信息

推荐信息