1.判断数据库中表是否存在
string strsql = "select count(1) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='hfslog' and TABLE_NAME='" + TableName + "'";
例如:
select count(1) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='hfslog' and TABLE_NAME='datflow20170812';
2.判断表中字段是否存在
string sql = "select count(*) from information_schema.columns where table_name = '"+tableName+"' and column_name = '"+columnName+"'";
例如:
select count(*) from information_schema.columns where table_name = 'datflow20170810' and column_name = 'id'
更多内容请访问:IT源点
注意:本文归作者所有,未经作者允许,不得转载