Re: Autoincremental value

Поиск
Список
Период
Сортировка
От Gaetano Mendola
Тема Re: Autoincremental value
Дата
Msg-id 4121FCCD.7050308@bigfoot.com
обсуждение исходный текст
Ответ на Re: Autoincremental value  (adburne@asocmedrosario.com.ar)
Ответы Re: Autoincremental value  (adburne@asocmedrosario.com.ar)
Список pgsql-general
adburne@asocmedrosario.com.ar wrote:

> Estimado Mage,
>
> Con fecha viernes 13 de agosto de 2004, 16.54.09, escribió:
>
> M> adburne@asocmedrosario.com.ar wrote:
>
>
>>>when insert rows:
>>>
>>>insert into table1 (field1) values (1);
>>>insert into table1 (field1) values (1);
>>>insert into table1 (field1) values (2);
>>>
>>>and then select * from table1, you get:
>>>field1| field2
>>>------+-------
>>> 1   |  1
>>> 1   |  2
>>> 2   |  1
>>>------+-------
>>>
>>>
>
> M> Do you mean:
>
>
> M>  field1| field2
> M>  ------+-------
> M>    1   |  1
> M>    1   |  2
> M>    2   |  3
> M>  ------+-------
>
> M> You need the serial type.
>
> M>           Mage
>
>
> Thnx to everybody for your answers; you put the finger on the key =), in
> mysql you can create a mixed autoincremental on 2 fields, then the first
> act as key and the second field is autoincremental based on the first
> field. Like I wrote in the prev msg.
>
> field1| field2
> ------+-------
>   1   |  1
>   1   |  2
>   2   |  1
> ------+-------
>
> I was reading about serial type but I didn't find anything to do this
> like mysql.

Did you see the other posts in this threads ? What you can do with MySQL
surelly you can do with Postgres, don't forget features that MySQL
doesn't have that in Postgresq can help you to obtain the same result.
Of course in Postgresql you have to write you own trigger, this means
however to have a for example a unique serial for values: 1,2,3,4 and
another serial for value: 4,5,6,7   ( note the 4 repeated twice just to
made it more difficult ). The solutions proposed can easily solve this problem,
could you do this in MySQL ?


Regards
Gaetano Mendola










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

Предыдущее
От: adburne@asocmedrosario.com.ar
Дата:
Сообщение: Re: Autoincremental value
Следующее
От: adburne@asocmedrosario.com.ar
Дата:
Сообщение: Re: Autoincremental value