From: | louis gonzales <gonzales(at)linuxlouis(dot)net> |
---|---|
To: | Rhys Stewart <rhys(dot)stewart(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: not so sequential sequences |
Date: | 2006-10-18 03:49:59 |
Message-ID: | 4535A467.8080103@linuxlouis.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Rhys,
You could create a sequence, then make the "seq" attribute to your table
have a default value of:
seq integer default nextval('your_sequence')
Then every time an insert is done into your table, the "seq" will
increment. You alternatively could make your "insert" statement have
for that position, the nextval('your_sequence')
Does that help?
Rhys Stewart wrote:
> Hi all, looking for a method to number a table sequentially, but the
> sequence only increments if the value in a certain column is
> different. as in
>
>
> seq | parish
> ------------------------
> 1 | Kingston
> 1 | Kingston
> 1 | Kingston
> 1 | Kingston
> 2 | Lucea
> 3 | Morant Bay
> 3 | Morant Bay
> 3 | Morant Bay
> 4 | Port Antonio
> 5 | Savannah-La-Mar
> 5 | Savannah-La-Mar
> 5 | Savannah-La-Mar
>
> so i guess i would order by a certain column and then the 'magic
> sequence' would be a column that only increments when the column
> changes.
>
> Rhys
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
--
Email: louis(dot)gonzales(at)linuxlouis(dot)net
WebSite: http://www.linuxlouis.net
"Open the pod bay doors HAL!" -2001: A Space Odyssey
"Good morning starshine, the Earth says hello." -Willy Wonka
From | Date | Subject | |
---|---|---|---|
Next Message | roopa perumalraja | 2006-10-18 04:49:55 | Postgres Database Slow |
Previous Message | Edward Macnaghten | 2006-10-18 03:23:41 | Re: Maximum size of database |