1
drop table if exists t1;
2
create table t1(n1 int, n2 int, s char(20), vs varchar(20), t text);
3
insert into t1 values (1,11, 'one','eleven', 'eleven'),
4
(1,11, 'one','eleven', 'eleven'),
5
(2,11, 'two','eleven', 'eleven'),
6
(2,12, 'two','twevle', 'twelve'),
7
(2,13, 'two','thirteen', 'foo'),
8
(2,13, 'two','thirteen', 'foo'),
9
(2,13, 'two','thirteen', 'bar'),
10
(NULL,13, 'two','thirteen', 'bar'),
11
(2,NULL, 'two','thirteen', 'bar'),
12
(2,13, NULL,'thirteen', 'bar'),
13
(2,13, 'two',NULL, 'bar'),
14
(2,13, 'two','thirteen', NULL);
15
select distinct n1 from t1;
20
select count(distinct n1) from t1;
23
select distinct n2 from t1;
29
select count(distinct n2) from t1;
32
select distinct s from t1;
37
select count(distinct s) from t1;
40
select distinct vs from t1;
46
select count(distinct vs) from t1;
49
select distinct t from t1;
56
select count(distinct t) from t1;
59
select distinct n1,n2 from t1;
67
select count(distinct n1,n2) from t1;
70
select distinct n1,s from t1;
76
select count(distinct n1,s) from t1;
79
select distinct s,n1,vs from t1;
88
select count(distinct s,n1,vs) from t1;
89
count(distinct s,n1,vs)
91
select distinct s,t from t1;
100
select count(distinct s,t) from t1;
103
select count(distinct n1), count(distinct n2) from t1;
104
count(distinct n1) count(distinct n2)
106
select count(distinct n2), n1 from t1 group by n1;
107
count(distinct n2) n1
112
create table t1 (n int default NULL);
114
select count(distinct n) from t1;
117
show status like 'Created_tmp_disk_tables';
119
Created_tmp_disk_tables 0
121
create table t1 (s text);
123
select count(distinct s) from t1;
126
show status like 'Created_tmp_disk_tables';
128
Created_tmp_disk_tables 1