开发者

Set all empty strings to NULL in all records of all tables in PostgreSQL

开发者 https://www.devze.com 2022-12-11 05:36 出处:网络
I\'d like to update all records wi开发者_如何学Goth an empty string in all columns of all tables in PostgreSQL. Is there a way to do this with a query? Or at least how to query for all columns that do

I'd like to update all records wi开发者_如何学Goth an empty string in all columns of all tables in PostgreSQL. Is there a way to do this with a query? Or at least how to query for all columns that don't have a NOT NULL constraint.


Visit the information_schema like this

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

From that data you can generate yourself update statements for all the tables and columns.

0

精彩评论

暂无评论...
验证码 换一张
取 消