代码之家  ›  专栏  ›  技术社区  ›  Matt Haley

在PostgreSQL中所有表的所有记录中将所有空字符串设置为空。

  •  2
  • Matt Haley  · 技术社区  · 15 年前

    我想用一个空字符串更新PostgreSQL中所有表的所有列中的所有记录。有没有一种方法可以通过查询来做到这一点?或者至少如何查询没有非空约束的所有列。

    1 回复  |  直到 15 年前
        1
  •  2
  •   Kuberchaun    15 年前

    像这样访问信息模式

    select * 
    from information_schema.columns
    where is_nullable = 'YES';
    

    从这些数据中,您可以为所有表和列生成更新语句。