data dependent sequences?

Поиск
Список
Период
Сортировка
От Stuart McGraw
Тема data dependent sequences?
Дата
Msg-id AKEFJAHAPDBEDKIICNJKMEJPCDAA.smcg2297@frii.com
обсуждение исходный текст
Ответы Re: data dependent sequences?  (Ragnar <gnari@hive.is>)
Re: data dependent sequences?  (chester c young <chestercyoung@yahoo.com>)
Список pgsql-sql
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?



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Andrej Ricnik-Bay"
Дата:
Сообщение: Re: Converting from MS Access field aliases
Следующее
От: Ragnar
Дата:
Сообщение: Re: data dependent sequences?