pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedis it easy to change the create sequence algorithm?
3+ messages / 3 participants
[nested] [flat]
* is it easy to change the create sequence algorithm?
@ 2002-06-19 00:16 Kevin Brannen <kevinb@nurseamerica.net>
0 siblings, 2 replies; 3+ messages in thread
From: Kevin Brannen @ 2002-06-19 00:16 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: is it easy to change the create sequence algorithm?
@ 2002-06-21 20:43 Josh Berkus <josh@agliodbs.com>
parent: Kevin Brannen <kevinb@nurseamerica.net>
1 sibling, 0 replies; 3+ messages in thread
From: Josh Berkus @ 2002-06-21 20:43 UTC (permalink / raw)
To: Kevin Brannen <kevinb@nurseamerica.net>; pgsql-sql
Kevin,
> 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.
This would require hacking the Postgres source code.
Sure you don't wanna just create the sequences manually?
If you're sure, post your question to psql-Hackers to find out where
the SERIAL code is located.
-Josh
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: is it easy to change the create sequence algorithm?
@ 2002-06-21 21:34 Andrew Hammond <drew@xyzzy.dhs.org>
parent: Kevin Brannen <kevinb@nurseamerica.net>
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Hammond @ 2002-06-21 21:34 UTC (permalink / raw)
To: Kevin Brannen <kevinb@nurseamerica.net>; +Cc: 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@postgresql.org
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-06-21 21:34 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-06-19 00:16 is it easy to change the create sequence algorithm? Kevin Brannen <kevinb@nurseamerica.net>
2002-06-21 20:43 ` Josh Berkus <josh@agliodbs.com>
2002-06-21 21:34 ` Andrew Hammond <drew@xyzzy.dhs.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox