13

I'm new to PostgreSQL and that is why I'm asking this question. I have a table app_client_users and a column named client_id. Initially I set it as NOT NULL and now I would like to change it to allow NULL. I've tried

alter table app_client_users alter column client_id int NULL ;

and

alter table app_client_users alter column client_id NULL ;

which is not working. How can I fix it?

András Váczi
31.8k13 gold badges103 silver badges152 bronze badges
asked Jan 3, 2017 at 5:58
1
  • 1
    Please be aware that psql is a client to PostgreSQL, not a nickname of the latter. Commented Jan 3, 2017 at 11:30

1 Answer 1

20

You can simply drop NOT NULL

ALTER TABLE app_client_users ALTER COLUMN client_id DROP NOT NULL;
András Váczi
31.8k13 gold badges103 silver badges152 bronze badges
answered Jan 3, 2017 at 7:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.