From: Stuart McGraw <smcg2297@frii.com>
To: pgsql-sql@postgresql.org
Subject: data dependent sequences?
Date: Sun, 15 Jul 2007 09:28:26 -0600
Message-ID: <AKEFJAHAPDBEDKIICNJKMEJPCDAA.smcg2297@frii.com> (raw)
Advice requested :-) I have a table like:
CREATE TABLE items (
id INT,
typ INT ...
PRIMAY KEY (seq,typ));
I would like 'id' to be like a SERIAL except that I
want independent sequences for each value of 'typ'.
So if 'items' is:
id typ
----+-----
1 'a'
2 'a'
3 'a'
1 'b'
then doing:
INSERT items(typ) VALUES('a');
INSERT items(typ) VALUES('b');
will result in:
id typ
----+-----
1 'a'
2 'a'
3 'a'
1 'b'
4 'a'
2 'b'
Because there can be dozens of values of 'typ'
and new ones added not infrequently, creating
a postgresql sequence for each seems awkward.
Are there other ways I could accomplish this?
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: smcg2297@frii.com
Subject: Re: data dependent sequences?
In-Reply-To: <AKEFJAHAPDBEDKIICNJKMEJPCDAA.smcg2297@frii.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox