1、判断数据库是否存在
(推荐教程:mysql数据库学习教程)
查询SQL如下:
select * from information_schema.SCHEMATA where SCHEMA_NAME = '需要查找的数据库名';
www#gaodaima.com来源gaodai#ma#com搞@代~码网搞代码
也可以模糊查询,SQL如下:
select * from information_schema.SCHEMATA where SCHEMA_NAME like '%需要查询的数据库名的部分名称%';
2、判断数据表是否存在
查询SQL如下:
select * from information_schema.TABLES where TABLE_NAME = '需要查询的数据表名';
也可以模糊查询,SQL如下:
select * from information_schema.TABLES where TABLE_NAME like '%需要查询的数据库名的部分名称%';
来源:搞代码网:原文地址:https://www.gaodaima.com