MySQL 临时表 SELECT COUNT(*) 返回不同的结果
我在 mysql 中遇到临时表问题。我创建了这个临时表:
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_general_detalle_entrada_salida (
numero_registro INT(10),
numero_admision INT(10),
id_referencia INT(10),
facturable CHAR(1),
fecha_acceso DATE,
cod_via INT(10),
anexo2 VARCHAR(40),
anexo3 VARCHAR(40),
cod_bodega CHAR(3),
id_centro_costo INT(10),
cod_medico INT(10),
cantidad FLOAT(15,2),
precio_venta_bruto FLOAT(15,2),
descuento FLOAT(15,2),
precio_venta_neto FLOAT(15,2),
copago FLOAT(15,2),
consumido CHAR(1)
)ENGINE = INNODB;
当我在临时表上执行简单的 select count(*) from tmp_general_detalle_entrada_salida
时,查询返回随机值 (5, 4, 5, 5, 0, 'table does'不存在”等)。我正在使用 mysql 5.0.51b 和 PHP 5.2.6。
I have a problem with temporary tables in mysql. I created this temporary table:
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_general_detalle_entrada_salida (
numero_registro INT(10),
numero_admision INT(10),
id_referencia INT(10),
facturable CHAR(1),
fecha_acceso DATE,
cod_via INT(10),
anexo2 VARCHAR(40),
anexo3 VARCHAR(40),
cod_bodega CHAR(3),
id_centro_costo INT(10),
cod_medico INT(10),
cantidad FLOAT(15,2),
precio_venta_bruto FLOAT(15,2),
descuento FLOAT(15,2),
precio_venta_neto FLOAT(15,2),
copago FLOAT(15,2),
consumido CHAR(1)
)ENGINE = INNODB;
When I do a simple select count(*) from tmp_general_detalle_entrada_salida
on the temporary table, the query returns random values (5, 4, 5, 5, 0, 'table doesn't exist', etc). I'm working with mysql 5.0.51b and PHP 5.2.6.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不断变化的数字看起来就像数据在您的选择之间发生了变化。该表不存在表示您的连接在选择之间已关闭。当连接关闭时,临时表就会消失。
您可以尝试运行
这会将连接中的每个查询记录到选择/tmp/mysql.log。这将使您更深入地了解服务器所看到的内容。
The changing numbers makes it seem as the data is mutating between your selects. The table does not exist indicates your connection was closed in between selects. Temporary tables go away when your connection closes.
You could try running
This will log every single query from connections to selects /tmp/mysql.log. This will give you more insight to what the servers seeing.