查看mysql数据库是否存在某张表及某张表是否存在某个字段


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'

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM