pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ty <ty@koi.tsukebe.net>
To: pgsql-admin@postgresql.org
Subject: DEFAULT now() ?
Date: Tue, 18 Apr 2000 10:36:53 -0000
Message-ID: <000e01bfa922$03466330$a20efea9@indus> (raw)

May someone please show me the necessary code snippets that would allow the value of a column to take the current time ( ala now() ) by default on INSERT?

Indicative example:

CREATE TABLE foo (
    a INTEGER NOT NULL DEFAULT 0,
    b DATETIME NOT NULL DEFAULT now()
);

INSERT INTO foo (a) VALUES (123);

What happens here? Well, a row is inserted into table ``foo'' where ``a'' has the value 123 and b holds the date & time of when the create DDL statement was executed. I'm wondering how to get b to have the value of the time whenever any arbitrary insert statement is executed...

Ty

view thread (2+ messages)  latest in thread

Message-ID: <000e01bfa922$03466330$a20efea9@indus>
Permalink:  ../000e01bfa922$03466330$a20efea9@indus/
Also on:    postgresql.org/message-id/000e01bfa922$03466330$a20efea9@indus

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: ty@koi.tsukebe.net
  Subject: Re: DEFAULT now() ?
  In-Reply-To: <000e01bfa922$03466330$a20efea9@indus>
  References: <000e01bfa922$03466330$a20efea9@indus>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox