dbTalk Databases Forums  

Adding a date column in Oracle 9i

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Adding a date column in Oracle 9i in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Adding a date column in Oracle 9i - 05-05-2006 , 12:47 PM






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


Reply With Quote
  #2  
Old   
Mark C. Stock
 
Posts: n/a

Default Re: Adding a date column in Oracle 9i - 05-05-2006 , 01:38 PM







<laredotornado (AT) zipmail (DOT) com> wrote

: 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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.