检查表是否存在于mysql中

检查表是否存在于mysql中

问题描述:

可能重复:
MySQL-检查表是否存在而不使用"select from"

Possible Duplicate:
MySQL - check if table exists without using "select from"

我可以依靠此查询来查找指定数据库中的表是否存在或可能存在一些限制吗?

Can I rely on this query to find out if tables in the specified database exists or there may be some restrictions?

SELECT
    `information_schema`.`TABLES`.`TABLE_NAME`
FROM
    `information_schema`.`TABLES`
WHERE
    `information_schema`.`TABLES`.`TABLE_SCHEMA` = 'my_database_name'
AND `information_schema`.`TABLES`.`TABLE_NAME` IN (
    'table_name',
    'table_name',
    'table_name',
    'table_name',
    'table_name',
    'table_name'
)

P.S. 我不需要创建表,只需要检查它是否存在.

P.S. I do not need to create a table, and just need to check whether it exists or not.

或者您可以使用它(更长的查询时间).

Or you could use this (longer query).

SELECT count(*)
FROM information_schema.tables
WHERE table_schema = 'databasename'
AND table_name = 'tablename'