~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
drop table if exists t1,t2,t3;
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
insert into t1 values(1,1),(2,2),(3,3),(4,4);
4
delete from t1 where a=1 or a=0;
5
show keys from t1;
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		
8
select * from t1;
9
a	b
10
2	2
11
3	3
12
4	4
13
select * from t1 where a=4;
14
a	b
15
4	4
16
update t1 set b=5 where a=4;
17
update t1 set b=b+1 where a>=3;
18
replace t1 values (3,3);
19
select * from t1;
20
a	b
21
2	2
22
3	3
23
4	6
24
alter table t1 add c int not null, add key (c,a);
25
drop table t1;
26
create table t1 (a int not null,b int not null, primary key (a)) engine=memory comment="testing heaps";
27
insert into t1 values(1,1),(2,2),(3,3),(4,4);
28
delete from t1 where a > 0;
29
select * from t1;
30
a	b
31
drop table t1;
32
create table t1 (a int not null,b int not null, primary key (a)) engine=heap comment="testing heaps";
33
insert into t1 values(1,1),(2,2),(3,3),(4,4);
34
alter table t1 modify a int not null auto_increment, engine=myisam, comment="new myisam table";
35
select * from t1;
36
a	b
37
1	1
38
2	2
39
3	3
40
4	4
41
drop table t1;
42
create table t1 (a int not null) engine=heap;
43
insert into t1 values (869751),(736494),(226312),(802616),(728912);
44
select * from t1 where a > 736494;
45
a
46
869751
47
802616
48
alter table t1 add unique uniq_id(a);
49
select * from t1 where a > 736494;
50
a
51
869751
52
802616
53
select * from t1 where a = 736494;
54
a
55
736494
56
select * from t1 where a=869751 or a=736494;
57
a
58
736494
59
869751
60
select * from t1 where a in (869751,736494,226312,802616);
61
a
62
226312
63
736494
64
802616
65
869751
66
alter table t1 engine=myisam;
67
explain select * from t1 where a in (869751,736494,226312,802616);
68
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
69
1	SIMPLE	t1	range	uniq_id	uniq_id	4	NULL	4	Using where; Using index
70
drop table t1;
71
create table t1 (x int not null, y int not null, key x (x), unique y (y))
72
engine=heap;
73
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
74
select * from t1 where x=1;
75
x	y
76
1	3
77
1	1
78
select * from t1,t1 as t2 where t1.x=t2.y;
79
x	y	x	y
80
1	1	1	1
81
2	2	2	2
82
1	3	1	1
83
2	4	2	2
84
2	5	2	2
85
2	6	2	2
86
explain select * from t1,t1 as t2 where t1.x=t2.y;
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	
90
drop table t1;
91
create table t1 (a int) engine=heap;
92
insert into t1 values(1);
93
select max(a) from t1;
94
max(a)
95
1
96
drop table t1;
97
CREATE TABLE t1 ( a int not null default 0, b int not null default 0,  key(a),  key(b)  ) ENGINE=HEAP;
98
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
99
select * from t1 where a=1;
100
a	b
101
1	6
102
1	5
103
1	4
104
1	3
105
1	2
106
1	1
107
insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
108
select * from t1 where a=1;
109
a	b
110
1	6
111
1	5
112
1	4
113
1	3
114
1	2
115
1	1
116
1	6
117
1	5
118
1	4
119
1	3
120
1	2
121
1	1
122
drop table t1;
123
create table t1 (id int unsigned not null, primary key (id)) engine=HEAP;
124
insert into t1 values(1);
125
select max(id) from t1;
126
max(id)
127
1
128
insert into t1 values(2);
129
select max(id) from t1;
130
max(id)
131
2
132
replace into t1 values(1);
133
drop table t1;
134
create table t1 (n int) engine=heap;
135
drop table t1;
136
create table t1 (n int) engine=heap;
137
drop table if exists t1;
138
CREATE table t1(f1 int not null,f2 char(20) not 
139
null,index(f2)) engine=heap;
140
INSERT into t1 set f1=12,f2="bill";
141
INSERT into t1 set f1=13,f2="bill";
142
INSERT into t1 set f1=14,f2="bill";
143
INSERT into t1 set f1=15,f2="bill";
144
INSERT into t1 set f1=16,f2="ted";
145
INSERT into t1 set f1=12,f2="ted";
146
INSERT into t1 set f1=12,f2="ted";
147
INSERT into t1 set f1=12,f2="ted";
148
INSERT into t1 set f1=12,f2="ted";
149
delete from t1 where f2="bill";
150
select * from t1;
151
f1	f2
152
16	ted
153
12	ted
154
12	ted
155
12	ted
156
12	ted
157
drop table t1;
158
create table t1 (btn char(10) not null, key(btn)) engine=heap;
159
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
160
explain select * from t1 where btn like "q%";
161
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
162
1	SIMPLE	t1	ALL	btn	NULL	NULL	NULL	14	Using where
163
select * from t1 where btn like "q%";
164
btn
165
alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn;
166
update t1 set new_col=left(btn,1);
167
explain select * from t1 where btn="a";
168
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
169
1	SIMPLE	t1	ALL	btn	NULL	NULL	NULL	14	Using where
170
explain select * from t1 where btn="a" and new_col="a";
171
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
172
1	SIMPLE	t1	ref	btn	btn	11	const,const	2	Using where
173
drop table t1;
174
CREATE TABLE t1 (
175
a int default NULL,
176
b int default NULL,
177
KEY a (a),
178
UNIQUE b (b)
179
) engine=heap;
180
INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
181
SELECT * FROM t1 WHERE a=NULL;
182
a	b
183
explain SELECT * FROM t1 WHERE a IS NULL;
184
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
185
1	SIMPLE	t1	ref	a	a	5	const	2	Using where
186
SELECT * FROM t1 WHERE a<=>NULL;
187
a	b
188
NULL	99
189
SELECT * FROM t1 WHERE b=NULL;
190
a	b
191
explain SELECT * FROM t1 WHERE b IS NULL;
192
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
193
1	SIMPLE	t1	ref	b	b	5	const	1	Using where
194
SELECT * FROM t1 WHERE b<=>NULL;
195
a	b
196
99	NULL
197
INSERT INTO t1 VALUES (1,3);
198
ERROR 23000: Duplicate entry '3' for key 'b'
199
DROP TABLE t1;
200
CREATE TABLE t1 (
201
a int default NULL,
202
key a (a)
203
) ENGINE=HEAP;
204
INSERT INTO t1 VALUES (10), (10), (10);
205
EXPLAIN SELECT * FROM t1 WHERE a=10;
206
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
207
1	SIMPLE	t1	ref	a	a	5	const	3	
208
SELECT * FROM t1 WHERE a=10;
209
a
210
10
211
10
212
10
213
DROP TABLE t1;
214
CREATE TABLE t1 (a int not null, primary key(a)) engine=heap;
215
INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
216
DELETE from t1 where a < 100;
217
SELECT * from t1;
218
a
219
DROP TABLE t1;
220
CREATE TABLE `job_titles` (
221
`job_title_id` int(6) unsigned NOT NULL default '0',
222
`job_title` char(18) NOT NULL default '',
223
PRIMARY KEY  (`job_title_id`),
224
UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
225
) ENGINE=HEAP;
226
SELECT MAX(job_title_id) FROM job_titles;
227
MAX(job_title_id)
228
NULL
229
DROP TABLE job_titles;
230
CREATE TABLE t1 (a INT NOT NULL, B INT, KEY(B)) ENGINE=HEAP;
231
INSERT INTO t1 VALUES(1,1), (1,NULL);
232
SELECT * FROM t1 WHERE B is not null;
233
a	B
234
1	1
235
DROP TABLE t1;
236
CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int(10) unsigned NOT NULL) ENGINE=HEAP;
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);
238
DELETE FROM t1 WHERE date<1101106546;
239
SELECT * FROM t1;
240
pseudo	date
241
ZoomZip	1101106546
242
DROP TABLE t1;
243
create table t1(a char(2)) engine=memory;
244
insert into t1 values (NULL), (NULL);
245
delete from t1 where a is null;
246
insert into t1 values ('2'), ('3');
247
select * from t1;
248
a
249
3
250
2
251
drop table t1;
252
set storage_engine=HEAP;
253
create table t1 (v varchar(10), c char(10), t varchar(50));
254
insert into t1 values('+ ', '+ ', '+ ');
255
set @a=repeat(' ',20);
256
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
257
Warnings:
258
Note	1265	Data truncated for column 'v' at row 1
259
Note	1265	Data truncated for column 'c' at row 1
260
select concat('*',v,'*',c,'*',t,'*') from t1;
261
concat('*',v,'*',c,'*',t,'*')
262
*+ *+*+ *
263
*+         *+*+                    *
264
show create table t1;
265
Table	Create Table
266
t1	CREATE TABLE `t1` (
267
  `v` varchar(10) DEFAULT NULL,
268
  `c` char(10) DEFAULT NULL,
269
  `t` varchar(50) DEFAULT NULL
270
) ENGINE=MEMORY DEFAULT CHARSET=latin1
271
create table t2 like t1;
272
show create table t2;
273
Table	Create Table
274
t2	CREATE TABLE `t2` (
275
  `v` varchar(10) DEFAULT NULL,
276
  `c` char(10) DEFAULT NULL,
277
  `t` varchar(50) DEFAULT NULL
278
) ENGINE=MEMORY DEFAULT CHARSET=latin1
279
create table t3 select * from t1;
280
show create table t3;
281
Table	Create Table
282
t3	CREATE TABLE `t3` (
283
  `v` varchar(10) DEFAULT NULL,
284
  `c` char(10) DEFAULT NULL,
285
  `t` varchar(50) DEFAULT NULL
286
) ENGINE=MEMORY DEFAULT CHARSET=latin1
287
alter table t1 modify c varchar(10);
288
show create table t1;
289
Table	Create Table
290
t1	CREATE TABLE `t1` (
291
  `v` varchar(10) DEFAULT NULL,
292
  `c` varchar(10) DEFAULT NULL,
293
  `t` varchar(50) DEFAULT NULL
294
) ENGINE=MEMORY DEFAULT CHARSET=latin1
295
alter table t1 modify v char(10);
296
show create table t1;
297
Table	Create Table
298
t1	CREATE TABLE `t1` (
299
  `v` char(10) DEFAULT NULL,
300
  `c` varchar(10) DEFAULT NULL,
301
  `t` varchar(50) DEFAULT NULL
302
) ENGINE=MEMORY DEFAULT CHARSET=latin1
303
alter table t1 modify t varchar(10);
304
Warnings:
305
Warning	1265	Data truncated for column 't' at row 2
306
show create table t1;
307
Table	Create Table
308
t1	CREATE TABLE `t1` (
309
  `v` char(10) DEFAULT NULL,
310
  `c` varchar(10) DEFAULT NULL,
311
  `t` varchar(10) DEFAULT NULL
312
) ENGINE=MEMORY DEFAULT CHARSET=latin1
313
select concat('*',v,'*',c,'*',t,'*') from t1;
314
concat('*',v,'*',c,'*',t,'*')
315
*+*+*+ *
316
*+*+*+         *
317
drop table t1,t2,t3;
318
create table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
319
show create table t1;
320
Table	Create Table
321
t1	CREATE TABLE `t1` (
322
  `v` varchar(10) DEFAULT NULL,
323
  `c` char(10) DEFAULT NULL,
324
  `t` varchar(50) DEFAULT NULL,
325
  KEY `v` (`v`),
326
  KEY `c` (`c`),
327
  KEY `t` (`t`(10))
328
) ENGINE=MEMORY DEFAULT CHARSET=latin1
329
select count(*) from t1;
330
count(*)
331
270
332
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
333
select count(*) from t1 where v='a';
334
count(*)
335
10
336
select count(*) from t1 where c='a';
337
count(*)
338
10
339
select count(*) from t1 where t='a';
340
count(*)
341
10
342
select count(*) from t1 where v='a  ';
343
count(*)
344
10
345
select count(*) from t1 where c='a  ';
346
count(*)
347
10
348
select count(*) from t1 where t='a  ';
349
count(*)
350
10
351
select count(*) from t1 where v between 'a' and 'a ';
352
count(*)
353
10
354
select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
355
count(*)
356
10
357
select count(*) from t1 where v like 'a%';
358
count(*)
359
11
360
select count(*) from t1 where c like 'a%';
361
count(*)
362
11
363
select count(*) from t1 where t like 'a%';
364
count(*)
365
11
366
select count(*) from t1 where v like 'a %';
367
count(*)
368
9
369
explain select count(*) from t1 where v='a  ';
370
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
371
1	SIMPLE	t1	ref	v	v	13	const	10	Using where
372
explain select count(*) from t1 where c='a  ';
373
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
374
1	SIMPLE	t1	ref	c	c	11	const	10	Using where
375
explain select count(*) from t1 where t='a  ';
376
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
377
1	SIMPLE	t1	ref	t	t	13	const	10	Using where
378
explain select count(*) from t1 where v like 'a%';
379
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
380
1	SIMPLE	t1	ALL	v	NULL	NULL	NULL	271	Using where
381
explain select count(*) from t1 where v between 'a' and 'a ';
382
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
383
1	SIMPLE	t1	ref	v	v	13	const	10	Using where
384
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
385
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
386
1	SIMPLE	t1	ref	v	v	13	const	10	Using where
387
alter table t1 add unique(v);
388
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
389
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
390
qq
391
*a*a*a*
392
*a *a*a *
393
*a  *a*a  *
394
*a   *a*a   *
395
*a    *a*a    *
396
*a     *a*a     *
397
*a      *a*a      *
398
*a       *a*a       *
399
*a        *a*a        *
400
*a         *a*a         *
401
explain select * from t1 where v='a';
402
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
403
1	SIMPLE	t1	ref	v	v	13	const	10	Using where
404
select v,count(*) from t1 group by v limit 10;
405
v	count(*)
406
a	1
407
a	10
408
b	10
409
c	10
410
d	10
411
e	10
412
f	10
413
g	10
414
h	10
415
i	10
416
select v,count(t) from t1 group by v limit 10;
417
v	count(t)
418
a	1
419
a	10
420
b	10
421
c	10
422
d	10
423
e	10
424
f	10
425
g	10
426
h	10
427
i	10
428
select v,count(c) from t1 group by v limit 10;
429
v	count(c)
430
a	1
431
a	10
432
b	10
433
c	10
434
d	10
435
e	10
436
f	10
437
g	10
438
h	10
439
i	10
440
select sql_big_result trim(v),count(t) from t1 group by v limit 10;
441
trim(v)	count(t)
442
a	1
443
a	10
444
b	10
445
c	10
446
d	10
447
e	10
448
f	10
449
g	10
450
h	10
451
i	10
452
select sql_big_result trim(v),count(c) from t1 group by v limit 10;
453
trim(v)	count(c)
454
a	1
455
a	10
456
b	10
457
c	10
458
d	10
459
e	10
460
f	10
461
g	10
462
h	10
463
i	10
464
select c,count(*) from t1 group by c limit 10;
465
c	count(*)
466
a	1
467
a	10
468
b	10
469
c	10
470
d	10
471
e	10
472
f	10
473
g	10
474
h	10
475
i	10
476
select c,count(t) from t1 group by c limit 10;
477
c	count(t)
478
a	1
479
a	10
480
b	10
481
c	10
482
d	10
483
e	10
484
f	10
485
g	10
486
h	10
487
i	10
488
select sql_big_result c,count(t) from t1 group by c limit 10;
489
c	count(t)
490
a	1
491
a	10
492
b	10
493
c	10
494
d	10
495
e	10
496
f	10
497
g	10
498
h	10
499
i	10
500
select t,count(*) from t1 group by t limit 10;
501
t	count(*)
502
a	1
503
a	10
504
b	10
505
c	10
506
d	10
507
e	10
508
f	10
509
g	10
510
h	10
511
i	10
512
select t,count(t) from t1 group by t limit 10;
513
t	count(t)
514
a	1
515
a	10
516
b	10
517
c	10
518
d	10
519
e	10
520
f	10
521
g	10
522
h	10
523
i	10
524
select sql_big_result trim(t),count(t) from t1 group by t limit 10;
525
trim(t)	count(t)
526
a	1
527
a	10
528
b	10
529
c	10
530
d	10
531
e	10
532
f	10
533
g	10
534
h	10
535
i	10
536
drop table t1;
537
create table t1 (a char(10), unique (a));
538
insert into t1 values ('a');
539
insert into t1 values ('a ');
540
ERROR 23000: Duplicate entry 'a' for key 'a'
541
alter table t1 modify a varchar(10);
542
insert into t1 values ('a '),('a  '),('a   '),('a         ');
543
ERROR 23000: Duplicate entry 'a ' for key 'a'
544
insert into t1 values ('a     ');
545
ERROR 23000: Duplicate entry 'a     ' for key 'a'
546
insert into t1 values ('a          ');
547
ERROR 23000: Duplicate entry 'a         ' for key 'a'
548
insert into t1 values ('a ');
549
ERROR 23000: Duplicate entry 'a ' for key 'a'
550
update t1 set a='a      ' where a like 'a ';
551
update t1 set a='a  ' where a like 'a      ';
552
drop table t1;
553
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)));
554
show create table t1;
555
Table	Create Table
556
t1	CREATE TABLE `t1` (
557
  `v` varchar(10) DEFAULT NULL,
558
  `c` char(10) DEFAULT NULL,
559
  `t` varchar(50) DEFAULT NULL,
560
  KEY `v` (`v`) USING BTREE,
561
  KEY `c` (`c`) USING BTREE,
562
  KEY `t` (`t`(10)) USING BTREE
563
) ENGINE=MEMORY DEFAULT CHARSET=latin1
564
select count(*) from t1;
565
count(*)
566
270
567
insert into t1 values(concat('a',char(1)),concat('a',char(1)),concat('a',char(1)));
568
select count(*) from t1 where v='a';
569
count(*)
570
10
571
select count(*) from t1 where c='a';
572
count(*)
573
10
574
select count(*) from t1 where t='a';
575
count(*)
576
10
577
select count(*) from t1 where v='a  ';
578
count(*)
579
10
580
select count(*) from t1 where c='a  ';
581
count(*)
582
10
583
select count(*) from t1 where t='a  ';
584
count(*)
585
10
586
select count(*) from t1 where v between 'a' and 'a ';
587
count(*)
588
10
589
select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
590
count(*)
591
10
592
explain select count(*) from t1 where v='a  ';
593
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
594
1	SIMPLE	t1	ref	v	v	13	const	#	Using where
595
explain select count(*) from t1 where c='a  ';
596
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
597
1	SIMPLE	t1	ref	c	c	11	const	#	Using where
598
explain select count(*) from t1 where t='a  ';
599
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
600
1	SIMPLE	t1	ref	t	t	13	const	#	Using where
601
explain select count(*) from t1 where v like 'a%';
602
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
603
1	SIMPLE	t1	range	v	v	13	NULL	#	Using where
604
explain select count(*) from t1 where v between 'a' and 'a ';
605
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
606
1	SIMPLE	t1	ref	v	v	13	const	#	Using where
607
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a  ' and 'b\n';
608
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
609
1	SIMPLE	t1	ref	v	v	13	const	#	Using where
610
alter table t1 add unique(v);
611
ERROR 23000: Duplicate entry '{ ' for key 'v_2'
612
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
613
qq
614
*a*a*a*
615
*a *a*a *
616
*a  *a*a  *
617
*a   *a*a   *
618
*a    *a*a    *
619
*a     *a*a     *
620
*a      *a*a      *
621
*a       *a*a       *
622
*a        *a*a        *
623
*a         *a*a         *
624
explain select * from t1 where v='a';
625
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
626
1	SIMPLE	t1	ref	v	v	13	const	#	Using where
627
drop table t1;
628
create table t1 (a char(10), unique using btree (a)) engine=heap;
629
insert into t1 values ('a');
630
insert into t1 values ('a ');
631
ERROR 23000: Duplicate entry 'a' for key 'a'
632
alter table t1 modify a varchar(10);
633
insert into t1 values ('a '),('a  '),('a   '),('a         ');
634
ERROR 23000: Duplicate entry 'a ' for key 'a'
635
insert into t1 values ('a     ');
636
ERROR 23000: Duplicate entry 'a     ' for key 'a'
637
insert into t1 values ('a          ');
638
ERROR 23000: Duplicate entry 'a         ' for key 'a'
639
insert into t1 values ('a ');
640
ERROR 23000: Duplicate entry 'a ' for key 'a'
641
update t1 set a='a      ' where a like 'a ';
642
update t1 set a='a  ' where a like 'a      ';
643
drop table t1;
644
create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
645
show create table t1;
646
Table	Create Table
647
t1	CREATE TABLE `t1` (
648
  `v` varchar(10) DEFAULT NULL,
649
  `c` char(10) DEFAULT NULL,
650
  `t` varchar(50) DEFAULT NULL,
651
  KEY `v` (`v`(5)),
652
  KEY `c` (`c`(5)),
653
  KEY `t` (`t`(5))
654
) ENGINE=MEMORY DEFAULT CHARSET=latin1
655
drop table t1;
656
create table t1 (v varchar(65530), key(v(10)));
657
show create table t1;
658
Table	Create Table
659
t1	CREATE TABLE `t1` (
660
  `v` varchar(65530) DEFAULT NULL,
661
  KEY `v` (`v`(10))
662
) ENGINE=MEMORY DEFAULT CHARSET=latin1
663
insert into t1 values(repeat('a',65530));
664
select length(v) from t1 where v=repeat('a',65530);
665
length(v)
666
65530
667
drop table t1;
668
set storage_engine=MyISAM;
669
create table t1 (a bigint unsigned auto_increment primary key, b int,
670
key (b, a)) engine=heap;
671
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
672
select * from t1;
673
a	b
674
1	1
675
2	1
676
3	1
677
4	1
678
5	1
679
6	1
680
7	1
681
8	1
682
drop table t1;
683
create table t1 (a int not null, b int not null auto_increment,
684
primary key(a, b), key(b)) engine=heap;
685
insert t1 (a) values (1),(1),(1),(1),(1),(1),(1),(1);
686
select * from t1;
687
a	b
688
1	1
689
1	2
690
1	3
691
1	4
692
1	5
693
1	6
694
1	7
695
1	8
696
drop table t1;
697
create table t1 (a int not null, b int not null auto_increment,
698
primary key(a, b)) engine=heap;
699
ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key
700
create table t1 (c char(255), primary key(c(90)));
701
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
702
insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
703
ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 'PRIMARY'
704
drop table t1;
705
CREATE TABLE t1 (a int, key(a)) engine=heap;
706
insert into t1 values (0);
707
delete from t1;
708
select * from t1;
709
a
710
insert into t1 values (0), (1);
711
select * from t1 where a = 0;
712
a
713
0
714
drop table t1;
715
create table t1 (c char(10)) engine=memory;
716
create table t2 (c varchar(10)) engine=memory;
717
show table status like 't_';
718
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
719
t1	MEMORY	10	Fixed	0	11	0	#	0	0	NULL	NULL	NULL	NULL	latin1_swedish_ci	NULL		
720
t2	MEMORY	10	Fixed	0	12	0	#	0	0	NULL	NULL	NULL	NULL	latin1_swedish_ci	NULL		
721
drop table t1, t2;
722
CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),
723
KEY(a), KEY(b), KEY(c)) ENGINE=MEMORY;
724
INSERT INTO t1 VALUES('a','aa',REPEAT('a', 256)),('a','aa',REPEAT('a',256));
725
SELECT COUNT(*) FROM t1 WHERE a='a';
726
COUNT(*)
727
2
728
SELECT COUNT(*) FROM t1 WHERE b='aa';
729
COUNT(*)
730
2
731
SELECT COUNT(*) FROM t1 WHERE c=REPEAT('a',256);
732
COUNT(*)
733
2
734
DROP TABLE t1;
735
CREATE TABLE t1(c1 VARCHAR(100), c2 INT) ENGINE=MEMORY;
736
INSERT INTO t1 VALUES('', 0);
737
ALTER TABLE t1 MODIFY c1 VARCHAR(101);
738
SELECT c2 FROM t1;
739
c2
740
0
741
DROP TABLE t1;