Re: [HACKERS] create table and default 'now' problem ? - Mailing list pgsql-hackers

From José Soares
Subject Re: [HACKERS] create table and default 'now' problem ?
Date
Msg-id 12D0B75C.241E4474@sferacarta.com
Whole thread Raw
In response to create table and default 'now' problem ?  (Oleg Bartunov <oleg@sai.msu.su>)
List pgsql-hackers
<tt>You can use DEFAULT CURRENT_TIMESTAMP as in:</tt><tt></tt><p><tt>prova=> create table test ( a datetime default
current_timestamp,b int4);</tt><br /> <tt></tt><p><tt>prova=> insert into test (b) values (1);</tt><br /><tt>INSERT
9410041</tt><tt></tt><p><tt>prova=> insert into test (b) values (1);</tt><br /><tt>INSERT 941005 1</tt><br
/><tt>prova=>select * from test1;</tt><br /><tt>a                          |b</tt><br
/><tt>---------------------------+-</tt><br/><tt>21/09/1999 16:26:45.00 CEST|1</tt><br /><tt>21/09/1999 16:26:50.00
CEST|1</tt><br/><tt>(2 rows)</tt><p>José <br />  <p>Oleg Bartunov ha scritto: <blockquote type="CITE">Hi, <p>how I
couldcreate table with datetime field default to 'now'::text in <br />a way Jan did in his shoes rule example ? <p>If I
do:<br />test=> create table test ( a datetime default 'now', b int4); <br />CREATE <br />test=> insert into test
(b)values (1); <br />INSERT 1677899 1 <br />test=> insert into test (b) values (2); <br />INSERT 1677900 1 <br
/>test=>select * from test; <br />a                           |b <br />----------------------------+- <br />Tue 21
Sep01:48:27 1999 MSD|1 <br />Tue 21 Sep 01:48:27 1999 MSD|2 <br />(2 rows) <p>I always get datetime of the moment I
createdthe table, but I'd like <br />to have datetime of moment I insert. <p>        Regards, <p>                Oleg
<p>_____________________________________________________________<br />Oleg Bartunov, sci.researcher, hostmaster of
AstroNet,<br />Sternberg Astronomical Institute, Moscow University (Russia) <br />Internet: oleg@sai.msu.su, <a
href="http://www.sai.msu.su/~megera/">http://www.sai.msu.su/~megera/</a><br/>phone: +007(095)939-16-83,
+007(095)939-23-83<p>************</blockquote> 

pgsql-hackers by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: [HACKERS] create table and default 'now' problem ?
Next
From: Thomas Lockhart
Date:
Subject: Re: [HACKERS] create table and default 'now' problem ?