Set current date as default for date Type in mysql
I have to add new columns in table 'order' namely shippedDate and last_updated which consist of datetime data type. i would like to do the following.
a) Set shippedDate defaults value to MySQL NOW() or
CURRENT_DATE
b) Set last_updated default value to CURRENT_TIMESTAMP Instead of null which it uses by default.
as the table already exist and it already some existing records i would like to do Modify table, i tried using two different code but none is working.
ALTER TABLE orders ADD COLUMN shippedDate Date NULL default
CURRENT_DATE
AFTER 'previoueColumn', ADD COLUMN `last_updated ` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP AFTER `shippedDate ` ;
It gives me Error :Error 1067 : Invalid default value for shippedDate.
is it possible for me to set the default datetime value to NOW() in MySQL?
thank you...
oh fish.....
ReplyDeleteThis is explicitely documented limitation.
"The DEFAULT value clause in a data type specification indicates 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."
for more details visit
http://dev.mysql.com/doc/refman/5.0/en/data-type-defaults.html
How To Play Baccarat - Pros & Cons
ReplyDeleteIn this guide, we'll start 샌즈카지노 with the basics of Baccarat — the process for winning the game at the table. If you're a newcomer to 바카라 the casino world, kadangpintar you've probably heard of