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

sequences not renamed with tables

P: n/a
CSN
I'm getting these errors when importing dumps:

ERROR: relation "table1_id_seq" does not exist
ERROR: relation "table2_id_seq" does not exist

I renamed a couple tables, and the names of their
corresponding sequences remained the same. This causes
a problem because when importing - the create table
statements create sequences with different names, then
the setval() statements use the old names. Any way to
automatically avoid this "gotcha"?

Thanks,
CSN
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I renamed a couple tables, and the names of their
corresponding sequences remained the same. This causes
a problem because when importing - the create table
statements create sequences with different names, then
the setval() statements use the old names. Any way to
automatically avoid this "gotcha"?


Don't rely on the create table to make the sequences for
you: declare them yourself. Instead of this:

CREATE TABLE foobar (
id SERIAL
);

Try this:

CREATE SEQUENCE barbell_seq;

CREATE TABLE foobar (
id INTEGER NOT NULL DEFAULT nextval('barbell_seq')
);

- --
Greg Sabino Mullane gr**@turnstep.com
PGP Key: 0x14964AC8 200312172134

-----BEGIN PGP SIGNATURE-----

iD8DBQE/4RJjvJuQZxSWSsgRAgEdAJ9y4eDaQENuRWVRETJdLu/vKO5PggCeKLjs
dkPyceUBRMkTbvcqMBAgLr4=
=5b5j
-----END PGP SIGNATURE-----

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.