470,624 Members | 2,175 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,624 developers. It's quick & easy.

pgadmin 3

In pgadmin3 I'm tring to add auto_inc column like this

ALTER TABLE public.modems ADD COLUMN id serial;

But get this error :

NOTICE: ALTER TABLE will create implicit sequence "modems_id_seq" for "serial" column "modems.id"

ERROR: adding columns with defaults is not implemented
HINT: Add the column, then use ALTER TABLE SET DEFAULT.
How to add auto_inc fields... thanx

PS. Can I use OID column for primary/foreign functionality, or it
has some restriction ...i mean i may not use auto_inc field ?

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #1
2 2528
Hello,
try alter table modems add column id serial set default

Set default tells postgres to automatically fill in the column data using a sequence on your behalf.

OID could be used for primary key I suppose. To use as a foreign key you would manually have to somehow copy the value in table A and insert into B. AFAIK system generated OIDS are unique to each table.

HTH

mike
In pgadmin3 I'm tring to add auto_inc column like this

ALTER TABLE public.modems ADD COLUMN id serial;

But get this error :

NOTICE: ALTER TABLE will create implicit sequence "modems_id_seq" for "serial" column "modems.id"

ERROR: adding columns with defaults is not implemented
HINT: Add the column, then use ALTER TABLE SET DEFAULT.
How to add auto_inc fields... thanx

PS. Can I use OID column for primary/foreign functionality, or it
has some restriction ...i mean i may not use auto_inc field ?

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #2
On Wed, Jul 21, 2004 at 12:06:09AM -0500, Mike G wrote:
OID could be used for primary key I suppose. To use as a foreign key
you would manually have to somehow copy the value in table A and
insert into B. AFAIK system generated OIDS are unique to each table.
WRONG. OIDs are not guarenteed unique. They are not suitable for
primary keys. They will wrap eventually. They are not indexed in any
way unless you create an index yourself.

Use serials from primary keys, much safer...
--
Martijn van Oosterhout <kl*****@svana.org> http://svana.org/kleptog/ Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
tool for doing 5% of the work and then sitting around waiting for someone
else to do the other 95% so you can sue them.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFA/wkkY5Twig3Ge+YRApi7AJ9PmHl6mYqXHeULgPGFT+vzj33+WgC eMwUF
d7Y6WNiCg09LHGwK8MsuaIk=
=yR+m
-----END PGP SIGNATURE-----

Nov 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Matthew T. O'Connor | last post: by
1 post views Thread by EgyŁd Csaba | last post: by
2 posts views Thread by mmd | last post: by
1 post views Thread by raptor | last post: by
2 posts views Thread by Vic Cekvenich | last post: by
reply views Thread by Laurent Duperval | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.