Newbie Question

Started by Clay & Judi Kinneyalmost 25 years ago5 messagesgeneral
Jump to latest
#1Clay & Judi Kinney
cricketk@home.com

How do I create an autoincrement field in a postgresql table???

What are the correct field type and parameters????

Any help would be appreciated.....

Thanks

Clay

#2Mitch Vincent
mitch@venux.net
In reply to: Clay & Judi Kinney (#1)
Re: Newbie Question

You *really* should go glance over the manual.. There is the field type
SERIAL and things called sequences, both could be what you're talking
about....The rest I'll leave up to you :-)

Good luck!!!

-Mitch

----- Original Message -----
From: "Clay & Judi Kinney" <cricketk@home.com>
To: <pgsql-general@postgresql.org>
Sent: Tuesday, May 01, 2001 8:34 AM
Subject: Newbie Question

Show quoted text

How do I create an autoincrement field in a postgresql table???

What are the correct field type and parameters????

Any help would be appreciated.....

Thanks

Clay

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

#3Ludwig Meyerhoff
ludwig@antar.com
In reply to: Clay & Judi Kinney (#1)
Re: Newbie Question

Hallo!

How do I create an autoincrement field in a postgresql table???
What are the correct field type and parameters????

Well, what about using sequences?
create sequence tralalala;
create table huibui
(
id integer primary key default nextval('tralalala'),
field1 references table1,
and-so-on references all-other-tables
);

How, each time You insert some data in huibui using
insert into huibui (field1, and-son-on) values (?, ..);
the 'tralala' counter will be increased by one (nextval).

Saluti!

Ludwig

#4Joel Burton
jburton@scw.org
In reply to: Clay & Judi Kinney (#1)
Re: Newbie Question

On Tue, 1 May 2001, Clay & Judi Kinney wrote:

How do I create an autoincrement field in a postgresql table???

What are the correct field type and parameters????

Any help would be appreciated.....

CREATE TABLE foo (
id SERIAL,
...
)

it comes out as an int4 or integer type.

--
Joel Burton <jburton@scw.org>
Director of Information Systems, Support Center of Washington

#5Peter Eisentraut
peter_e@gmx.net
In reply to: Clay & Judi Kinney (#1)
Re: Newbie Question

Clay & Judi Kinney writes:

How do I create an autoincrement field in a postgresql table???

See FAQ.

--
Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter