Noob question: how to auto-increment index field on INSERT?

Поиск
Список
Период
Сортировка
От Ken MacDonald
Тема Noob question: how to auto-increment index field on INSERT?
Дата
Msg-id 3468cae10911190855s52d87129ie697b254ba8c3375@mail.gmail.com
обсуждение исходный текст
Ответы Re: Noob question: how to auto-increment index field on INSERT?  (Thomas Kellerer <spam_eater@gmx.net>)
Re: Noob question: how to auto-increment index field on INSERT?  (APseudoUtopia <apseudoutopia@gmail.com>)
Список pgsql-novice
Hi,
I have a PostgreSQL DB created by a Django model, with a field 'id' that is automatically created by Django as a primary key, type integer.

I would like to create a new row by doing something like....

INSERT INTO table (a, b, c, d) VALUES ('aa', 'bb', 'cc', 'dd')

where I've been hoping that 'id' would get the next value of id available. Unfortunately, instead I get a 'duplicate primary key' error saying that 'id' is a duplicate, even though I'm not specifying it explicitly in the INSERT. What is the proper way to auto-increment a primary key?
Thanks!
Ken

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

Предыдущее
От: Thom Brown
Дата:
Сообщение: Re: Using file data as argument to functions called from psql command line
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Re: Noob question: how to auto-increment index field on INSERT?