日期:2014-05-16  浏览次数:21382 次

MySQL 如何判断一个临时表是否存在?
MySQL 如何判断一个临时表是否存在?

------解决方案--------------------
不同的连接不能检测到临时表码
不能,你是要检测同一个临时表吧,是session级的。
MYSQL HELP:
You can use the TEMPORARY keyword when creating a table. A TEMPORARY table is visible only to the current connection, and is dropped automatically when the connection is closed. This means that two different connections can use the same temporary table name without conflicting with each other or with an existing non-TEMPORARY table of the same name. (The existing table is hidden until the temporary table is dropped.)
------解决方案--------------------
你可以直接设置该用户账号的 MAX_USER_CONNECTIONS = 1 就可以了。


SQL code
mysql> CREATE USER 'francis'@'localhost' IDENTIFIED BY 'frank';
mysql> GRANT ALL ON customer.* TO 'francis'@'localhost'
    ->     WITH MAX_QUERIES_PER_HOUR 20
    ->          MAX_UPDATES_PER_HOUR 10
    ->          MAX_CONNECTIONS_PER_HOUR 5
    ->          MAX_USER_CONNECTIONS 2;