Bug #2040 Functions as default values in columns... give them a chance :)

Submitted: 7 Dec 2003 18:01 Modified: 23 Nov 2005 23:45
Reporter: Kevin Grigorenko Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version: OS:
Assigned to: CPU Architecture:Any

[7 Dec 2003 18:01] Kevin Grigorenko
Description:
Hello, now I understand that the documentation clearly states:

"... This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE. ..."

I was wondering if there is anything on the drawing board to re-anaylze this issue and possibly make slight modifications.  It would be a drastic and complicated change to allow all functions to be defaults, but I don't think it would be too much to ask for even at least the NOW() function in a date or datetime field, and various other logic functions per the type of field.  I think customers would love an enhancement such as this, and I would really appreciate it if the great and wonderful people at MySQL would take this into consideration.

Anyway, it's probably more complicated than I think, as it always is, but it would be a lovely enhancement!

Thanks so much for a great product!
Kevin

How to repeat:
mysql> alter table table_name alter column column_name set default "now()";

I selected Feature Request, but the Bug Report system said that I must supply something in the "How to repeat" box.  Maybe there actually was something worth your time in this request.
[2 Jul 2005 8:06] Evan Chaney
I would appreciate this feature, as well.
[26 Oct 2005 15:35] Tal Kormas
This is a great options for auditing. Please add it.
[23 Nov 2005 23:45] James Day
This was added for timestamps in MySQL 4.1. The description there says:

"Any of CURRENT_TIMESTAMP, CURRENT_TIMESTAMP(), or NOW() can be used in the DEFAULT and ON UPDATE clauses. They all have the same effect. "

More details at http://dev.mysql.com/doc/refman/4.1/en/timestamp-4-1.html
[28 Nov 2005 15:50] Tal Kormas
The problem is, that sometimes people want to be able to use this function for a date column, and not a timestamp. What if I want to capture only the current date?

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.052 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.