mysql timestamp 值不合法问题
Create Table: CREATE TABLE `RecruitmentDesc` (
`sn` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号(自增字段)',
`areaSn` int(11) NOT NULL COMMENT '地区编号',
`title` varchar(50) NOT NULL COMMENT '职位标题',
`content` text NOT NULL COMMENT '职位描述',
`status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态 1可用 2不可用',
`personNum` int(11) NOT NULL DEFAULT '0' COMMENT '招聘人数 0-若干',
`actionTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '启用时间',
`dueTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '到期时间',
`createTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间',
`updateTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '更新时间',
PRIMARY KEY (`sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='诚聘英才表'
1 row in set (0.00 sec) mysql> ALTER TABLE `RecruitmentDesc` MODIFY COLUMN `status` TINYINT NOT NULL DEFAULT 2 COMMENT '状态 1可用 2不可用';
ERROR 1067 (42000): Invalid default value for 'dueTime' Create Table: CREATE TABLE `RecruitmentDesc111` (
`sn` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号(自增字段)',
`areaSn` int(11) NOT NULL COMMENT '地区编号',
`title` varchar(50) NOT NULL COMMENT '职位标题',
`content` text NOT NULL COMMENT '职位描述',
`status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态 1可用 2不可用',
`personNum` int(11) NOT NULL DEFAULT '0' COMMENT '招聘人数 0-若干',
`actionTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '启用时间',
`dueTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '到期时间',
`createTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '创建时间',
`updateTime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '更新时间',
PRIMARY KEY (`sn`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='诚聘英才表 tinyint
从 0 到 255 的整型数据。存储大小为 1 字节。 ALTER TABLE `RecruitmentDesc` MODIFY COLUMN `dueTime` timestamp NOT NULL DEFAULT '2016-03-23 00:00:00' , MODIFY COLUMN `createTime` timestamp NOT NULL DEFAULT '2016-03-23 00:00:00' , MODIFY COLUMN `updateTime` timestamp NOT NULL DEFAULT '2016-03-23 00:00:00' ; ALTER TABLE `RecruitmentDesc` MODIFY COLUMN `dueTime` timestamp NOT NULL DEFAULT now() , MODIFY COLUMN `createTime` timestamp NOT NULL DEFAULT now() , MODIFY COLUMN `updateTime` timestamp NOT NULL DEFAULT now() ; create table test100(id TINYINT,dueTime NOT NULL DEFAULT now()); mysql> desc test100
-> ;
+---------+------------+------+-----+-------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+------------+------+-----+-------------------+-------+
| id | tinyint(4) | YES | | NULL | |
| dueTime | timestamp | NO | | CURRENT_TIMESTAMP | |
+---------+------------+------+-----+-------------------+-------+
2 rows in set (0.00 sec) mysql> select * from test100;
Empty set (0.00 sec) mysql> insert into test100 values(1, default);
Query OK, 1 row affected (0.03 sec) mysql> select * from test100;
+------+---------------------+
| id | dueTime |
+------+---------------------+
| 1 | 2016-03-23 17:37:19 |
+------+---------------------+
1 row in set (0.00 sec) mysql> insert into test100(id) values(20);
Query OK, 1 row affected (0.01 sec) mysql> select * from test00;
ERROR 1146 (42S02): Table 'zjzc.test00' doesn't exist
mysql> select * from test100;
+------+---------------------+
| id | dueTime |
+------+---------------------+
| 1 | 2016-03-23 17:37:19 |
| 20 | 2016-03-23 17:38:24 |
+------+---------------------+
2 rows in set (0.00 sec)
mysql timestamp 值不合法问题的更多相关文章
- mysql TIMESTAMP详解
navicat中设置timestamp字段的时间,默认这里填写CURRENT_TIMESTAMP,就是在插入数据的时候按照当前时间插入: 勾选根据当前时间戳更新,表示在UPDATE的时候,会根据当前时 ...
- MySQL timestamp用法
与timestamp类型相关的类型包括:date类型与datetime类型.date类型只包含日期部分,不包含时间部分,它的格式为'YYYY-MM-DD',支持的范围为'1000-01-01' to ...
- mysql TIMESTAMP与DATATIME的区别---转载加自己的看法
from:http://lhdeyx.blog.163.com/blog/static/318196972011230113645715/ from:http://blog.csdn.NET/zht6 ...
- loadrunner动态从mysql取值
loadrunner动态从mysql取值 [需要下载跟数据库服务器一致的dll,32位或64位] loadrunner中有参数化从数据库中取值,但是只是静态的,对于一些要实时取值的数据就game ov ...
- MySQL NULL 值处理
MySQL NULL 值处理 我们已经知道MySQL使用 SQL SELECT 命令及 WHERE 子句来读取数据表中的数据,但是当提供的查询条件字段为 NULL 时,该命令可能就无法正常工作. 为了 ...
- mysql timestamp字段定义的
Cause: java.sql.SQLException: Cannot convert value '2017-07-26 20:40:41.000000' from column 10 to TI ...
- 二十一、MySQL NULL 值处理
MySQL NULL 值处理 我们已经知道 MySQL 使用 SQL SELECT 命令及 WHERE 子句来读取数据表中的数据,但是当提供的查询条件字段为 NULL 时,该命令可能就无法正常工作. ...
- DB-MySQL:MySQL NULL 值处理
ylbtech-DB-MySQL:MySQL NULL 值处理 1.返回顶部 1. MySQL NULL 值处理 我们已经知道 MySQL 使用 SQL SELECT 命令及 WHERE 子句来读取数 ...
- MySQL复习值代码知识点(1)
MySQL复习值代码知识点 一. 创建数据库 create database 数据库名: 二. 删除数据库 drop database 数据库名: 三. 选择相应的数据库 use 数据库名: 四. 创 ...
随机推荐
- EditPlus 快速去重
- 通过js控制html页面不能右键,复制等
<script type="text/javascript"> //Method one //<![CDATA[ //document.oncontextmenu ...
- android上传json与服务器交互
http://www.2cto.com/kf/201403/289328.html http://www.tuicool.com/articles/FZJR3eB
- RenderPartial: No overload for method 'Write' takes 0 arguments
如下方法调用RenderPartial: 报“No overload for method 'Write' takes 0 arguments”的错误: @if (@Model != null &am ...
- The solution for "Eclipse is running in a JRE, but a JDK is required"
Open the eclipse folder and access the eclipse.ini file: Before change it ,you will find it don’t ...
- 谈谈ILDasm的功能限制与解除
原文:谈谈ILDasm的功能限制与解除 首先,我在此申明,此文并不是教别人突破限制,我们只是用学习的眼光看问题 大家都知道ILDasm是.NET程序的反编译工具,它是由Microsoft提供的反编译工 ...
- node.js安装和启动
在Windows上安装 Node.js十分方便,我们只需要访问node.js官网http://www.nodejs.org/,点击Download链接,然后选择Windows Installer(32 ...
- 练习3.20 a 将中缀表达式转换为后缀表达式
//将中缀表达式转换为后缀表达式 int main() { ; ]={,,,,,,,}; char tmp; PtrToStack s; s = CreateStack( MaxSize ); ) { ...
- Centos6.5升级gcc for qt5.3.1
1.升级GCC CentOS6.5内置的GCC版本为4.4,而Qt5.2.1则需要4.8.2的支持(支持C++ 11特性),因此,必须先升级GCC wget http://ftp.tsukuba.wi ...
- linux 和unix 的区别
Linux与Unix的区别 某些PC机的Unix和Linux在实现方面相类似.几乎所有的商业Unix版本都基本支持同样的软件.程序设计环境和网络特性.然而,Linux和Unix的商业版本依然存在许多 ...