113
113
Field Type Null Key Default Extra
114
114
x varchar(50) YES NULL
116
create table t2 select now() as a , curtime() as b, curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f;
116
create table t2 select now() as a , curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f;
118
118
Field Type Null Key Default Extra
119
119
a datetime YES NULL
121
120
c date NO 0000-00-00
123
122
e decimal(3,1) NO 0.0
126
create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("20:45:11" AS TIME) as t, CAST("2001-12-29 20:45:11" AS DATETIME) as dt;
125
create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("2001-12-29 20:45:11" AS DATETIME) as dt;
128
127
Field Type Null Key Default Extra
131
129
dt datetime YES NULL
132
130
drop table t1,t2;
133
131
create table t1 (a int);
388
386
SET SESSION storage_engine=default;
390
create table t1(a int,b int,c int,d date,e char,f datetime,g time,h blob);
388
create table t1(a int,b int,c int,d date,e char,f datetime,h blob);
391
389
insert into t1(a)values(1);
392
insert into t1(a,b,c,d,e,f,g,h)
393
values(2,-2,2,'1825-12-14','a','2003-01-01 03:02:01','4:3:2','binary data');
390
insert into t1(a,b,c,d,e,f,h)
391
values(2,-2,2,'1825-12-14','a','2003-01-01 03:02:01','binary data');
394
392
select * from t1;
396
1 NULL NULL NULL NULL NULL NULL NULL
397
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data
394
1 NULL NULL NULL NULL NULL NULL
395
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 binary data
399
397
ifnull(b,-7) as b,
400
398
ifnull(c,7) as c,
401
399
ifnull(d,cast('2000-01-01' as date)) as d,
402
400
ifnull(e,cast('b' as char)) as e,
403
401
ifnull(f,cast('2000-01-01' as datetime)) as f,
404
ifnull(g,cast('5:4:3' as time)) as g,
405
ifnull(h,cast('yet another binary data' as binary)) as h,
406
addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd
402
ifnull(h,cast('yet another binary data' as binary)) as h
409
1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00
410
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00
405
1 -7 7 2000-01-01 b 2000-01-01 00:00:00 yet another binary data
406
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 binary data
416
412
ifnull(d,cast('2000-01-01' as date)) as d,
417
413
ifnull(e,cast('b' as char)) as e,
418
414
ifnull(f,cast('2000-01-01' as datetime)) as f,
419
ifnull(g,cast('5:4:3' as time)) as g,
420
ifnull(h,cast('yet another binary data' as binary)) as h,
421
addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd
415
ifnull(h,cast('yet another binary data' as binary)) as h
424
418
Field Type Null Key Default Extra
429
423
e varchar(1) YES NULL
430
424
f datetime YES NULL
434
426
select * from t2;
436
1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00
437
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00
428
1 -7 7 2000-01-01 b 2000-01-01 00:00:00 yet another binary data
429
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 binary data
438
430
drop table t1, t2;
439
431
create table t1 (a int, b int, d int, e bigint, f float(3,2), g double(4,3), h decimal(5,4), j date, k timestamp, l datetime, m enum('a','b'), o char(10));
440
432
create table t2 select ifnull(a,a), ifnull(b,b), ifnull(d,d), ifnull(e,e), ifnull(f,f), ifnull(g,g), ifnull(h,h), ifnull(j,j), ifnull(k,k), ifnull(l,l), ifnull(m,m), ifnull(o,o) from t1;
449
441
`ifnull(g,g)` double(4,3) DEFAULT NULL,
450
442
`ifnull(h,h)` decimal(5,4) DEFAULT NULL,
451
443
`ifnull(j,j)` date DEFAULT NULL,
452
`ifnull(k,k)` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
444
`ifnull(k,k)` timestamp NULL DEFAULT NULL,
453
445
`ifnull(l,l)` datetime DEFAULT NULL,
454
446
`ifnull(m,m)` varchar(1) DEFAULT NULL,
455
447
`ifnull(o,o)` varchar(10) DEFAULT NULL