Create Table: CREATE TABLE `Client` (
`sn` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户编号(自增字段)',
`uuid` char(32) NOT NULL DEFAULT '' COMMENT '用户统一编号',
`userNick` char(20) NOT NULL DEFAULT '' COMMENT '用户昵称',
`password` char(32) NOT NULL DEFAULT '' COMMENT '用户登录密码',
`tradePassword` char(32) NOT NULL DEFAULT '' COMMENT '交易密码',
`accountType` char(1) NOT NULL COMMENT '账户类型 1-个人账户 2-企业账户',
`registerType` char(1) NOT NULL DEFAULT '' COMMENT '注册类型 1-网上注册 2-线下开户',
`mobilePhone` char(11) NOT NULL COMMENT '手机号码',
`mailBox` char(60) NOT NULL DEFAULT '' COMMENT '电子邮箱',
`weixinAccount` char(60) NOT NULL DEFAULT '' COMMENT '微信帐号',
`introducerSn` int(11) NOT NULL COMMENT '推荐人用户编号',
`introducer` varchar(50) NOT NULL DEFAULT '' COMMENT '用户填写的介绍人信息',
`status` char(1) NOT NULL DEFAULT '' COMMENT '用户状态 1-激活,2-冻结',
`registerTime` datetime DEFAULT NULL COMMENT '注册时间',
`passwordErrNum` tinyint(4) NOT NULL DEFAULT '0' COMMENT '客户连续登陆密码错误次数',
`lastLoginTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '客户上次登陆时间',
`tradePasswordErrNum` tinyint(4) NOT NULL DEFAULT '0' COMMENT '客户连续交易密码输错次数',
`lastInputTradePasswordTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '客户上次交易密码输入时间',
PRIMARY KEY (`sn`),
UNIQUE KEY `uuid` (`uuid`),
UNIQUE KEY `userNick` (`userNick`),
UNIQUE KEY `mobilePhone` (`mobilePhone`)
) ENGINE=InnoDB AUTO_INCREMENT=1485 DEFAULT CHARSET=utf8 COMMENT='用户表\r\n'
1 row in set (0.13 sec)
CREATE TABLE quarterly_report_status (
report_updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)
PARTITION BY RANGE ( UNIX_TIMESTAMP(report_updated) ) (
PARTITION p0 VALUES LESS THAN ( UNIX_TIMESTAMP('2015-08-13 00:00:00') ),
PARTITION p1 VALUES LESS THAN ( UNIX_TIMESTAMP('2015-08-14 00:00:00') ),
PARTITION p2 VALUES LESS THAN ( UNIX_TIMESTAMP('2015-08-15 00:00:00') ));
mysql> CREATE TABLE quarterly_report_status (
-> report_updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
-> )
-> PARTITION BY RANGE ( UNIX_TIMESTAMP(report_updated) ) (
-> PARTITION p0 VALUES LESS THAN ( UNIX_TIMESTAMP('2015-08-13 00:00:00') ),
-> PARTITION p1 VALUES LESS THAN ( UNIX_TIMESTAMP('2015-08-14 00:00:00') ),
-> PARTITION p2 VALUES LESS THAN ( UNIX_TIMESTAMP('2015-08-15 00:00:00') ));
Query OK, 0 rows affected (0.16 sec)
mysql>
mysql> desc quarterly_report_status
-> ;
+----------------+-----------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-----------+------+-----+-------------------+-----------------------------+
| report_updated | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+----------------+-----------+------+-----+-------------------+-----------------------------+
1 row in set (0.00 sec)
mysql> insert into quarterly_report_status values('2015-08-12 12:00:01');
Query OK, 1 row affected (0.01 sec)
mysql> select * from quarterly_report_status partition(p0);
+---------------------+
| report_updated |
+---------------------+
| 2015-08-12 12:00:01 |
+---------------------+
1 row in set (0.00 sec)
mysql> select * from quarterly_report_status partition(p1);
Empty set (0.00 sec)
mysql> select * from quarterly_report_status partition(p2);
Empty set (0.00 sec)
mysql> insert into quarterly_report_status values (UNIX_TIMESTAMP('2015-08-12 13:00:01'));
ERROR 1292 (22007): Incorrect datetime value: '1439355601' for column 'report_updated' at row 1
[root@pay01 ~]# date -d@1439355601 "+%Y-%m-%d"
2015-08-12
mysql> select (UNIX_TIMESTAMP('2015-08-12 13:00:01')) from quarterly_report_status;
+-----------------------------------------+
| (UNIX_TIMESTAMP('2015-08-12 13:00:01')) |
+-----------------------------------------+
| 1439355601 |
+-----------------------------------------+
1 row in set (0.00 sec)
mysql> select * from quarterly_report_status where report_updated>='2015-08-12 12:00:01' and report_updated<='2015-08-13 12:00:01';
+---------------------+
| report_updated |
+---------------------+
| 2015-08-12 12:00:01 |
| 2015-08-13 12:00:01 |
+---------------------+
2 rows in set (0.00 sec)
select * from quarterly_report_status where report_updated>=timestamp'2015-08-12 12:00:01' and report_updated<=timestamp'2015-08-13 12:00:01';
mysql> select * from quarterly_report_status where report_updated>=timestamp'2015-08-12 12:00:01' and report_updated<=timestamp'2015-08-13 12:00:01';
+---------------------+
| report_updated |
+---------------------+
| 2015-08-12 12:00:01 |
| 2015-08-13 12:00:01 |
+---------------------+
2 rows in set (0.00 sec)
mysql timestamp格式
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章