Re: default timestamp and default autoinc - Mailing list pgsql-general

From Edward Q. Bridges
Subject Re: default timestamp and default autoinc
Date
Msg-id 200011081507.eA8F7ps99857@mail.postgresql.org
Whole thread Raw
In response to default timestamp and default autoinc  ("Jarmo Paavilainen" <jarmo@comder.com>)
List 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




pgsql-general by date:

Previous
From: "Martin A. Marques"
Date:
Subject: TEXT and BLOBS
Next
From: "Jonathan Ellis"
Date:
Subject: Re: how do you call one pltcl function from another?