- 查看数据库有无某张表
select t.table_name from information_schema.TABLES t where t.TABLE_SCHEMA ='databaseName' and t.TABLE_NAME ='tableName';
有则返回表明, 无则返回空
- 查看某张表是否包含某个字段
select count(1) from information_schema.columns t where t.TABLE_SCHEMA = 'databaseName' and table_name = 'tableName' and column_name = 'columnName';
有则返回1, 无则返回0