ALTER TABLE [dbo].[MonitorUser] WITH NOCHECK ADD CONSTRAINT [DateTime] DEFAULT (getdate()) for[DateTime] \\自动获取时间插到datetime列中
wanfustudio:你好,你给我的语句执行错误!mysql> ALTER TABLE [dbo].[MonitorUser] WITH NOCHECK ADD CONSTRAINT [DateTime] D FAULT (getdate()) for[DateTime]; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[dbo .[MonitorUser] WITH NOCHECK ADD CONSTRAINT [DateTime] DEFAULT (getdate()) f' at line 1
如:
CREATE TABLE tb(
id char(32) not null,
addtime timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY(id)
) ENGINE=MyISAM DEFAULT CHARSET=gbk;
这样addtime字段就使用当前时间为默认时间了
我试着把时间字段的默认值改成了 CURRENT_TIMESTAMP ,在insert数据的时候,他仅仅就是 0000-00-00 而已?
CONSTRAINT [DateTime] DEFAULT (getdate()) for[DateTime] \\自动获取时间插到datetime列中
FAULT (getdate()) for[DateTime];
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '[dbo
.[MonitorUser] WITH NOCHECK ADD CONSTRAINT [DateTime] DEFAULT (getdate()) f' at
line 1