HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

ADD Column ON UPDATE TIMESTAMP

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
updatetimestampaddcolumn

Problem

I want to alter a table to include modified and created columns. However, I am having trouble with adding the modified column. I get the following error:


SQL Error: ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"

I was reading this Oracle document (http://docs.oracle.com/cd/E17952_01/refman-5.5-en/timestamp-initialization.html) to get an example on how to properly write the ON UPDATE syntax

Here is my SQL.

ALTER TABLE FOOBAR
ADD (
  created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
  modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);


Why am I getting a missing right parenthesis error?

Solution

That is the MySQL documentation, not the Oracle Database documentation.
There is no such clause in Oracle Datababase.
Use a trigger. Here is an example: link

Context

StackExchange Database Administrators Q#56900, answer score: 7

Revisions (0)

No revisions yet.