开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜