
在MySQL存储过程中创建临时表的语法如下:
CREATE PROCEDURE yourProcedureName()
BEGIN
CREATE TEMPORARY TABLE yourTemporaryTableName SELECT yourValue;
ENDLet 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
PbootCMS是一款高效、简洁、强悍的开源PHP企业网站开发建设管理系统。 PbootCMS 1.1.8 更新日志:2018-08-07 1.修复提交表单多选字段接收数据问题; 2.修复登录过程中二次登陆在页面不刷新时验证失败问题; 3.新增搜索结果fuzzy参数来控制是否模糊匹配; 4.新增父分类,顶级分类名称及链接独立标签,具体见手册; 5.新增内容多图拖动排序功能。
243
现在您可以调用上述存储过程来创建一个临时表 −
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 过程中创建临时表?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号