I have a table with not null column, How to set a null value in this column as default?
I mean, I want to do something like this:
postgres=# ALTER TABLE person ALTER COLUMN phone SET NULL;
but it shows:
postgres=# ALTER TABLE person ALTER COLUMN phone SET NULL;
ERROR: syntax error at or near "NULL"
LINE 1: ALTER TABLE person ALTER COLUMN phone SET NULL;
This question is related to
postgresql
null
postgresql-9.1
First, Set :
ALTER TABLE person ALTER COLUMN phone DROP NOT NULL;
Execute the command in this format
ALTER TABLE tablename ALTER COLUMN columnname SET NOT NULL;
for setting the column to not null.
Execute the command in this format:
ALTER [ COLUMN ] column { SET | DROP } NOT NULL
Source: Stackoverflow.com