PostgreSQL如何判断字段是否存在

570次阅读
没有评论

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教程

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:postgresql2022-12-02发表,共计679字。
新手QQ群:570568346,欢迎进群讨论 Python51学习