本文介绍了mysql遇到information_schema.tables的麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-edit2- 3小时后,仍然存在相同的问题.我正在使用noinstall存档软件包.-edit-也许有人可以告诉我一种检查表是否存在的更好方法?

-edit2- 3hrs later and still have the same problem. I am using the noinstall archive package.-edit- maybe someone can tell me a better way to check if a table exist?

我的库中有一个函数来检查是否存在一个表,该表过去我曾问过要怎么做.

I have a function in my lib to check if a table exist which i asked how to do in the past.

我删除了数据库,然后再次创建了它.我的代码没有正确创建表.调试后,我决定编写以下内容.

I deleted my database and created it again. My code didnt create the tables properly. After debugging i decided to write the below.

mysql> SELECT table_schema, table_name FROM information_schema.tables WHERE tabl
e_schema = 'mydb' AND table_name='ApprovePost';
+--------------+-------------+
| table_schema | table_name  |
+--------------+-------------+
| mydb         | ApprovePost |
+--------------+-------------+
1 row in set (0.00 sec)

很奇怪... mydb被删除并再次创建(我写了drop database mydb;create database mydb;.应该消失了吗?).让我们找出存在的东西

Weird... mydb was dropped and created again (i wrote drop database mydb; and create database mydb;. It should be gone?). Lets find out what exists

mysql> SELECT table_schema, table_name FROM information_schema.tables WHERE tabl
e_schema = 'mydb';
Empty set (0.00 sec)

我不仅不知道为什么第一条语句显示的表破坏了我的代码,而且我不知道为什么它不显示任何表(在该数据库中).

Not only do i not know why the first statement shows tables which is wrecking my code, i dont know why this is not showing any tables (in that database).

注意:数据库都应该是innodb.另外,这是全新的Windows安装,我可能配置有误.

note: The databases should all be innodb. Also this is a fresh windows install and i may have configured something wrong.

奖金怪异.

mysql> drop database mydb;
ERROR 1008 (HY000): Can't drop database 'mydb'; database doesn't exist
mysql> SELECT table_schema, table_name FROM information_schema.tables WHERE tabl
e_schema = 'mydb';
Empty set (0.00 sec)

mysql> SELECT table_schema, table_name FROM information_schema.tables WHERE tabl
e_schema = 'mydb' AND table_name='ApprovePost';
+--------------+-------------+
| table_schema | table_name  |
+--------------+-------------+
| mydb         | ApprovePost |
+--------------+-------------+
1 row in set (0.00 sec)

推荐答案

好像您需要对INFORMATION_SCHEMA.TABLES使用FLUSH TABLES命令以反映现有表.

Looks like you need to use the FLUSH TABLES command for the INFORMATION_SCHEMA.TABLES to reflect existing tables.

参考:

这篇关于mysql遇到information_schema.tables的麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 10:00