Temporary Tables Not Working in PHPMyAdmin

谁说我不能喝 提交于 2019-12-06 04:01:44

问题


I run this query

CREATE TEMPORARY TABLE usercount SELECT * FROM users

I get this message

Your SQL query has been executed successfully ( Query took 0.1471 sec )

But when I try to access the newly created table using

SELECT * FROM usercount

I get this error

#1146 - Table 'abc_site.usercount' doesn't exist

Not sure why, I need to mention that I've did a good share of googling beforehand.

My version of PHPMyAdmin is 3.5.2.2 and MySQL 5.5.27


回答1:


PHPMyAdmin (or rather PHP) closes the database connection after each screen. Thus your temporary tables disappear.

You can put multiple SQL statements in the SQL query box in PHPMyAdmin; this should be executed as one block and thus the temporary table is not deleted.




回答2:


Temporary tables are temparar and after use thay Delete. for example ,when insert data into database , first we can insert into temp table and thus when complete transaction , then insert into main table.

EXAMPLE :
//------------------------------------------
CREATE TEMPORARY TABLE TEMP
(
USERNAME VARCHAR(50) NOT NULL,
PASSWORD VARCHAR(50) NOT NULL,
EMAIL varchar(100),
TYPE_USER INT
);
INSERT INTO TEMP VALUES('A','A','A','1');
SELECT * FROM TEMP
//-----------------------------------------
Show A,A,A,1


来源:https://stackoverflow.com/questions/14426401/temporary-tables-not-working-in-phpmyadmin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!