"A. Kretschmer" <andreas.kretschmer@schollglas.com> writes:
> Yes. You don't need call nextval.
Well, you do, but the point is that the default expression for a
serial column includes the nextval() call. Look at the table with
\d, eg
postgres=# create table t1(id serial primary key);
NOTICE: CREATE TABLE will create implicit sequence "t1_id_seq" for serial column "t1.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t1_pkey" for table "t1"
CREATE TABLE
postgres=# \d t1
Table "public.t1"
Column | Type | Modifiers
--------+---------+-------------------------------------------------
id | integer | not null default nextval('t1_id_seq'::regclass)
Indexes:
"t1_pkey" PRIMARY KEY, btree (id)
postgres=#
So if you do an insert that doesn't provide a value for that column,
the nextval is done implicitly.
regards, tom lane