duanhanglekr37902 2014-06-17 08:29
浏览 380

创建MYSQL表时的日期时间和时间戳问题

I am trying to create mysql table in PhpMyAdmin in Hostgator server with the following information but it is showing error

Error : #1067 - Invalid default value for 'CreatedDate'

Table

  CREATE TABLE `tbl_sample` (
  `ID` int(11) NOT NULL  AUTO_INCREMENT,
  `Domain` varchar(100) DEFAULT NULL,
  `ClickUrl` varchar(600) DEFAULT NULL,
  `CreatedDate` datetime NULL DEFAULT now(),
  `ModifyDate` timestamp NULL DEFAULT NULL on update now(),
  PRIMARY KEY (`ID`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

The purpose of table is I need to enter only 'Domain' and 'ClickUrl' data using insert command remaining Id(autoincrement),CreatedDate(current date when inserting row),ModifyDate(when update the row) will automatically insert.

The above table is executed successfully in mysql environment in my local system but it is not executing in the mysql environment in hostgator

  • 写回答

1条回答 默认 最新

  • douweilei2307 2014-06-17 08:39
    关注

    Check this link]1

    Problem with creating Two column with timestamps. have to use trigger to get it done.

    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口