By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Add not null column in a table

P: 10
Hi again

I have another question, I would like to add NOT NULL column in my table. I have done like this :

ALTER TABLE patent ALTER COLUMN patent_pri_date SET NOT NULL;

but it doesn't work and give the following error :
ERROR: ALTER TABLE: Attribute "patent_pri_date" contains NULL values

is any body can help me how can i add NOT NULL column to my table ?, I use postgresql 7.4. Thank you very much.

Best regards,
Bogie
Sep 13 '07 #1
Share this Question
Share on Google+
6 Replies


Expert 100+
P: 700
Hi again

I have another question, I would like to add NOT NULL column in my table. I have done like this :

ALTER TABLE patent ALTER COLUMN patent_pri_date SET NOT NULL;

but it doesn't work and give the following error :
ERROR: ALTER TABLE: Attribute "patent_pri_date" contains NULL values

is any body can help me how can i add NOT NULL column to my table ?, I use postgresql 7.4. Thank you very much.

Best regards,
Bogie

I looks like there are rows in which pri_date column contans NULLS values. U should fill it first.
Sep 13 '07 #2

amitpatel66
Expert 100+
P: 2,367
Hi again

I have another question, I would like to add NOT NULL column in my table. I have done like this :

ALTER TABLE patent ALTER COLUMN patent_pri_date SET NOT NULL;

but it doesn't work and give the following error :
ERROR: ALTER TABLE: Attribute "patent_pri_date" contains NULL values

is any body can help me how can i add NOT NULL column to my table ?, I use postgresql 7.4. Thank you very much.

Best regards,
Bogie
You can add NOT NULL columns to a table only if the table is EMPTY and does not contain any ROW.
Sep 13 '07 #3

Expert 100+
P: 700
You can add NOT NULL columns to a table only if the table is EMPTY and does not contain any ROW.
I in version 8.* u can add not null on a column if it does not contain null values. Maybe I'm wrong but in earlier versions it's looks the same.
Sep 13 '07 #4

P: 15
attention......
attention......
attention......
attention......
attention......
Sep 14 '07 #5

amitpatel66
Expert 100+
P: 2,367
I in version 8.* u can add not null on a column if it does not contain null values. Maybe I'm wrong but in earlier versions it's looks the same.
Yes It is possible to make the COLUMN NOT NULL in case if it does not contain any NULL value
Sep 14 '07 #6

P: 10
I looks like there are rows in which pri_date column contans NULLS values. U should fill it first.

Hi

Thank you very much for the advice, it works.

Best regards,
Bogie
Sep 18 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.