serial nextval() question

Поиск
Список
Период
Сортировка
От Jean-Christian Imbeault
Тема serial nextval() question
Дата
Msg-id 3D5CC1D1.80907@mega-bucks.co.jp
обсуждение исходный текст
Ответы Re: serial nextval() question  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-general
I have the following table def:

create table TMP_LI (

cart_id                 integer         references TMP_CART(id),
li_id                   integer         not null,
shop_id                 integer         references CHARISMA_SHOPS(id),
prod_id                 char(12)        references PRODUCTS(id),
quantity                int2            not null,
price                   integer         not null,

primary key (cart_id, li_id)
);

I'd like to have li_id be an serial but not for the whole table, only as
li_id relates to cart_id ... i.e. I'd like li_id to increment relative
to cart_id so that I can generate sequences of the kind:

cart_id      li_id
1         1
1         2
1         3
2         1
2
    2

How could I do this?

Thanks!

Jc


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

Предыдущее
От: mixo
Дата:
Сообщение: last entry
Следующее
От: Manfred Koizar
Дата:
Сообщение: Re: performance with triggers depends on table size?