summaryrefslogtreecommitdiff
path: root/mysql-test/t/type_datetime.test
blob: eed3f831383e6ae4931ecd9bce8808f9c731c0cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#
# testing different DATETIME ranges
#

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);
select * from t1;
delete from t1 where t > 0;
optimize table t1;
check table t1;
insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959");
select * from t1;
drop table t1;

#
# Test insert of now() and curtime()
#

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,6)=c+0,a=d+0 from t1;
drop table t1;

#
# Test of datetime and not null
#

CREATE TABLE t1 (a datetime not null);
insert into t1 values (0);
select * from t1 where a is null;
drop table t1;

#
# Test of datetime optimization
#

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`)
) TYPE=MyISAM;

INSERT INTO t1 (expedition) VALUES ('0001-00-00 00:00:00');
SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
INSERT INTO t1 (numfacture,expedition) VALUES ('1212','0001-00-00 00:00:00');
SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
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;
drop table t1;