Re: not null
am 25.01.2003 12:51:48 von Philipp Ottlinger
ryanne cruz wrote:
>
> hi list.
>
> i have a column that has a "not null" as its modifier. is there a way that i
> can remove that? or better yet to make it a "serial not null"?
>
It depends on your entitiy-relationship schema - usually it makes sense
to define things as "not null" and it shouldn't be considered to be
taken away just by chance !!!
Usually you can alter the TABLE to remove such constraints ...
SERIAL - if I'm not too mistaken - is automatically maintained by
postgres as an implicit sequence whose values are generated by calling
sequence.nextval autonomously everytime you "need" a value!
Yours,
Phil
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
not null
am 25.01.2003 12:52:40 von ryanne cruz
hi list.
i have a column that has a "not null" as its modifier. is there a way that i
can remove that? or better yet to make it a "serial not null"?
thanks!
ryanne
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
Re: not null
am 25.01.2003 13:55:16 von Matthew Horoschun
Hi Ryanne,
As already suggested, a SERIAL is just an column that has a default of
the nextval() of an implicitly defined SEQUENCE.
So, try:
ALTER TABLE table_name ALTER COLUMN column_name SET DEFAULT
nextval('column_name_seq'::text);
CREATE SEQUENCE column_name_seq;
Cheers
Matthew.
On Saturday, January 25, 2003, at 10:52 PM, ryanne cruz wrote:
>
> hi list.
>
> i have a column that has a "not null" as its modifier. is there a way
> that i
> can remove that? or better yet to make it a "serial not null"?
--
Matthew Horoschun
Network Administrator
CanPrint Communications Pty. Ltd.
--
Matthew Horoschun
Network Administrator
CanPrint Communications Pty. Ltd.
Mobile: 0417 282 378
Direct: (02) 6295 4544
Telephone: (02) 6295 4422
Facsimile: (02) 6295 4473
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Re: not null
am 25.01.2003 13:59:59 von Matthew Horoschun
Hi Ryanne,
As already suggested, a SERIAL is just an column that has a default of
the nextval() of an implicitly defined SEQUENCE.
So, try:
ALTER TABLE table_name ALTER COLUMN column_name SET DEFAULT
nextval('column_name_seq'::text);
CREATE SEQUENCE column_name_seq;
Cheers
Matthew.
On Saturday, January 25, 2003, at 10:52 PM, ryanne cruz wrote:
>
> hi list.
>
> i have a column that has a "not null" as its modifier. is there a way
> that i
> can remove that? or better yet to make it a "serial not null"?
--
Matthew Horoschun
Network Administrator
CanPrint Communications Pty. Ltd.
--
Matthew Horoschun
Network Administrator
CanPrint Communications Pty. Ltd.
Mobile: 0417 282 378
Direct: (02) 6295 4544
Telephone: (02) 6295 4422
Facsimile: (02) 6295 4473
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly