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
123
122
e decimal(3,1) NO NULL
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);
249
247
create table t1 select 1,2,3;
250
248
create table if not exists t1 select 1,2;
249
ERROR HY000: Field '1' doesn't have a default value
251
250
create table if not exists t1 select 1,2,3,4;
251
ERROR 21S01: Column count doesn't match value count at row 1
252
252
create table if not exists t1 select 1;
253
ERROR HY000: Field '1' doesn't have a default value
253
254
select * from t1;
388
389
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);
391
create table t1(a int,b int,c int,d date,e char,f datetime,h blob);
391
392
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');
393
insert into t1(a,b,c,d,e,f,h)
394
values(2,-2,2,'1825-12-14','a','2003-01-01 03:02:01','binary data');
394
395
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
397
1 NULL NULL NULL NULL NULL NULL
398
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 binary data
399
400
ifnull(b,-7) as b,
400
401
ifnull(c,7) as c,
401
402
ifnull(d,cast('2000-01-01' as date)) as d,
402
403
ifnull(e,cast('b' as char)) as e,
403
404
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
405
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
408
1 -7 7 2000-01-01 b 2000-01-01 00:00:00 yet another binary data
409
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 binary data
416
415
ifnull(d,cast('2000-01-01' as date)) as d,
417
416
ifnull(e,cast('b' as char)) as e,
418
417
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
418
ifnull(h,cast('yet another binary data' as binary)) as h
424
421
Field Type Null Key Default Extra
429
426
e varchar(1) YES NULL
430
427
f datetime YES NULL
434
429
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
431
1 -7 7 2000-01-01 b 2000-01-01 00:00:00 yet another binary data
432
2 -2 2 1825-12-14 a 2003-01-01 03:02:01 binary data
438
433
drop table t1, t2;
439
434
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
435
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
444
`ifnull(g,g)` double(4,3) DEFAULT NULL,
450
445
`ifnull(h,h)` decimal(5,4) DEFAULT NULL,
451
446
`ifnull(j,j)` date DEFAULT NULL,
452
`ifnull(k,k)` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
447
`ifnull(k,k)` timestamp NULL DEFAULT NULL,
453
448
`ifnull(l,l)` datetime DEFAULT NULL,
454
449
`ifnull(m,m)` varchar(1) DEFAULT NULL,
455
450
`ifnull(o,o)` varchar(10) DEFAULT NULL
691
687
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
692
688
create table t1 (i int);
693
689
create table if not exists t1 select 1 as i;
691
Note 1050 Table 't1' already exists
694
692
select * from t1;
697
696
create table t1 select coalesce('a' collate utf8_swedish_ci,'b' collate utf8_bin);
698
697
ERROR HY000: Illegal mix of collations (utf8_swedish_ci,EXPLICIT) and (utf8_bin,EXPLICIT) for operation 'coalesce'