OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: alter table

From: s. keeling (keelingspots.ab.ca)
Date: Wed Oct 05 2005 - 18:53:38 CDT


Incoming from Pooly:
> 2005/10/3, s. keeling <keelingspots.ab.ca>:
> > I'd like to add a bit of history data to a table (who changed a record
> > last, and when it was last changed). Is this the way to do it?
> > [snip]
> > alter table MEMBERS
> > alter CHG_DATE set default CURRENT_DATE
>
> btw, you could do :
> alter table MEMBERS add CHG_BY varchar(3) not null default "sbk", add
> CHG_DATE date not null default CURRENT_DATE on update current_date
> (not tested)

It doesn't appear to work as I was hoping. According to the manual
the target for keyword default has to be a literal.

mysql> alter table MEMBERS
    -> alter CHANGED_DATE set default CHANGED_DATE = DATE;
ERROR 1064: You have an error in your SQL syntax. Check the \
   manual that corresponds to your MySQL server version for the \
   right syntax to use near 'CHANGED_DATE = DATE' at line 2
mysql> alter table MEMBERS
    -> alter CHANGED_DATE set default CHANGED_DATE = CURRENT_DATE;
ERROR 1064: You have an error in your SQL syntax. Check the \
   manual that corresponds to your MySQL server version for the \
   right syntax to use near 'CHANGED_DATE = CURRENT_DATE' at line 2

Drat.

--
Any technology distinguishable from magic is insufficiently advanced.
(*) http://www.spots.ab.ca/~keeling Please don't Cc: me.
- -
For the ChiComms: democracy human rights Taiwan Independence

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql