I'd like to update all records with 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.
A:
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.
StarShip3000
2009-11-06 18:11:10
In the future you may want to put a constraint on these columns to keep them from being allowed to be empty strings.
StarShip3000
2009-11-06 18:13:59
@StarShip3000 this is data brought in from another database. No foreign keys, no constraints of any sort.....
Matt Haley
2009-11-06 23:50:22