Re: How to autoincrement a primary key...

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: How to autoincrement a primary key...
Дата
Msg-id 20060922192541.46464.qmail@web31815.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на How to autoincrement a primary key...  ("Doug Hyde" <doug.hyde@e-cocreate.com>)
Ответы Re: How to autoincrement a primary key...
Re: How to autoincrement a primary key...
Список pgsql-sql
> I am sure this is simple, but I don't get it. I am new to PGSQL, coming from
> MySQL - in mysql, you can autoincrement the primary key; in postgre, I am
> not sure how to do this. I have read the documentation, and tried "nextval"
> as the default - I have searched for the datatype SERIAL, but I am using
> navicat and this datatype is not supported. Can someone tell me how to do
> this - I just want the integer value for a primary key to autoincrement by
> one. 

CREATE TABLE bar (id    SERIAL PRIMARY KEY);


Is just shorthand notation for:


CREATE SEQUENCE foo START 1;
CREATE TABLE bar (id integer PRIMARY KEY DEFAULT nextval('bar'));


Also see:
http://www.postgresql.org/docs/8.1/interactive/sql-createtable.html
http://www.postgresql.org/docs/8.1/interactive/sql-createsequence.html

Regards,

Richard Broersma Jr.


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

Предыдущее
От: "Doug Hyde"
Дата:
Сообщение: How to autoincrement a primary key...
Следующее
От: "Andrew Chilton"
Дата:
Сообщение: Re: How to autoincrement a primary key...