Clickhouse查询某个字段以什么结尾
发布网友
发布时间:2022-04-10 09:13
我来回答
共1个回答
热心网友
时间:2022-04-10 10:42
可用如下方式查询数据库中的数据表的id/name
selectidfromsysobjectswherename='数据表的名称’查询数据库中字段的id/name
selectidfromsyscolumnswherename='字段名’查询一个数据表中是否有某个字段
selectcount(1)fromsyscolumnswhere[name]=字段名and
[id]=object_id(数据表名)publicstaticbool
ColumnExists(stringtableName,stringcolumnName){
stringsql="selectcount(1)fromsyscolumnswhere[id]=object_id("+tableName+"')and[name]="+columnName+"";
objectres=GetSingle(sq);
if(res==nul){
returnfalse;}
returnConvert.ToInt32(res)O;publicstaticobjectGetSingle(stringSQLString)
using(SqIConnectionconnection=new
SqIConnection(connectionString
SqIConnection(connectionString)(using(SqIcommandcmd=newSqIcommand(sQLString,
connection))(tryl
connection.Open();
objectobj=cmd.ExecuteScalar();
if((object.Equals(obj,nul)Il(object.Equals(obj,System.DBNul.Value))){
returnnull;}elsel
returnobj;}}