mysql常用sql语句

wylc123 1年前 ⋅ 1658 阅读

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源点

相关文章推荐

全部评论: 0

    我有话说: