Re: customising serial type

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: customising serial type
Дата
Msg-id 0352BD99-B517-4D57-808A-924A2D59ADFF@myrealbox.com
обсуждение исходный текст
Ответ на customising serial type  (Kenneth Gonsalves <lawgon@thenilgiris.com>)
Список pgsql-sql
On Jun 21, 2005, at 7:01 PM, Kenneth Gonsalves wrote:

> in a table with a serial datatype, how do i get the sequence to start
> at a specific number like 100000?

The SERIAL datatype (e.g., CREATE TABLE foo(foo_id SERIAL) )is a  
shorthand for something like
CREATE SEQUENCE foo_id_seq;
CREATE TABLE foo (foo_id integer default nextval('foo_id_seq') );

If you want it to specify the start value, you'll need to either use  
CREATE SEQUENCE first and then create the table with the appropriate  
default, or use ALTER SEQUENCE after creating the table.

http://www.postgresql.org/docs/8.0/interactive/sql-createsequence.html
http://www.postgresql.org/docs/8.0/interactive/sql-altersequence.html

Michael Glaesemann
grzm myrealbox com


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

Предыдущее
От: Krasimir Dimitrov
Дата:
Сообщение: Re: customising serial type
Следующее
От: Veikko Mäkinen
Дата:
Сообщение: Alias to a type