MySQL Error 1293 - Incorrect table definition (TIMESTAMP)
来源:互联网 发布:sort python 编辑:程序博客网 时间:2024/06/05 17:06
1.首先我们来看下TIMESTAMP和DATETIME的相同与不同:
ref:http://database.51cto.com/art/200905/124240.htm
相同
显示
TIMESTAMP列的显示格式与DATETIME列相同。换句话说,显示宽度固定在19字符,并且格式为YYYY-MM-DD HH:MM:SS。
不同
范围
datetime 以'YYYY-MM-DD HH:MM:SS'格式检索和显示DATETIME值。支持的范围为'1000-01-01 00:00:00'到'9999-12-31 23:59:59'TIMESTAMP值不能早于1970或晚于2037
储存
TIMESTAMP
1.4个字节储存(Time stamp value is stored in 4 bytes)
2.值以UTC格式保存( it stores the number of milliseconds)
3.时区转化 ,存储时对当前的时区进行转换,检索时再转换回当前的时区。
datetime
1.8个字节储存(8 bytes storage)
2.实际格式储存(Just stores what you have stored and retrieves the same thing which you have stored.)
3.与时区无关(It has nothing to deal with the TIMEZONE and Conversion.)
实例对比
现在我来做个时区对他们的影响。
1.先插入一个数据insert into `t8` values(now(), now());
2.改变客户端时区(东9区,日本时区)。
3.再次显示插入的数据,变化了,timestamp类型的数据 增加了 1个小时
接下来 讨论一些timestamp 的其他的属性
1.null 是否为空
timestamp 默认允许为 “非空”(not null by default), 如果你在定义“ts TIMESTAMP DEFAULT NULL” 是非法的。 可以指定为空 null ,“ts TIMESTAMP NULL" ,这时可以在添加语句改变默认值。
ts2 TIMESTAMP NULL DEFAULT 0,ts3 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
default (一个表中只能有一个列选择下面其中一种)
default CURRENT_TIMESTAMPdefault CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP
ON UPDATE 见上2
2.因此当我们遇到MySQL Error 1293 - Incorrect table definition (TIMESTAMP)问题时,应该知道是没有给timestamp字段赋予默认值。
例如:如果数据库语句如下会出现1293的问题:
create table users ( id int unsigned auto_increment not null primary key, username varchar(50) not null unique, password varchar(40) not null, email_address varchar(128) not null unique, email_sent timestamp not null, last_login timestamp not null default now()) ENGINE = InnoDB;我们可以通过以下两种方式进行修改:
create table users ( id int unsigned auto_increment not null primary key, username varchar(50) not null unique, password varchar(40) not null, email_address varchar(128) not null unique, last_login timestamp not null default now(), email_sent timestamp not null) ENGINE = InnoDB;方法2:
create table users ( id int unsigned auto_increment not null primary key, username varchar(50) not null unique, password varchar(40) not null, email_address varchar(128) not null unique, email_sent timestamp not null default 0, last_login timestamp not null default now()) ENGINE = InnoDB;ref:http://alvinalexander.com/mysql/mysql-error-1293-incorrect-table-definition-timestamp
- MySQL Error 1293 - Incorrect table definition (TIMESTAMP)
- Mysql 1293 - Incorrect table definition; there can be only one TIMESTAMP column with C
- mysql单表多timestamp报错#1293 - Incorrect table definition; there can be only one TIMESTAMP column with C
- mysql从5.6版本导入5.5报错:Error Code : 1293 Incorrect table definition
- error : Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in
- [Err] 1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTA
- 解决mysql建表报错ERROR 1075 (42000): Incorrect table definition...
- mysql报ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must
- 创建主键时报错:ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it mus
- 创建主键时报错:ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it mus
- ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be def
- ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be def
- MySQL Error Query database. Causejava.sql.SQLException: Incorrect key file for table ‘/tmp/#sql_181c
- Error 'Incorrect key file for table 'test'
- MySQL Error : Incorrect date value
- MySql Incorrect key file for table *** 解决方法
- MySQL: [ERROR] /usr/sbin/mysqld: Incorrect key file for table './xxx/xxxx.MYI'; try to repair it
- mysql error table
- 第一篇博客文章《知识总结》
- 水平滚动和ViewPager联动
- 第11周项目1- 点-圆-圆柱类族的设计
- hadoop单机安装
- TCP的拥塞避免、超时重传、快速重传、快速恢复
- MySQL Error 1293 - Incorrect table definition (TIMESTAMP)
- 5.31Linux下的JAVA
- hdu1045(二分图)
- 杂记开篇
- 华为机试---计算字符串的距离
- PHP5权限控制修饰符
- zookeeper简介及其搭建
- <ViewSwitcher>的简单功能与用法
- 同过js判断,改变按键的功能