1
1
drop table if exists t1,t2;
2
create temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=MEMORY comment="testing heaps";
2
create temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps";
3
3
insert into t1 values(1,1),(2,2),(3,3),(4,4);
4
4
delete from t1 where a=1 or a=0;
5
show table status like "t1";
6
Session Schema Name Type Engine Version Rows Avg_row_length Table_size Auto_increment
7
# test t1 TEMPORARY MEMORY # # # # #
9
Table Unique Key_name Seq_in_index Column_name
6
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
7
t1 0 PRIMARY 1 a NULL 3 NULL NULL HASH
27
24
alter table t1 add c int not null, add key using HASH (c,a);
29
create temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=MEMORY comment="testing heaps";
26
create temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps";
30
27
insert into t1 values(1,1),(2,2),(3,3),(4,4);
31
28
delete from t1 where a > 0;
35
create temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=MEMORY comment="testing heaps";
32
create temporary table t1 (a int not null,b int not null, primary key using HASH (a)) engine=heap comment="testing heaps";
36
33
insert into t1 values(1,1),(2,2),(3,3),(4,4);
37
34
alter table t1 modify a int not null auto_increment, engine=innodb, comment="new innodb table";
38
show table status like "t1";
39
Session Schema Name Type Engine Version Rows Avg_row_length Table_size Auto_increment
40
# test t1 TEMPORARY InnoDB # # # # #
48
create temporary table t1 (a int not null) engine=MEMORY;
42
create temporary table t1 (a int not null) engine=heap;
49
43
insert into t1 values (869751),(736494),(226312),(802616),(728912);
50
44
select * from t1 where a > 736494;
75
69
1 SIMPLE t1 index uniq_id uniq_id 4 NULL 5 Using where; Using index
77
71
create temporary table t1 (x int not null, y int not null, key x using HASH (x), unique y using HASH (y))
79
73
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
80
74
select * from t1 where x=1;
86
80
explain select * from t1,t1 as t2 where t1.x=t2.y;
87
81
ERROR HY000: Can't reopen table: 't1'
89
create temporary table t1 (a int) engine=MEMORY;
83
create temporary table t1 (a int) engine=heap;
90
84
insert into t1 values(1);
91
85
select max(a) from t1;
95
CREATE TEMPORARY TABLE t1 ( a int not null default 0, b int not null default 0, key using HASH (a), key using HASH (b) ) ENGINE=MEMORY;
89
CREATE TEMPORARY TABLE t1 ( a int not null default 0, b int not null default 0, key using HASH (a), key using HASH (b) ) ENGINE=HEAP;
96
90
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
97
91
select * from t1 where a=1;
130
124
replace into t1 values(1);
132
create temporary table t1 (n int) engine=MEMORY;
126
create temporary table t1 (n int) engine=heap;
134
create temporary table t1 (n int) engine=MEMORY;
128
create temporary table t1 (n int) engine=heap;
135
129
drop table if exists t1;
136
130
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not
137
null,index(f2)) engine=MEMORY;
131
null,index(f2)) engine=heap;
138
132
INSERT into t1 set f1=12,f2="bill";
139
133
INSERT into t1 set f1=13,f2="bill";
140
134
INSERT into t1 set f1=14,f2="bill";
156
create temporary table t1 (btn char(10) not null, key using HASH (btn)) engine=MEMORY;
150
create temporary table t1 (btn char(10) not null, key using HASH (btn)) engine=heap;
157
151
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
158
152
explain select * from t1 where btn like "q%";
159
153
id select_type table type possible_keys key key_len ref rows Extra
174
168
b int default NULL,
175
169
KEY a using HASH (a),
176
170
UNIQUE b using HASH (b)
178
172
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
179
173
SELECT * FROM t1 WHERE a=NULL;
195
189
INSERT INTO t1 VALUES (1,3);
196
190
ERROR 23000: Duplicate entry '3' for key 'b'
198
CREATE TEMPORARY TABLE t1 (a int not null, primary key using HASH (a)) engine=MEMORY;
192
CREATE TEMPORARY TABLE t1 (a int not null, primary key using HASH (a)) engine=heap;
199
193
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
200
194
DELETE from t1 where a < 100;
201
195
SELECT * from t1;
207
201
b char(20) not null,
211
205
insert into t1 values ('aaaa', 'prefill-hash=5',0);
212
206
insert into t1 values ('aaab', 'prefill-hash=0',0);
213
207
insert into t1 values ('aaac', 'prefill-hash=7',0);
277
271
name varchar(20) not null,
278
272
index heap_idx(name),
279
273
index btree_idx using btree(name)
281
275
create temporary table t2 (
282
276
id int not null primary key auto_increment,
283
277
name varchar(20) not null,
284
278
index btree_idx using btree(name),
285
279
index heap_idx(name)
287
281
insert into t1 (name) values ('Matt'), ('Lilu'), ('Corbin'), ('Carly'),
288
282
('Suzy'), ('Hoppy'), ('Burrito'), ('Mimi'), ('Sherry'), ('Ben'), ('Phil'),
289
283
('Emily'), ('Mike');
326
320
id select_type table type possible_keys key key_len ref rows Extra
327
321
1 SIMPLE t1 ref heap_idx heap_idx 82 const 9 Using where
328
322
show index from t1;
329
Table Unique Key_name Seq_in_index Column_name
331
t1 FALSE heap_idx 1 name
332
t1 FALSE btree_idx 1 name
323
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
324
t1 0 PRIMARY 1 id NULL 91 NULL NULL HASH
325
t1 1 heap_idx 1 name NULL 10 NULL NULL HASH
326
t1 1 btree_idx 1 name A NULL NULL NULL BTREE
333
327
show index from t1;
334
Table Unique Key_name Seq_in_index Column_name
336
t1 FALSE heap_idx 1 name
337
t1 FALSE btree_idx 1 name
328
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
329
t1 0 PRIMARY 1 id NULL 91 NULL NULL HASH
330
t1 1 heap_idx 1 name NULL 10 NULL NULL HASH
331
t1 1 btree_idx 1 name A NULL NULL NULL BTREE
338
332
create temporary table t3
340
334
a varchar(20) not null,
341
335
b varchar(20) not null,
344
338
insert into t3 select name, name from t1;
345
339
show index from t3;
346
Table Unique Key_name Seq_in_index Column_name
340
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
341
t3 1 a 1 a NULL NULL NULL NULL HASH
342
t3 1 a 2 b NULL 13 NULL NULL HASH
349
343
show index from t3;
350
Table Unique Key_name Seq_in_index Column_name
344
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
345
t3 1 a 1 a NULL NULL NULL NULL HASH
346
t3 1 a 2 b NULL 13 NULL NULL HASH
353
347
explain select * from t1 ignore key(btree_idx), t3 where t1.name='matt' and t3.a = concat('',t1.name) and t3.b=t1.name;
354
348
id select_type table type possible_keys key key_len ref rows Extra
355
349
1 SIMPLE t1 ref heap_idx heap_idx 82 const 9 Using where
356
350
1 SIMPLE t3 ref a a 164 func,const 7 Using where
357
351
drop table t1, t2, t3;
358
create temporary table t1 ( a int, index (a) ) engine=memory;
352
create temporary temporary table t1 ( a int, index (a) ) engine=memory;
359
353
insert into t1 values (1),(2),(3),(4),(5);
360
354
select a from t1 where a in (1,3);