Probleme on ALTER

Started by Mickaël Jouanneover 25 years ago3 messagesgeneral
Jump to latest
#1Mickaël Jouanne
m.jouanne@apr-job.com

Hello !

I have this table :

Attribute | Type | Modifier
-----------------+--------------+---------------------------------------
ref | integer | default nextval('cvdb_ref_seq'::text)
nom | varchar(50) |
prenom | varchar(50) |
email | varchar(100) |
password | varchar(20) |

but i forgot to do "NOT NULL" on the fields.

I try ALTER table ALTER COLUMN ref ADD CONSTRAINT NOT NULL but it doesn't work.

Does someone have the right solution ?

thanks for answer.

--

Micka�l JOUANNE
Webmaster / Developpeur / Support Technique

APR-Job &
www.jobscout24.fr - Meet your future
_____________________________________

HumanLine France SAS
32, rue Pierret
92200 Neuilly

tel: +33 1 42 44 40 73
fax: +33 1 49 26 09 76
ICQ: 42799256
m.jouanne@humanline.fr

#2Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Mickaël Jouanne (#1)
Re: Probleme on ALTER

In 7.0, you have to go into pg_attribute and set
attnotnull manually and make sure that there already
isn't null data. In 7.1, you can do the above or
you should be able to just add a table check constraint.

BTW: Was the alter you tried something you'd seen in
another database or just a guess? I've been wondering
about appropriate syntax for that since I haven't
seen one in sql92 (other than adding a table constraint
that checks the column against null).

Stephan Szabo
sszabo@bigpanda.com

On Wed, 8 Nov 2000, [iso-8859-1] Micka���l Jouanne wrote:

Show quoted text

Hello !

I have this table :

Attribute | Type | Modifier
-----------------+--------------+---------------------------------------
ref | integer | default nextval('cvdb_ref_seq'::text)
nom | varchar(50) |
prenom | varchar(50) |
email | varchar(100) |
password | varchar(20) |

but i forgot to do "NOT NULL" on the fields.

I try ALTER table ALTER COLUMN ref ADD CONSTRAINT NOT NULL but it doesn't work.

Does someone have the right solution ?

#3Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Mickaël Jouanne (#1)
Re: Probleme on ALTER

Forgot the simplest solution though, make a new table
with the correct structure and insert the data into it
and rename them into the right place :)