问题提示!当我拼写正确时,问题就消失了!在MySQL存储过程中创建的临时表的范围
我有一个MySQL存储过程,它创建一个临时表。当我从mysql提示符调用过程时,它似乎运行成功,但是如果我从临时表中选择COUNT(*),则会出现一个错误消息,指出该表不存在。
在存储过程结束时,存储过程中创建的临时表是否会停止存在?
mysql> delimiter //
mysql> drop procedure if exists sp_temp_reciepts//
mysql> create procedure sp_temp_receipts()
begin
drop temporary table if exists receipts;
create temporary table receipts
( ... snip ...
);
insert into receipts
select ... snip ...
end//
mysql> delimiter ;
mysql> call sp_temp_reciepts();
Query OK, 46903 rows affected, 1 warning (2.15 sec)
mysql> select count(*) from receipts;
ERROR 1146 (42S02): Table 'receipts' doesn't exist
不,它仍然存在。你可以在这里包含代码吗?如果存在// 创建过程sp_temp_receipts sp_temp_reciepts – ethrbunny
分隔符// 下降过程() 开始 – user1956095
请编辑您原来的职位,包括代码。 – ethrbunny