PostgreSQL判断字段是否存在的方法
小编给大家分享一下PostgreSQL判断字段是否存在的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!
PostgreSQL如何判断字段是否存在
方法一:
selectcount(*)frominformation_schema.columnsWHEREtable_schema='table_schema'andtable_name='table_name'andcolumn_name='column_name';
方法二:
select*frominformation_schema.columnsWHEREtable_schema='table_schema'andtable_name='table_name'andcolumn_name='column_name';
补充:
判断表是否存在:
selectcount(*)frominformation_schema.tablesWHEREtable_schema='table_schema'andtable_name='table_name';select*frominformation_schema.tablesWHEREtable_schema='table_schema'andtable_name='table_name';
看完了这篇文章,相信你对PostgreSQL判断字段是否存在的方法有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。