On Fri, 2 Feb 2001, Alex Howansky wrote:
>
> What's the simplest way to add a not null constraint to a field in an existing
> table? It doesn't seem that alter table supports it -- that I'll have to create
> a new table and copy into it. Is that correct? TIA,
You can also do something to the system catalogs as a superuser to set
attnotnull to true in pg_attribute for the particular attribute you want.
Something like:
update pg_attribute set attnotnull='t' where
pg_attribute.attrelid=pg_class.oid and pg_class.relname=<table> and
attname=<attribute>;