如何在mysql中将默认日期时间设置为系统日期时间

Sha*_*pta 5 mysql mysql-error-1067

我正在尝试将列的默认日期时间设置为系统日期时间.它显示了一个错误

"InsertionDate"的默认值无效

alter table `vts`.`tblpickpoint` 
  add column `InsertionDate` 
      datetime DEFAULT 'Now()' NULL after `PickPointLatLong`
Run Code Online (Sandbox Code Playgroud)

lex*_*exu 3

mysql 中列的默认值不能是函数的结果。

正如旁观者指出的,一个例外是 current_timestamp 。

你的陈述应该是

alter table `vts`.`tblpickpoint` 
  add column `InsertionDate` TIMESTAMP 
             DEFAULT CURRENT_TIMESTAMP 
Run Code Online (Sandbox Code Playgroud)