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

finding my schema (for sequences)

P: n/a
I am used to creating sequences separately and using them for default
values instead of using the serial type. I am not sure why... but that's the
way I have been doing it. Maybe I don't trust the generated names.
I should probably just get over it, but anyhow...

Let's say I am writing a file for creating a database. Say ...

-- schematest
CREATE SEQUENCE foo_id_seq;
CREATE TABLE foo(
id integer
PRIMARY KEY
DEFAULT nextval('foo_id_seq'),
xx text
);
I want to be able to ...

lee=# drop schema beta cascade;
DROP SCHEMA
lee=# create schema beta;
CREATE SCHEMA
lee=# set search_path to beta;
SET
lee=# \i schematest
CREATE SEQUENCE
CREATE TABLE
The problem is that unlike a comparable serial column, my default value
does not qualify the sequence with the right schema name.

Is there a way to do that, such that my schematest file does not need to
know which schema I am loading the file into?

Or should I just get over my aversion to serial?

__________________________________________________ _______________
Working moms: Find helpful tips here on managing kids, home, work and
yourself. http://special.msn.com/msnbc/workingmom.armx
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.