Re: Implicit sequence with start value?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Implicit sequence with start value?
Дата
Msg-id 27956.1248625117@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Implicit sequence with start value?  (Clemens Eisserer <linuxhippy@gmail.com>)
Ответы Re: Implicit sequence with start value?
Список pgsql-general
Clemens Eisserer <linuxhippy@gmail.com> writes:
> Is it possible to use an implicit sequence with a start value?
> Something like:  CREATE TABLE foo (key SERIAL START 1000 PRIMARY KEY NOT NULL);

Well, you can't do it just that way, but you could issue a setval() or
ALTER SEQUENCE command after creating the table.  For instance

regression=# create table foo (bar serial);
NOTICE:  CREATE TABLE will create implicit sequence "foo_bar_seq" for serial column "foo.bar"
CREATE TABLE
regression=# alter sequence foo_bar_seq start with 1000;
ALTER SEQUENCE

or you might prefer

regression=# select setval(pg_get_serial_sequence('foo', 'bar'), 1000);
 setval
--------
   1000
(1 row)


            regards, tom lane

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

Предыдущее
От: Clemens Eisserer
Дата:
Сообщение: Implicit sequence with start value?
Следующее
От: Clemens Eisserer
Дата:
Сообщение: Re: Implicit sequence with start value?