Re: Autoincremental value

From: Gaetano Mendola <mendola(at)bigfoot(dot)com>
To: adburne(at)asocmedrosario(dot)com(dot)ar
Subject: Re: Autoincremental value
Date: 2004-08-17 12:40:45
Message-ID: 4121FCCD.7050308@bigfoot.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

adburne(at)asocmedrosario(dot)com(dot)ar wrote:

> Estimado Mage,
>
> Con fecha viernes 13 de agosto de 2004, 16.54.09, escribió:
>
> M> adburne(at)asocmedrosario(dot)com(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message adburne 2004-08-17 12:53:18 Re: Autoincremental value
Previous Message adburne 2004-08-17 12:32:22 Re: Autoincremental value