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

Поиск
Список
Период
Сортировка
От Andrew Hammond
Тема Re: is it easy to change the create sequence algorithm?
Дата
Msg-id 3D139C03.4090503@xyzzy.dhs.org
обсуждение исходный текст
Ответ на is it easy to change the create sequence algorithm?  (Kevin Brannen <kevinb@nurseamerica.net>)
Список 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




В списке pgsql-sql по дате отправления:

Предыдущее
От: "Josh Berkus"
Дата:
Сообщение: Re: is it easy to change the create sequence algorithm?
Следующее
От: "Kris"
Дата:
Сообщение: Obtaining primary key information from pg system tables