Re: default timestamp and default autoinc

From: "Edward Q(dot) Bridges" <ed(dot)bridges(at)buzznik(dot)com>
To: "Jarmo Paavilainen" <jarmo(at)comder(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: default timestamp and default autoinc
Date: 2000-11-08 15:03:30
Message-ID: 200011081507.eA8F7ps99857@mail.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 6 Nov 2000 15:00:19 +0100, Jarmo Paavilainen wrote:

> Hi,
>
> Does pg have "default timestamp" and "default autoinc" as default values
> (used in CREATE TABLE).
>

here's an example that shows how to default a timestamp and how to use a
sequence to auto-increment a primary key column:

CREATE SEQUENCE personid_seq;
CREATE TABLE person (
person_id INT4 NOT NULL DEFAULT nextval('personid_seq'),
create_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
modify_date TIMESTAMP NOT NULL,
firstname VARCHAR (128) NOT NULL,
lastname VARCHAR (128),
PRIMARY KEY (person_id));
CREATE UNIQUE INDEX personid_key
ON person(person_id);
CREATE TRIGGER trg_modtime BEFORE INSERT OR UPDATE
ON person FOR EACH ROW
EXECUTE PROCEDURE setmodtime();

the trigger updates the modify_date column, and you could use that
as an alternate way of adding a timestamp.

> And where is the PostgreSQL reference guide. Or actually/maybe how do I make
> html files of the sgml files that are included with the CVS tree (what do I
> need, jade? and where do I get it?)?
>

bash# cd $POSTGRES_SOURCE_TREE/doc
bash# gmake install

should create man pages and html files for all docs

HTH
ed

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jonathan Ellis 2000-11-08 16:21:14 Re: how do you call one pltcl function from another?
Previous Message Martin A. Marques 2000-11-08 13:36:58 TEXT and BLOBS