date stamp on update?

Started by blackwater devover 17 years ago4 messagesgeneral
Jump to latest
#1blackwater dev
blackwaterdev@gmail.com

Is there a datatype in postgres that will automatically update the date when
the row is updated? I know I can do a timestamp and set the default to
now() but once the row is inserted, and then edited, I want the column
updated without editing my application code or adding a trigger. Is this
possible with Postgres?

Thanks!

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: blackwater dev (#1)
Re: date stamp on update?

"blackwater dev" <blackwaterdev@gmail.com> writes:

Is there a datatype in postgres that will automatically update the date when
the row is updated?

No, and it's conceptually impossible to make that happen at the datatype
level. Use a trigger.

regards, tom lane

#3Martin Gainty
mgainty@hotmail.com
In reply to: blackwater dev (#1)
Re: date stamp on update?

Create Table TableName(
ColumnName DATE Sysdate;
);
ALTER TABLE TableName
ALTER COLUMN ColumnName { SET DEFAULT newdefaultvalue | DROP OLDDEFAULT }

HTH
Martin
______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission.

Date: Sat, 22 Nov 2008 17:34:26 -0500
From: blackwaterdev@gmail.com
To: pgsql-general@postgresql.org
Subject: [GENERAL] date stamp on update?

Is there a datatype in postgres that will automatically update the date when the row is updated? I know I can do a timestamp and set the default to now() but once the row is inserted, and then edited, I want the column updated without editing my application code or adding a trigger. Is this possible with Postgres?

Thanks!

_________________________________________________________________
Proud to be a PC? Show the world. Download the “I’m a PC” Messenger themepack now.
hthttp://clk.atdmt.com/MRT/go/119642558/direct/01/

In reply to: blackwater dev (#1)
Re: date stamp on update?

On Sat, Nov 22, 2008 at 05:34:26PM -0500, blackwater dev wrote:

Is there a datatype in postgres that will automatically update the date when
the row is updated? I know I can do a timestamp and set the default to
now() but once the row is inserted, and then edited, I want the column
updated without editing my application code or adding a trigger. Is this
possible with Postgres?

http://www.depesz.com/index.php/2008/05/08/mysqls-timestamp-in-postgresql/

depesz

--
Linkedin: http://www.linkedin.com/in/depesz / blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007