• 技术文章 >数据库 >PostgreSQL

    PostgreSQL如何判断字段是否存在

    月亮邮递员月亮邮递员2020-03-27 18:13:28原创5795

    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 字段 是否存在
    品易云
    上一篇:VB怎么连接PostgreSQL 下一篇:PostgreSQL怎么延时执行

    相关文章推荐

    • 如何查看PostgreSQL中的表• VB怎么连接PostgreSQL

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网