当我想将默认值设置为 - 示例 - 2011-01-26 14:30:00 时,我找不到向 mysql 表添加 DATETIME 列的语法是什么样的
有人知道这个语法是什么样的吗?
这就是我所拥有的
ADD COLUMN new_date DATETIME AFTER preceding_col,
谢谢
如果您有疑问,请参阅此处的语法解释 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
或
ALTER TABLE yourTable
ADD COLUMN new_date DATETIME NOT NULL DEFAULT '2011-01-26 14:30:00' AFTER preceding_col
(我只是更喜欢数字 DATETIME 格式)
ALTER TABLE `yourTable`
ADD `new_date` DATETIME NOT NULL
DEFAULT '2011-01-26 14:30:00'
AFTER `preceding_col`
13年后同样的问题:
这些 VB 代码不起作用,你有想法吗?
'________________________________ T E S T S um den Standartwert AUTOMATISCH einzustellen _______________________________________________
'SQLtext = "ALTER TABLE " & dtnamenstab1!Name & " ADD COLUMN ChangeDate2 DATETIME NOT NULL DEFAULT '" & Now() & "' AFTER preceding_col"
'SQLtext = "ALTER TABLE " & dtnamenstab1!Name & " ADD COLUMN ChangeDate2 DATETIME NOT NULL DEFAULT 20241119143000 AFTER preceding_col"
'SQLtext = "ALTER TABLE " & dtnamenstab1!Name & " ADD COLUMN ChangeDate2 DATETIME NOT NULL DEFAULT ""20241119143000"" AFTER preceding_col"
'SQLtext = "ALTER TABLE " & dtnamenstab1!Name & " ADD COLUMN ChangeDate2 DATETIME NOT NULL DEFAULT 20241119143000"
'SQLtext = "Alter Table " & dtnamenstab1!Name & " ALTER ChangeDate DATETIME DEFAULT set " & Now()
'dbdatenbank.Execute "ALTER TABLE " & dtnamenstab1!Name & " ALTER Changedate DATETIME DEFAULT NOW() NOT NULL;"
'SQLtext = "ALTER TABLE " & dtnamenstab1!Name & " Modify ChangeDate2 Datetime DEFAULT"