Thread: SYSDATE in PostgreSQL !?

SYSDATE in PostgreSQL !?

From
Louie Kwan
Date:
How can I define a table with columns with sysdate as the default value..

If there is no SYSDATE defined in PostgreSQL , what can I do ?

Any help is appreciated. 


CREATE TABLE channels    (channelID                  NUMBER PRIMARY KEY,name                         VARCHAR2(64) NOT
NULL,status                       INTEGER NOT NULL,remedyID                   VARCHAR2(15) UNIQUE,remedySchemaID
NUMBERdefault 48,remedyLastModified    INTEGER,updateTimeStamp      DATE default (SYSDATE),createTimeStamp       DATE
default(SYSDATE)
 
);


Regards,
Louie Kwan



Re: SYSDATE in PostgreSQL !?

From
Oliver Elphick
Date:
On Mon, 2004-03-01 at 21:18, Louie Kwan wrote:
> How can I define a table with columns with sysdate as the default value..
> 
> If there is no SYSDATE defined in PostgreSQL , what can I do ?

> CREATE TABLE channels    (
...
>  updateTimeStamp      DATE default (SYSDATE),
>  createTimeStamp       DATE default (SYSDATE)
> );
updateTimeStamp      DATE DEFAULT CURRENT_DATE

or possibly 
updateTimeStamp      TIMESTAMP DEFAULT CURRENT_TIMESTAMP

which will give you time as well as date.  Perhaps you should also add
NOT NULL.

CURRENT_* doesn't change within a transaction.  If you need to record
real time, use timeofday().