189 8069 5689

PostgreSQL判断字段是否存在的方法-创新互联

创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!

怒江州ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!

小编给大家分享一下PostgreSQL判断字段是否存在的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

PostgreSQL如何判断字段是否存在

方法一:

select count(*) from information_schema.columns WHERE table_schema = 'table_schema'
     and table_name = 'table_name' and column_name = 'column_name';

方法二:

select * from information_schema.columns WHERE table_schema = 'table_schema' 
    and table_name = 'table_name' and column_name = 'column_name';

补充:

判断表是否存在:

select count (*) from information_schema.tables WHERE table_schema = 'table_schema' 
    and table_name = 'table_name';
    
select * from information_schema.tables WHERE table_schema = 'table_schema' 
    and table_name = 'table_name';

看完了这篇文章,相信你对PostgreSQL判断字段是否存在的方法有了一定的了解,想了解更多相关知识,欢迎关注创新互联-成都网站建设公司行业资讯频道,感谢各位的阅读!


当前文章:PostgreSQL判断字段是否存在的方法-创新互联
标题URL:http://cdxtjz.cn/article/ddodcs.html

其他资讯