Re: How do I make a timestamp column default to current time

From: "William ZHANG" <uniware(at)zedware(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How do I make a timestamp column default to current time
Date: 2006-03-16 15:16:13
Message-ID: dvbvka$ugc$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


"zagman" <daveh(at)allheller(dot)net>
>
> Hi,
>
> I'm setting up a simple timecard program and I need a column that
> defaults to the current time when a new row is inserted. How can I do
> this I tried setting the default to 'now' but all that does is put the
> time I created the table in each row! I'm also new to postgresql and if
> someone can give me a pointer or two in the right direction I would be
> appreciative.
>
> Thanks,
>
> Dave
>

I think now() or current_timestamp both work.
But I cann't test it now:

create table foo (fno int, ftimestamp timestamp default now());
insert into foo(fno) values (1);
insert into foo(fno) values (2);
select * from foo;

Regards,
William ZHANG

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Amiel 2006-03-16 15:58:52 Re: Replication & web apps
Previous Message Tony Caduto 2006-03-16 15:04:16 Only 6 days left to get PGLA for 5 dollars (promtion has been adjusted to 100 units)