Is MySQL Temporary table a shared resource?(MySQL 临时表是共享资源吗?)
问题描述
我有一个使用临时表的 MySQL 存储过程.假设我的表名是temp",我用它来存储一些中间数据.它会在程序开始时创建,并在程序结束时删除.
I have a MySQL stored procedure that uses a temporary table. Assume that my table name is 'temp' and I use it to store some middle data. It will create at the beginning of procedure, and will drop at the end.
CREATE PROCEDURE p()
BEGIN
CREATE TEMPORARY TABLE `temp`(...);
INSERT INTO `temp` VALUES(...);
DROP TEMPORARY TABLE `temp`;
END;
问题是这个存储过程可能被不同的用户同时使用,所以我想知道这是否会导致任何问题(即临时表中插入数据的任何冲突).换句话说,临时表是对同一 SP 的不同调用中的共享资源吗?
The problem is that this stored procedure may be used by different users concurrently, so I want to know if this can cause any problems (i.e. any conflict in inserted data in temp table). In other word is temp table a shared resource within different calls to the same SP?
推荐答案
不,临时表仅限于您的数据库连接范围.在同一个数据库连接期间,您可以在对过程的后续调用中使用临时表,但其他连接无法访问它.他们可以创建一个同名的表,但每个临时表都是独立的.当您关闭连接时,临时表会消失.
No, a temp table is limited to the scope of your database connection. You can use the temp table in subsequent calls to the procedure during the same database connection, but other connections cannot access it. They can create a table by the same name, but each temp table will be independent. Temp tables go away when you close your connection.
这篇关于MySQL 临时表是共享资源吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL 临时表是共享资源吗?


- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- SQL 临时表问题 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01