mysqlはデータベースが存在するか、テーブルが存在するかを判断します.

2383 ワード

1、データベースが存在するかどうかを判断する
select * from information_schema.SCHEMATA where SCHEMA_NAME='hatc3500'

クエリーを曖昧にすることもできます.SQLは次のとおりです.
select * 
from information_schema.SCHEMATA 
where SCHEMA_NAME like '%              %'; 

2、判断表があるかどうか
select count(*) from information_schema.TABLES t where t.TABLE_SCHEMA ="    " and t.TABLE_NAME ="     ";
//     
select count(*) from information_schema.TABLES t where t.TABLE_SCHEMA='hatc3500' and t.TABLE_NAME='captest'