Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Adding a date column in Oracle 9i
<laredotornado_at_zipmail.com> wrote in message
news:1146851256.416441.271790_at_y43g2000cwc.googlegroups.com...
: Hi,
:
: How, if at all, could I add a column to a table in Oracle 9i in which
: the column would record time and date, and its default value would be
: the time the row was inserted. My objective is to avoid editing SQL
: statements to include "SYSDATE" calls. What I would like is taht
: whenever a row is INSERTED, the time the row was inserted is recorded
: in this new column I create.
:
: I don't want anything to happen on UPDATEs.
:
: Thanks, - Dave
:
use 'alter table add' to add a column
use the 'default' clause to have the default value on insert be sysdate
however, since users can override default values, create a BEFORE INSERT --
FOR EACH ROW trigger on the table to force the column value to sysdate (many
examples available by googling)
++ mcs Received on Fri May 05 2006 - 13:38:19 CDT