>From: Shawn Green (MySQL) [mailto:shawn.l.green@stripped]
>Sent: Friday, December 17, 2010 10:35 AM
>To: Jerry Schwartz
>Cc: joao@stripped; mysql@stripped
>Subject: Re: Access to MySQL
>On 12/17/2010 09:34, Jerry Schwartz wrote:
>>> -----Original Message-----
>>> From: Jo?o C?ndido de Souza Neto [mailto:joao@stripped]
>>> Sent: Friday, December 17, 2010 6:11 AM
>>> To: mysql@stripped
>>> Subject: Re: Access to MySQL
>>> What about this?
>>> date_format(now(), "%Y/%m/%d")
>> [JS] I don't think you can use anything but a constant as a default value.
>You are correct with one exception that was already mentioned earlier:
>the TIMESTAMP storage type.
>The DEFAULT clause specifies a default value for a column. With one
>exception, the default value must be a constant; it cannot be a function
>or an expression. 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. The exception is that you can specify CURRENT_TIMESTAMP as
>the default for a TIMESTAMP column. See Section 10.3.1.1, "TIMESTAMP
>However, nothing says you can't use a function or other computation in a
>TRIGGER to set the default value to an empty column of a new row to
>whatever you wanted it to be.
>I know it's a workaround but it will keep the default value management
>out of your application and inside the database.
[JS] Thanks. I did have that in the back of my mind, but to be honest I never
used a trigger.
I'll have to think about this.
Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032
860.674.8796 / FAX: 860.674.8341
Web site: www.the-infoshop.com
>MySQL Principal Technical Support Engineer
>Oracle USA, Inc.
>Office: Blountville, TN
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe: http://lists.mysql.com/mysql?unsub=1