using serial values

From: Dennis Gearon <gearond(at)cvc(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: using serial values
Date: 2003-02-13 20:03:10
Message-ID: LJTOC994FCRNT1YN93WS76SN32941Z.3e4bf9fe@cal-lab
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

How do I get the values for the serial field? Do they automatically insert themselves with a
default if I do not use that field in the INSERT statement?

Example:

create table EntityTypes(
entity_type_id serial NOT NULL CONSTRAINT PK_EntityTypes1 PRIMARY KEY,
entity_type varchar(16) NOT NULL,
CONSTRAINT UC_EntityTypes_Entity_Type1 UNIQUE(entity_type)
);

INSERT INTO EntityTypes( entity_type ) VALUES 'Big Smile, Good Dresser, Easy to Get Along With';

Will the above statement causes a row to be inserted with the value for 'entity_type_id' to be
automatically 1 or 0?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Emmanuel Charpentier 2003-02-13 20:04:14 Re: Restore from 7.3 to 7.2
Previous Message Brandon Craig Rhodes 2003-02-13 19:50:27 Re: arrays and pl/pgsql?