I can't find what the syntax looks like for adding a DATETIME column to a mysql table when I want to set the default to - example - 2011-01-26 14:30:00
当我想将默认设置为默认值时,我无法找到将DATETIME列添加到mysql表的语法 - 示例 - 2011-01-26 14:30:00
Does anyone know what that syntax looks like?
有谁知道那个语法是什么样的?
Here's what I've got
这就是我所拥有的
ADD COLUMN new_date DATETIME AFTER preceding_col,
Thanks
谢谢
2 个解决方案
#1
29
If you ever have doubts, the syntax is explained here http://dev.mysql.com/doc/refman/5.5/en/alter-table.html
如果你有疑问,请在http://dev.mysql.com/doc/refman/5.5/en/alter-table.html解释语法。
ALTER TABLE yourTable
ADD COLUMN new_date DATETIME NOT NULL DEFAULT 20110126143000 AFTER preceding_col
or
要么
ALTER TABLE yourTable
ADD COLUMN new_date DATETIME NOT NULL DEFAULT '2011-01-26 14:30:00' AFTER preceding_col
(I just prefer the numeric DATETIME format)
(我只是喜欢数字DATETIME格式)
#2
3
ALTER TABLE `yourTable`
ADD `new_date` DATETIME NOT NULL
DEFAULT '2011-01-26 14:30:00'
AFTER `preceding_col`
#1
29
If you ever have doubts, the syntax is explained here http://dev.mysql.com/doc/refman/5.5/en/alter-table.html
如果你有疑问,请在http://dev.mysql.com/doc/refman/5.5/en/alter-table.html解释语法。
ALTER TABLE yourTable
ADD COLUMN new_date DATETIME NOT NULL DEFAULT 20110126143000 AFTER preceding_col
or
要么
ALTER TABLE yourTable
ADD COLUMN new_date DATETIME NOT NULL DEFAULT '2011-01-26 14:30:00' AFTER preceding_col
(I just prefer the numeric DATETIME format)
(我只是喜欢数字DATETIME格式)
#2
3
ALTER TABLE `yourTable`
ADD `new_date` DATETIME NOT NULL
DEFAULT '2011-01-26 14:30:00'
AFTER `preceding_col`