Re: atomatic insert date and time - Mailing list pgsql-sql

From jasiek
Subject Re: atomatic insert date and time
Date
Msg-id 20030415094834.M11527@klaster.net
Whole thread Raw
In response to atomatic insert date and time  (Rado Petrik <r.p@szm.sk>)
List pgsql-sql
On 15 Apr 2003 10:58:48 +0200, Rado Petrik wrote
> Hi , 
> 
> I have column type "timestamptz". 
> I need automatic add date and time when create new row.
> 
> example.
> 
> id | name | dt_created 
> ---------------------
> 
> INSERT INTO table (name) VALUES('test')
> 
> id | name |    dt_created 
> -------------------------------
>  1   test   1980-06-25 11:11-7
Use now() when defining your table.
It would be something like this:
create table some_table(
...
dt_created timestamptz default now()
);

Remember, that now() is a transaction time, so inside one transaction all 
rows would have the same time.

Regards,
Tomasz Myrta



pgsql-sql by date:

Previous
From: Rado Petrik
Date:
Subject: atomatic insert date and time
Next
From: David Goodwin
Date:
Subject: ordering problems ...