Re: Alter Table Auto_Increment

Поиск
Список
Период
Сортировка
От Carlos Mennens
Тема Re: Alter Table Auto_Increment
Дата
Msg-id AANLkTinpn0kUTf83TTANwhsaASTpq8YAQgND8ViSqBn8@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Alter Table Auto_Increment  (Thom Brown <thom@linux.com>)
Ответы Re: Alter Table Auto_Increment  (Thom Brown <thom@linux.com>)
Re: Alter Table Auto_Increment  (Adrian Klaver <adrian.klaver@gmail.com>)
Список pgsql-general
On Mon, Sep 20, 2010 at 10:08 AM, Thom Brown <thom@linux.com> wrote:
> CREATE SEQUENCE seq_blades_id;
> SELECT setval('seq_blades_id', max(id)) FROM blades; -- set the
> sequence's value to the maximum value of "id"
> ALTER TABLE blades ALTER COLUMN id SET DEFAULT
> nextval('seq_blades_id'); -- make default value get value from
> sequence

That appeared to work fine. My question that I can't find in the
documentation is that if I already have one row created where my 'id =
1' for AUTO_INCREMENT, how do I enter future values into my table and
force id to auto_increment rather than having me type the value into
the SQL command? This way I can let PostgreSQL add the next INTEGER
rather than me having to know and avoid duplicates.

INSERT INTO blades VALUES (
'2',
'data',
'data',
'data',
'1234',
'2010-09-20
);

Is there a way I can omit having to type the '2' above in my SQL
command if 'id' column is configured for AUTO_INCREMENT

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

Предыдущее
От: Dave Page
Дата:
Сообщение: Re: Installing Contrib Modules with a Precompiled Binary
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: A note on pg_upgrade and missing "pg_upgrade_support.so"