1、通过information_schema查询数据库是否存在某张表

select t.table_name from information_schema.TABLES t where t.TABLE_SCHEMA ='".$database."' and t.TABLE_NAME ='".$table."';
$database:查询的数据库
$table :查询表格

返回:若存在则返回表名,不存在返回为空

 2、判断表中一个字段是否存在

select count(*) from information_schema.columns where table_name = '表名' and column_name = '字段名'

select count(*) from information_schema.columns where table_name = 't_iov_vehicle_owner_info' and column_name = 'id'

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-22
  • 2021-10-30
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
相关资源
相似解决方案