1
1
drop table if exists t1,t2,t3;
2
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=MEMORY comment="testing heaps";
2
create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
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 (c,a);
29
create temporary table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps";
26
create table t1 (a int not null,b int not null, primary key (a)) engine=memory 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 (a)) engine=MEMORY comment="testing heaps";
32
create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps";
36
33
insert into t1 values(1,1),(2,2),(3,3),(4,4);
37
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 # # # # #
34
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
72
create temporary table t2 SELECT * FROM t1;
73
explain select * from t2 where a in (869751,736494,226312,802616);
66
alter table t1 engine=myisam;
67
explain select * from t1 where a in (869751,736494,226312,802616);
74
68
id select_type table type possible_keys key key_len ref rows Extra
75
1 SIMPLE t2 ALL NULL NULL NULL NULL 5 Using where
77
create temporary table t1 (x int not null, y int not null, key x (x), unique y (y))
69
1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
71
create table t1 (x int not null, y int not null, key x (x), unique y (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;
84
78
select * from t1,t1 as t2 where t1.x=t2.y;
85
ERROR HY000: Can't reopen table: 't1'
86
86
explain select * from t1,t1 as t2 where t1.x=t2.y;
87
ERROR HY000: Can't reopen table: 't1'
87
id select_type table type possible_keys key key_len ref rows Extra
88
1 SIMPLE t1 ALL x NULL NULL NULL 6
89
1 SIMPLE t2 eq_ref y y 4 test.t1.x 1
89
create temporary table t1 (a int) engine=MEMORY;
91
create table t1 (a int) engine=heap;
90
92
insert into t1 values(1);
91
93
select max(a) from t1;
95
CREATE TEMPORARY TABLE t1 ( a int not null default 0, b int not null default 0, key(a), key(b) ) ENGINE=MEMORY;
97
CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key(a), key(b) ) ENGINE=HEAP;
96
98
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
97
99
select * from t1 where a=1;
130
132
replace into t1 values(1);
132
create temporary table t1 (n int) engine=MEMORY;
134
create table t1 (n int) engine=heap;
134
create temporary table t1 (n int) engine=MEMORY;
136
create table t1 (n int) engine=heap;
135
137
drop table if exists t1;
136
CREATE TEMPORARY table t1(f1 int not null,f2 char(20) not
137
null,index(f2)) engine=MEMORY;
138
CREATE table t1(f1 int not null,f2 char(20) not
139
null,index(f2)) engine=heap;
138
140
INSERT into t1 set f1=12,f2="bill";
139
141
INSERT into t1 set f1=13,f2="bill";
140
142
INSERT into t1 set f1=14,f2="bill";
195
197
INSERT INTO t1 VALUES (1,3);
196
198
ERROR 23000: Duplicate entry '3' for key 'b'
198
CREATE TEMPORARY TABLE t1 (
199
201
a int default NULL,
202
204
INSERT INTO t1 VALUES (10), (10), (10);
203
205
EXPLAIN SELECT * FROM t1 WHERE a=10;
204
206
id select_type table type possible_keys key key_len ref rows Extra
205
1 SIMPLE t1 ref a a 5 const 3 Using where
207
1 SIMPLE t1 ref a a 5 const 3
206
208
SELECT * FROM t1 WHERE a=10;
212
CREATE TEMPORARY TABLE t1 (a int not null, primary key(a)) engine=MEMORY;
214
CREATE TABLE t1 (a int not null, primary key(a)) engine=heap;
213
215
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
214
216
DELETE from t1 where a < 100;
215
217
SELECT * from t1;
218
CREATE TEMPORARY TABLE `job_titles` (
220
CREATE TABLE `job_titles` (
219
221
`job_title_id` int NOT NULL default '0',
220
222
`job_title` char(18) NOT NULL default '',
221
223
PRIMARY KEY (`job_title_id`),
222
224
UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
224
226
SELECT MAX(job_title_id) FROM job_titles;
225
227
MAX(job_title_id)
227
229
DROP TABLE job_titles;
228
CREATE TEMPORARY TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=MEMORY;
230
CREATE TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP;
229
231
INSERT INTO t1 VALUES(1,1), (1,NULL);
230
232
SELECT * FROM t1 WHERE B is not null;
234
CREATE TEMPORARY TABLE t1 (pseudo char(35) PRIMARY KEY, date int NOT NULL) ENGINE=MEMORY;
236
CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int NOT NULL) ENGINE=HEAP;
235
237
INSERT INTO t1 VALUES ('massecot',1101106491),('altec',1101106492),('stitch+',1101106304),('Seb Corgan',1101106305),('beerfilou',1101106263),('flaker',1101106529),('joce8',5),('M4vrick',1101106418),('gabay008',1101106525),('Vamp irX',1101106291),('ZoomZip',1101106546),('rip666',1101106502),('CBP ',1101106397),('guezpard',1101106496);
236
238
DELETE FROM t1 WHERE date<1101106546;
237
239
SELECT * FROM t1;
239
241
ZoomZip 1101106546
241
create temporary table t1(a char(2)) engine=memory;
243
create table t1(a char(2)) engine=memory;
242
244
insert into t1 values (NULL), (NULL);
243
245
delete from t1 where a is null;
244
246
insert into t1 values ('2'), ('3');
250
set storage_engine=MEMORY;
251
create temporary table t1 (v varchar(10), c char(10), t varchar(50));
252
set storage_engine=HEAP;
253
create table t1 (v varchar(10), c char(10), t varchar(50));
252
254
insert into t1 values('+ ', '+ ', '+ ');
253
255
set @a=repeat(' ',20);
254
256
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
255
ERROR 22001: Data too long for column 'v' at row 1
256
set @a=repeat(' ',10);
257
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
258
ERROR 22001: Data too long for column 'v' at row 1
259
set @a=repeat(' ',9);
260
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
258
Note 1265 Data truncated for column 'v' at row 1
259
Note 1265 Data truncated for column 'c' at row 1
261
260
select concat('*',v,'*',c,'*',t,'*') from t1;
262
261
concat('*',v,'*',c,'*',t,'*')
265
264
show create table t1;
266
265
Table Create Table
267
t1 CREATE TEMPORARY TABLE `t1` (
268
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
269
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
270
`t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL
271
) ENGINE=MEMORY COLLATE = utf8_general_ci
272
create temporary table t2 like t1;
266
t1 CREATE TABLE `t1` (
271
create table t2 like t1;
273
272
show create table t2;
274
273
Table Create Table
275
t2 CREATE TEMPORARY TABLE `t2` (
276
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
277
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
278
`t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL
279
) ENGINE=MEMORY COLLATE = utf8_general_ci
280
create temporary table t3 select * from t1;
274
t2 CREATE TABLE `t2` (
279
create table t3 select * from t1;
281
280
show create table t3;
282
281
Table Create Table
283
t3 CREATE TEMPORARY TABLE `t3` (
284
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
285
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
286
`t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL
287
) ENGINE=MEMORY COLLATE = utf8_general_ci
282
t3 CREATE TABLE `t3` (
288
287
alter table t1 modify c varchar(10);
289
288
show create table t1;
290
289
Table Create Table
291
t1 CREATE TEMPORARY TABLE `t1` (
292
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
293
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
294
`t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL
295
) ENGINE=MEMORY COLLATE = utf8_general_ci
290
t1 CREATE TABLE `t1` (
296
295
alter table t1 modify v char(10);
297
296
show create table t1;
298
297
Table Create Table
299
t1 CREATE TEMPORARY TABLE `t1` (
300
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
301
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
302
`t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL
303
) ENGINE=MEMORY COLLATE = utf8_general_ci
298
t1 CREATE TABLE `t1` (
304
303
alter table t1 modify t varchar(50);
305
304
show create table t1;
306
305
Table Create Table
307
t1 CREATE TEMPORARY TABLE `t1` (
308
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
309
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
310
`t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL
311
) ENGINE=MEMORY COLLATE = utf8_general_ci
306
t1 CREATE TABLE `t1` (
312
311
select concat('*',v,'*',c,'*',t,'*') from t1;
313
312
concat('*',v,'*',c,'*',t,'*')
316
315
drop table t1,t2,t3;
317
create temporary table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
316
create table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
318
317
show create table t1;
319
318
Table Create Table
320
t1 CREATE TEMPORARY TABLE `t1` (
321
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
322
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
323
`t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL,
319
t1 CREATE TABLE `t1` (
327
) ENGINE=MEMORY COLLATE = utf8_general_ci
328
327
select count(*) from t1;
531
530
insert into t1 values ('a ');
532
531
ERROR 23000: Duplicate entry 'a ' for key 'a'
533
532
insert into t1 values ('a ');
534
ERROR 22001: Data too long for column 'a' at row 1
533
ERROR 23000: Duplicate entry 'a ' for key 'a'
535
534
insert into t1 values ('a ');
536
535
ERROR 23000: Duplicate entry 'a ' for key 'a'
537
536
update t1 set a='a ' where a like 'a ';
538
537
update t1 set a='a ' where a like 'a ';
540
create temporary table t1 (v varchar(10), c char(10), t varchar(50), key using btree (v), key using btree (c), key using btree (t(10)));
539
create table t1 (v varchar(10), c char(10), t varchar(50), key using btree (v), key using btree (c), key using btree (t(10)));
541
540
show create table t1;
542
541
Table Create Table
543
t1 CREATE TEMPORARY TABLE `t1` (
544
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
545
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
546
`t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL,
542
t1 CREATE TABLE `t1` (
547
546
KEY `v` (`v`) USING BTREE,
548
547
KEY `c` (`c`) USING BTREE,
549
KEY `t` (`t`(10)) USING BTREE
550
) ENGINE=MEMORY COLLATE = utf8_general_ci
548
KEY `t` (`t`()) USING BTREE
551
550
select count(*) from t1;
622
621
insert into t1 values ('a ');
623
622
ERROR 23000: Duplicate entry 'a ' for key 'a'
624
623
insert into t1 values ('a ');
625
ERROR 22001: Data too long for column 'a' at row 1
624
ERROR 23000: Duplicate entry 'a ' for key 'a'
626
625
insert into t1 values ('a ');
627
626
ERROR 23000: Duplicate entry 'a ' for key 'a'
628
627
update t1 set a='a ' where a like 'a ';
629
628
update t1 set a='a ' where a like 'a ';
631
create temporary table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
630
create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
632
631
show create table t1;
633
632
Table Create Table
634
t1 CREATE TEMPORARY TABLE `t1` (
635
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
636
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
637
`t` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL,
641
) ENGINE=MEMORY COLLATE = utf8_general_ci
633
t1 CREATE TABLE `t1` (
643
create temporary table t1 (v varchar(16383), key(v(10)));
642
create table t1 (v varchar(16383), key(v(10)));
644
643
show create table t1;
645
644
Table Create Table
646
t1 CREATE TEMPORARY TABLE `t1` (
647
`v` VARCHAR(16383) COLLATE utf8_general_ci DEFAULT NULL,
649
) ENGINE=MEMORY COLLATE = utf8_general_ci
645
t1 CREATE TABLE `t1` (
650
649
insert into t1 values(repeat('a',16383));
651
650
select length(v) from t1 where v=repeat('a',16383);
655
654
set storage_engine=InnoDB;
656
create temporary table t1 (a bigint auto_increment primary key, b int,
657
key (b, a)) engine=MEMORY;
655
create table t1 (a bigint auto_increment primary key, b int,
656
key (b, a)) engine=heap;
658
657
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
659
658
select * from t1;
684
create temporary table t1 (a int not null, b int not null auto_increment,
685
primary key(a, b)) engine=MEMORY;
683
create table t1 (a int not null, b int not null auto_increment,
684
primary key(a, b)) engine=heap;
686
685
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
687
create temporary table t1 (c char(255), primary key(c(90)));
686
create table t1 (c char(255), primary key(c(90)));
688
687
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
689
688
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
690
689
ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 'PRIMARY'
692
CREATE TEMPORARY TABLE t1 (a int, key(a)) engine=MEMORY;
691
CREATE TABLE t1 (a int, key(a)) engine=heap;
693
692
insert into t1 values (0);
695
694
select * from t1;
702
create temporary table t1 (c char(10)) engine=memory;
703
create temporary table t2 (c varchar(10)) engine=memory;
701
create table t1 (c char(10)) engine=memory;
702
create table t2 (c varchar(10)) engine=memory;
704
703
show table status like 't_';
705
Session Schema Name Type Engine Version Rows Avg_row_length Table_size Auto_increment
706
# test t1 TEMPORARY MEMORY # # # # #
707
# test t2 TEMPORARY MEMORY # # # # #
704
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
705
t1 MEMORY 10 Fixed 0 42 0 # 0 0 NULL NULL NULL NULL utf8_general_ci NULL
706
t2 MEMORY 10 Fixed 0 42 0 # 0 0 NULL NULL NULL NULL utf8_general_ci NULL
708
707
drop table t1, t2;
709
CREATE TEMPORARY TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
708
CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
710
709
KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY;
711
710
INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256));
712
711
SELECT COUNT(*) FROM t1 WHERE a='a';