Re: is it easy to change the create sequence algorithm?

From: Andrew Hammond <drew(at)xyzzy(dot)dhs(dot)org>
To: Kevin Brannen <kevinb(at)nurseamerica(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: is it easy to change the create sequence algorithm?
Date: 2002-06-21 21:34:59
Message-ID: 3D139C03.4090503@xyzzy.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Well, the quickest solution I can think of off hand is to not use
SERIAL. Instead, do it manually, like this:

DROP SEQUENCE my_seq;

CREATE SEQUENCE my_seq;

DROP TABLE my_table;

CREATE TABLE my_table (

my_table_id INTEGER DEFAULT nextval('my_seq') PRIMARY KEY,

...

);

Kevin Brannen wrote:

> I see in the docs that when I create a column that is of type SERIAL,
> the engine automatically creates the sequence for me, named
> TABLE_COLUMN_seq. That's great until the table name + column name
> lengths are > 27 chars, then it starts chopping, and you guessed it, I
> have multiple table/column combinations that don't differ until after
> that length.
>
> Is there a way to influence the "create sequence" generator with a
> directive, hint, set value, whatever, to be something else? (e.g.
> COLUMN_seq if I guarantee all the columns are unique)
>
> Yes I know that I could create the sequence myself, but the engine
> does such a good job. :-)
>
> Thanks,
> Kevin
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Kris 2002-06-22 10:30:04 Obtaining primary key information from pg system tables
Previous Message Josh Berkus 2002-06-21 20:43:22 Re: is it easy to change the create sequence algorithm?