mysql timestamp 值不合法问题
2024-08-27 11:40:14
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)
最新文章
- jquery中ajax 从前端到后端 完整过程解析
- SQL SERVER--单回话下的死锁
- 配置Apache服务器 数据库mySQL
- WPF 制作圆角按钮
- CC++初学者编程教程(1) Visual Stduio2010开发环境搭建
- iOS定位功能
- VC之美化界面(内容覆盖十分全面,经典)
- [jquery备忘]
- r.js build.js配置
- Javascript中Array(数组)对象常用的几个方法
- centos手动配置IP和DNS
- 如何在服务器上配置ODBC来访问本机DB2 for Windows服务器
- k个一组翻转链表(java实现)
- Wireshark数据抓包教程之安装Wireshark
- 更改虚拟机UUID
- java 加载过程
- 子查询四(在select子句中使用子查询)
- 【BZOJ4278】[ONTAK2015]Tasowanie 后缀数组
- CSS/JQuery元素选择器之&;amp;&;amp;和||,选择器的逻辑操作
- [Idea]安装avtiviti插件以及 插件中文乱码
热门文章
- 使用ajax发送邮件的实例
- Stack的实现
- Mysql 常用查询语句
- Array 的五种迭代方法 -----every() /filter() /forEach() /map() /some()
- 启用 ASP.NET MVC 项目的 Edit and Continue
- ORACLE RAC中一个实例不能随crs自动启动的解决
- C语言入门(17)——C语言数组应用的一个实例
- libcurl提交表单上传文件
- poj3094---对字符串的处理
- Windows SVN变更发送邮件通知(JAVA实现)