You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.7 KiB
30 lines
1.7 KiB
drop table if exists t1,t2;
|
|
create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14');
|
|
insert into t1 values ('','',0,0.0);
|
|
analyze table t1;
|
|
Table Op Msg_type Msg_text
|
|
test.t1 analyze status OK
|
|
select default(str), default(strnull), default(intg), default(rel) from t1;
|
|
default(str) default(strnull) default(intg) default(rel)
|
|
def NULL 10 3.14
|
|
explain select default(str), default(strnull), default(intg), default(rel) from t1;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 NULL
|
|
Warnings:
|
|
Note 1003 /* select#1 */ select default(`test`.`t1`.`str`) AS `default(str)`,default(`test`.`t1`.`strnull`) AS `default(strnull)`,default(`test`.`t1`.`intg`) AS `default(intg)`,default(`test`.`t1`.`rel`) AS `default(rel)` from `test`.`t1`
|
|
select * from t1 where str <> default(str);
|
|
str strnull intg rel
|
|
0 0
|
|
explain select * from t1 where str <> default(str);
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 1 100.00 Using where
|
|
Warnings:
|
|
Note 1003 /* select#1 */ select `test`.`t1`.`str` AS `str`,`test`.`t1`.`strnull` AS `strnull`,`test`.`t1`.`intg` AS `intg`,`test`.`t1`.`rel` AS `rel` from `test`.`t1` where (`test`.`t1`.`str` <> <cache>(default(`test`.`t1`.`str`)))
|
|
drop table t1;
|
|
CREATE TABLE t1 (id int(11), s varchar(20));
|
|
Warnings:
|
|
Warning 1681 Integer display width is deprecated and will be removed in a future release.
|
|
INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three');
|
|
SELECT s, 32 AS mi FROM t1 GROUP BY s HAVING DEFAULT(mi) IS NULL;
|
|
ERROR HY000: Field 'mi' doesn't have a default value
|
|
DROP TABLE t1;
|
|
|