V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
armoni
V2EX  ›  MySQL

mysql的datetime列设默认值为now()的问题

  •  
  •   armoni · 2013-06-06 12:55:08 +08:00 · 5643 次点击
    这是一个创建于 3948 天前的主题,其中的信息可能已经有所发展或是发生改变。
    之前用自己的服务器创建数据库表的时候经常用now()作为create_time的默认值,一直没问题,这次在公司的windows机器上调试好,把脚本传到cent os上,创建表报错,说Invalid default value for 'create_time', 一查文档,说是不能使用函数作为默认值,you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE.(http://dev.mysql.com/doc/refman/5.0/en/data-type-defaults.html) ,但在w3cshcool上查到OrderDate datetime NOT NULL DEFAULT NOW(),,说明有人在用now()啊,求解。目前暂时用CURRENT_TIMESTAMP代替了。
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1137 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:37 · PVG 02:37 · LAX 11:37 · JFK 14:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.