📄 type_datetime.result
字号:
drop table if exists t1;create table t1 (t datetime);insert into t1 values (101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959),(20030100000000),(20030000000000);select * from t1;t2000-01-01 00:00:002069-12-31 00:00:001970-01-01 00:00:001999-12-31 00:00:001000-01-01 00:00:009999-12-31 00:00:002000-01-01 00:00:002069-12-31 00:00:001970-01-01 00:00:001999-12-31 23:59:591000-01-01 00:00:009999-12-31 23:59:592003-01-00 00:00:002003-00-00 00:00:00delete from t1 where t > 0;optimize table t1;Table Op Msg_type Msg_texttest.t1 optimize status OKcheck table t1;Table Op Msg_type Msg_texttest.t1 check status OKdelete from t1;insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"),("20030100000000"),("20030000000000");insert into t1 values ("2003-003-03");insert into t1 values ("20030102T131415"),("2001-01-01T01:01:01"), ("2001-1-1T1:01:01");select * from t1;t2000-01-01 00:00:002069-12-31 00:00:001970-01-01 00:00:001999-12-31 00:00:000000-01-01 00:00:000001-01-01 00:00:009999-12-31 00:00:002000-10-10 00:00:002069-12-31 00:00:001970-01-01 00:00:001999-12-31 23:59:591000-01-01 00:00:009999-12-31 23:59:592003-01-00 00:00:002003-00-00 00:00:002003-03-03 00:00:002003-01-02 13:14:152001-01-01 01:01:012001-01-01 01:01:01truncate table t1;insert into t1 values("2003-0303 12:13:14");Warnings:Warning 1264 Out of range value adjusted for column 't' at row 1select * from t1;t0000-00-00 00:00:00drop table t1;CREATE TABLE t1 (a timestamp, b date, c time, d datetime);insert into t1 (b,c,d) values(now(),curtime(),now());select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1;date_format(a,"%Y-%m-%d")=b right(a+0,6)=c+0 a=d+01 1 1drop table t1;CREATE TABLE t1 (a datetime not null);insert into t1 values (0);select * from t1 where a is null;a0000-00-00 00:00:00drop table t1;create table t1 (id int, dt datetime);insert into t1 values (1,"2001-08-14 00:00:00"),(2,"2001-08-15 00:00:00"),(3,"2001-08-16 00:00:00"),(4,"2003-09-15 01:20:30");select * from t1 where dt='2001-08-14 00:00:00' and dt = if(id=1,'2001-08-14 00:00:00','1999-08-15');id dt1 2001-08-14 00:00:00create index dt on t1 (dt);select * from t1 where dt > 20021020;id dt4 2003-09-15 01:20:30select * from t1 ignore index (dt) where dt > 20021020;id dt4 2003-09-15 01:20:30drop table t1;CREATE TABLE `t1` (`date` datetime NOT NULL default '0000-00-00 00:00:00',`numfacture` int(6) unsigned NOT NULL default '0',`expedition` datetime NOT NULL default '0000-00-00 00:00:00',PRIMARY KEY (`numfacture`),KEY `date` (`date`),KEY `expedition` (`expedition`)) ENGINE=MyISAM;INSERT INTO t1 (expedition) VALUES ('0001-00-00 00:00:00');SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';date numfacture expedition0000-00-00 00:00:00 0 0001-00-00 00:00:00INSERT INTO t1 (numfacture,expedition) VALUES ('1212','0001-00-00 00:00:00');SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';date numfacture expedition0000-00-00 00:00:00 0 0001-00-00 00:00:000000-00-00 00:00:00 1212 0001-00-00 00:00:00EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';id select_type table type possible_keys key key_len ref rows Extra1 SIMPLE t1 ref expedition expedition 8 const 1 drop table t1;create table t1 (a datetime not null, b datetime not null);insert into t1 values (now(), now());insert into t1 values (now(), now());select * from t1 where a is null or b is null;a bdrop table t1;create table t1 (t datetime);insert into t1 values (20030102030460),(20030102036301),(20030102240401),(20030132030401),(20031302030401),(100001202030401);Warnings:Warning 1264 Out of range value adjusted for column 't' at row 1Warning 1264 Out of range value adjusted for column 't' at row 2Warning 1264 Out of range value adjusted for column 't' at row 3Warning 1264 Out of range value adjusted for column 't' at row 4Warning 1264 Out of range value adjusted for column 't' at row 5Warning 1264 Out of range value adjusted for column 't' at row 6select * from t1;t0000-00-00 00:00:000000-00-00 00:00:000000-00-00 00:00:000000-00-00 00:00:000000-00-00 00:00:000000-00-00 00:00:00delete from t1;insert into t1 values("2003-01-02 03:04:60"),("2003-01-02 03:63:01"),("2003-01-02 24:04:01"),("2003-01-32 03:04:01"),("2003-13-02 03:04:01"), ("10000-12-02 03:04:00");Warnings:Warning 1264 Out of range value adjusted for column 't' at row 1Warning 1264 Out of range value adjusted for column 't' at row 2Warning 1264 Out of range value adjusted for column 't' at row 3Warning 1264 Out of range value adjusted for column 't' at row 4Warning 1264 Out of range value adjusted for column 't' at row 5Warning 1264 Out of range value adjusted for column 't' at row 6select * from t1;t0000-00-00 00:00:000000-00-00 00:00:000000-00-00 00:00:000000-00-00 00:00:000000-00-00 00:00:000000-00-00 00:00:00delete from t1;insert into t1 values ("0000-00-00 00:00:00 some trailer"),("2003-01-01 00:00:00 some trailer");Warnings:Warning 1264 Out of range value adjusted for column 't' at row 1Warning 1264 Out of range value adjusted for column 't' at row 2select * from t1;t0000-00-00 00:00:002003-01-01 00:00:00drop table t1;create table t1 (dt datetime);insert into t1 values ("12-00-00"), ("00-00-00 01:00:00");insert into t1 values ("00-00-00"), ("00-00-00 00:00:00");select * from t1;dt2012-00-00 00:00:002000-00-00 01:00:000000-00-00 00:00:000000-00-00 00:00:00drop table t1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -