From: | "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com> |
---|---|
To: | "Duffey, Kevin" <KDuffey(at)marketron(dot)com> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Why do I need to pass value for Serial type in |
Date: | 2003-09-12 20:13:47 |
Message-ID: | Pine.LNX.4.33.0309121412160.21862-100000@css120.ihs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 12 Sep 2003, Duffey, Kevin wrote:
> I don't know if jdbc/java code requires this, but when I use two gui
> admin tools I found, and I insert a row into the table using their row
> editor feature, both require me to enter a number for the Serial type.
> I thought this type was used to auto-increment an id field and that I
> would not need to enter anything into it? Basically we need the normal
> indexed ID field for each table, and we want it to auto-increment. The
> serial shows a function of nextVal() or something like that, so I assume
> it auto-increments, and it shows unique and not-null. Can someone
> explain how serial is used, why would I still need to pass a value for
> it?
You can do this in a few ways.
create table test (id serial unique, info text, num int);
insert into test (info,num) values ('abc',123);
insert into test (id, info, num) values (DEFAULT,'abc',123);
insert into test values (DEFAULT,'abc',123);
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Browne | 2003-09-12 21:22:58 | Re: PostGreSql database features questions |
Previous Message | Ron Johnson | 2003-09-12 20:04:08 | Re: State of Beta 2 |