From: | Chris Angelico <rosuav(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Best way to create unique primary keys across schemas? |
Date: | 2012-01-25 06:18:30 |
Message-ID: | CAPTjJmqKRNBpPAh9PbwOAjhLYjyzThZ=t4bx1FOaZjQkO5o5=A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Jan 25, 2012 at 9:54 AM, panam <panam(at)gmx(dot)net> wrote:
> What do you mean with "explicit sequence object"? An own sequence for each
> table per schema?
This:
On Wed, Jan 25, 2012 at 10:23 AM, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
> Barring domains, you can just manually apply the default instead of
> using a serial type:
>
> create table foo (gid bigint default nextval('global_seq'));
http://www.postgresql.org/docs/9.1/static/sql-createsequence.html
When you create a 'serial' column, Postgres creates a sequence and
makes the column as 'int' with a default that pulls from the sequence.
(Similarly for 'bigserial' and 'bigint'.) If you create the sequence
yourself, you get a bit more control over it (eg setting
min/max/step), and can name it appropriately.
Note the OWNED BY clause (as documented in the above link). That's
what I was saying about the sequence being owned by or linked to the
creating table.
ChrisA
From | Date | Subject | |
---|---|---|---|
Next Message | Achilleas Mantzios | 2012-01-25 07:52:34 | Re: Incomplete startup packet help needed |
Previous Message | Peter Geoghegan | 2012-01-25 06:04:17 | Re: any plans to support more rounding methods in sql? |