Search Postgresql Archives

Re: Implicit sequence with start value?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Clemens Eisserer <linuxhippy@xxxxxxxxx> 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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux