适用于在当前数据库中查询另一数据库中的表是否存在,
即知道数据库、表名,确定该表是否存在于该数据中
表名:tableName
数据库:databaseName
sql如下:
可以查出表名和数据库名
SELECT DISTINCT t.table_name, d.SCHEMA_NAME FROM information_schema.TABLES t, information_schema.SCHEMATA d WHERE t.table_name = 'tableName' AND d.SCHEMA_NAME = 'databaseName';
count表名,如果返回1则存在该表,返回0不存在
SELECT count(*) FROM information_schema.tables WHERE table_schema = 'open' AND table_name = 'open_api_access_log_2021_51' AND table_type = 'BASE TABLE'