1
create table t1(a int not null, b int, c char(10) not null, d varchar(20)) engine = innodb;
2
insert into t1 values (5,5,'oo','oo'),(4,4,'tr','tr'),(3,4,'ad','ad'),(2,3,'ak','ak');
4
alter table t1 add index b (b), add index b (b);
5
ERROR 42000: Duplicate key name 'b'
6
alter table t1 add index (b,b);
7
ERROR 42S21: Duplicate column name 'b'
8
alter table t1 add index d2 (d);
11
t1 CREATE TABLE `t1` (
13
`b` int(11) DEFAULT NULL,
14
`c` char(10) NOT NULL,
15
`d` varchar(20) DEFAULT NULL,
17
) ENGINE=InnoDB DEFAULT CHARSET=latin1
18
explain select * from t1 force index(d2) order by d;
19
id select_type table type possible_keys key key_len ref rows Extra
20
1 SIMPLE t1 index NULL d2 23 NULL 4
21
select * from t1 force index (d2) order by d;
27
alter table t1 add unique index (b);
28
ERROR 23000: Duplicate entry '4' for key 'b'
31
t1 CREATE TABLE `t1` (
33
`b` int(11) DEFAULT NULL,
34
`c` char(10) NOT NULL,
35
`d` varchar(20) DEFAULT NULL,
37
) ENGINE=InnoDB DEFAULT CHARSET=latin1
38
alter table t1 add index (b);
41
t1 CREATE TABLE `t1` (
43
`b` int(11) DEFAULT NULL,
44
`c` char(10) NOT NULL,
45
`d` varchar(20) DEFAULT NULL,
48
) ENGINE=InnoDB DEFAULT CHARSET=latin1
49
CREATE TABLE `t1#1`(a INT PRIMARY KEY) ENGINE=InnoDB;
50
alter table t1 add unique index (c), add index (d);
51
ERROR HY000: Table 'test.t1#1' already exists
52
rename table `t1#1` to `t1#2`;
53
alter table t1 add unique index (c), add index (d);
54
ERROR HY000: Table 'test.t1#2' already exists
56
alter table t1 add unique index (c), add index (d);
59
t1 CREATE TABLE `t1` (
61
`b` int(11) DEFAULT NULL,
62
`c` char(10) NOT NULL,
63
`d` varchar(20) DEFAULT NULL,
68
) ENGINE=InnoDB DEFAULT CHARSET=latin1
69
explain select * from t1 force index(c) order by c;
70
id select_type table type possible_keys key key_len ref rows Extra
71
1 SIMPLE t1 index NULL c 10 NULL 4
73
ERROR 42000: This table type requires a primary key
74
alter table t1 add primary key (a), drop index c;
77
t1 CREATE TABLE `t1` (
79
`b` int(11) DEFAULT NULL,
80
`c` char(10) NOT NULL,
81
`d` varchar(20) DEFAULT NULL,
86
) ENGINE=InnoDB DEFAULT CHARSET=latin1
87
alter table t1 add primary key (c);
88
ERROR 42000: Multiple primary key defined
89
alter table t1 drop primary key, add primary key (b);
90
ERROR 23000: Duplicate entry '4' for key 'PRIMARY'
91
create unique index c on t1 (c);
94
t1 CREATE TABLE `t1` (
96
`b` int(11) DEFAULT NULL,
97
`c` char(10) NOT NULL,
98
`d` varchar(20) DEFAULT NULL,
100
UNIQUE KEY `c` (`c`),
104
) ENGINE=InnoDB DEFAULT CHARSET=latin1
105
explain select * from t1 force index(c) order by c;
106
id select_type table type possible_keys key key_len ref rows Extra
107
1 SIMPLE t1 index NULL c 10 NULL 4
108
select * from t1 force index(c) order by c;
114
alter table t1 drop index b, add index (b);
115
show create table t1;
117
t1 CREATE TABLE `t1` (
118
`a` int(11) NOT NULL,
119
`b` int(11) DEFAULT NULL,
120
`c` char(10) NOT NULL,
121
`d` varchar(20) DEFAULT NULL,
123
UNIQUE KEY `c` (`c`),
127
) ENGINE=InnoDB DEFAULT CHARSET=latin1
128
insert into t1 values(6,1,'ggg','ggg');
136
select * from t1 force index(b) order by b;
143
select * from t1 force index(c) order by c;
150
select * from t1 force index(d) order by d;
157
explain select * from t1 force index(b) order by b;
158
id select_type table type possible_keys key key_len ref rows Extra
159
1 SIMPLE t1 index NULL b 5 NULL 5
160
explain select * from t1 force index(c) order by c;
161
id select_type table type possible_keys key key_len ref rows Extra
162
1 SIMPLE t1 index NULL c 10 NULL 5
163
explain select * from t1 force index(d) order by d;
164
id select_type table type possible_keys key key_len ref rows Extra
165
1 SIMPLE t1 index NULL d 23 NULL 5
166
show create table t1;
168
t1 CREATE TABLE `t1` (
169
`a` int(11) NOT NULL,
170
`b` int(11) DEFAULT NULL,
171
`c` char(10) NOT NULL,
172
`d` varchar(20) DEFAULT NULL,
174
UNIQUE KEY `c` (`c`),
178
) ENGINE=InnoDB DEFAULT CHARSET=latin1
180
create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb;
181
insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ad','ad'),(4,4,'afe','afe');
183
alter table t1 add index (c(2));
184
show create table t1;
186
t1 CREATE TABLE `t1` (
187
`a` int(11) NOT NULL,
188
`b` int(11) DEFAULT NULL,
189
`c` char(10) DEFAULT NULL,
190
`d` varchar(20) DEFAULT NULL,
193
) ENGINE=InnoDB DEFAULT CHARSET=latin1
194
alter table t1 add unique index (d(10));
195
show create table t1;
197
t1 CREATE TABLE `t1` (
198
`a` int(11) NOT NULL,
199
`b` int(11) DEFAULT NULL,
200
`c` char(10) DEFAULT NULL,
201
`d` varchar(20) DEFAULT NULL,
203
UNIQUE KEY `d` (`d`(10)),
205
) ENGINE=InnoDB DEFAULT CHARSET=latin1
206
insert into t1 values(5,1,'ggg','ggg');
214
select * from t1 force index(c) order by c;
221
select * from t1 force index(d) order by d;
228
explain select * from t1 order by b;
229
id select_type table type possible_keys key key_len ref rows Extra
230
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
231
explain select * from t1 force index(c) order by c;
232
id select_type table type possible_keys key key_len ref rows Extra
233
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
234
explain select * from t1 force index(d) order by d;
235
id select_type table type possible_keys key key_len ref rows Extra
236
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
237
show create table t1;
239
t1 CREATE TABLE `t1` (
240
`a` int(11) NOT NULL,
241
`b` int(11) DEFAULT NULL,
242
`c` char(10) DEFAULT NULL,
243
`d` varchar(20) DEFAULT NULL,
245
UNIQUE KEY `d` (`d`(10)),
247
) ENGINE=InnoDB DEFAULT CHARSET=latin1
248
alter table t1 drop index d;
249
insert into t1 values(8,9,'fff','fff');
258
select * from t1 force index(c) order by c;
266
explain select * from t1 order by b;
267
id select_type table type possible_keys key key_len ref rows Extra
268
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
269
explain select * from t1 force index(c) order by c;
270
id select_type table type possible_keys key key_len ref rows Extra
271
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
272
explain select * from t1 order by d;
273
id select_type table type possible_keys key key_len ref rows Extra
274
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
275
show create table t1;
277
t1 CREATE TABLE `t1` (
278
`a` int(11) NOT NULL,
279
`b` int(11) DEFAULT NULL,
280
`c` char(10) DEFAULT NULL,
281
`d` varchar(20) DEFAULT NULL,
284
) ENGINE=InnoDB DEFAULT CHARSET=latin1
286
create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb;
287
insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe');
289
alter table t1 add unique index (b,c);
290
insert into t1 values(8,9,'fff','fff');
298
select * from t1 force index(b) order by b;
305
explain select * from t1 force index(b) order by b;
306
id select_type table type possible_keys key key_len ref rows Extra
307
1 SIMPLE t1 index NULL b 16 NULL 5
308
show create table t1;
310
t1 CREATE TABLE `t1` (
311
`a` int(11) NOT NULL,
312
`b` int(11) DEFAULT NULL,
313
`c` char(10) DEFAULT NULL,
314
`d` varchar(20) DEFAULT NULL,
316
UNIQUE KEY `b` (`b`,`c`)
317
) ENGINE=InnoDB DEFAULT CHARSET=latin1
318
alter table t1 add index (b,c);
319
insert into t1 values(11,11,'kkk','kkk');
328
select * from t1 force index(b) order by b;
336
explain select * from t1 force index(b) order by b;
337
id select_type table type possible_keys key key_len ref rows Extra
338
1 SIMPLE t1 index NULL b 16 NULL 6
339
show create table t1;
341
t1 CREATE TABLE `t1` (
342
`a` int(11) NOT NULL,
343
`b` int(11) DEFAULT NULL,
344
`c` char(10) DEFAULT NULL,
345
`d` varchar(20) DEFAULT NULL,
347
UNIQUE KEY `b` (`b`,`c`),
349
) ENGINE=InnoDB DEFAULT CHARSET=latin1
350
alter table t1 add unique index (c,d);
351
insert into t1 values(13,13,'yyy','aaa');
361
select * from t1 force index(b) order by b;
370
select * from t1 force index(c) order by c;
379
explain select * from t1 force index(b) order by b;
380
id select_type table type possible_keys key key_len ref rows Extra
381
1 SIMPLE t1 index NULL b 16 NULL 7
382
explain select * from t1 force index(c) order by c;
383
id select_type table type possible_keys key key_len ref rows Extra
384
1 SIMPLE t1 index NULL c 34 NULL 7
385
show create table t1;
387
t1 CREATE TABLE `t1` (
388
`a` int(11) NOT NULL,
389
`b` int(11) DEFAULT NULL,
390
`c` char(10) DEFAULT NULL,
391
`d` varchar(20) DEFAULT NULL,
393
UNIQUE KEY `b` (`b`,`c`),
394
UNIQUE KEY `c` (`c`,`d`),
396
) ENGINE=InnoDB DEFAULT CHARSET=latin1
398
create table t1(a int not null, b int not null, c int, primary key (a), key (b)) engine = innodb;
399
create table t3(a int not null, c int not null, d int, primary key (a), key (c)) engine = innodb;
400
create table t4(a int not null, d int not null, e int, primary key (a), key (d)) engine = innodb;
401
create table t2(a int not null, b int not null, c int not null, d int not null, e int,
402
foreign key (b) references t1(b) on delete cascade,
403
foreign key (c) references t3(c), foreign key (d) references t4(d))
405
alter table t1 drop index b;
406
ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint
407
alter table t3 drop index c;
408
ERROR HY000: Cannot drop index 'c': needed in a foreign key constraint
409
alter table t4 drop index d;
410
ERROR HY000: Cannot drop index 'd': needed in a foreign key constraint
411
alter table t2 drop index b;
412
ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint
413
alter table t2 drop index b, drop index c, drop index d;
414
ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint
415
create unique index dc on t2 (d,c);
416
create index dc on t1 (b,c);
417
alter table t2 add primary key (a);
418
insert into t1 values (1,1,1);
419
insert into t3 values (1,1,1);
420
insert into t4 values (1,1,1);
421
insert into t2 values (1,1,1,1,1);
423
alter table t4 add constraint dc foreign key (a) references t1(a);
424
show create table t4;
426
t4 CREATE TABLE `t4` (
427
`a` int(11) NOT NULL,
428
`d` int(11) NOT NULL,
429
`e` int(11) DEFAULT NULL,
432
CONSTRAINT `dc` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)
433
) ENGINE=InnoDB DEFAULT CHARSET=latin1
434
alter table t3 add constraint dc foreign key (a) references t1(a);
435
ERROR HY000: Can't create table '#sql-temporary' (errno: 121)
436
show create table t3;
438
t3 CREATE TABLE `t3` (
439
`a` int(11) NOT NULL,
440
`c` int(11) NOT NULL,
441
`d` int(11) DEFAULT NULL,
444
) ENGINE=InnoDB DEFAULT CHARSET=latin1
445
alter table t2 drop index b, add index (b);
446
show create table t2;
448
t2 CREATE TABLE `t2` (
449
`a` int(11) NOT NULL,
450
`b` int(11) NOT NULL,
451
`c` int(11) NOT NULL,
452
`d` int(11) NOT NULL,
453
`e` int(11) DEFAULT NULL,
455
UNIQUE KEY `dc` (`d`,`c`),
458
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`b`) ON DELETE CASCADE,
459
CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`c`) REFERENCES `t3` (`c`),
460
CONSTRAINT `t2_ibfk_3` FOREIGN KEY (`d`) REFERENCES `t4` (`d`)
461
) ENGINE=InnoDB DEFAULT CHARSET=latin1
463
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t4`, CONSTRAINT `dc` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
465
ERROR 42000: Can't DROP 'dc'; check that column/key exists
466
alter table t3 drop foreign key dc;
467
ERROR HY000: Error on rename of './test/t3' to '#sql2-temporary' (errno: 152)
468
alter table t4 drop foreign key dc;
475
drop table t2,t4,t3,t1;
476
create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb default charset=utf8;
477
insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe');
479
alter table t1 add unique index (b);
480
ERROR 23000: Duplicate entry '2' for key 'b'
481
insert into t1 values(8,9,'fff','fff');
489
show create table t1;
491
t1 CREATE TABLE `t1` (
492
`a` int(11) NOT NULL,
493
`b` int(11) DEFAULT NULL,
494
`c` char(10) DEFAULT NULL,
495
`d` varchar(20) DEFAULT NULL,
497
) ENGINE=InnoDB DEFAULT CHARSET=utf8
498
alter table t1 add index (b);
499
insert into t1 values(10,10,'kkk','iii');
508
select * from t1 force index(b) order by b;
516
explain select * from t1 force index(b) order by b;
517
id select_type table type possible_keys key key_len ref rows Extra
518
1 SIMPLE t1 index NULL b 5 NULL 6
519
show create table t1;
521
t1 CREATE TABLE `t1` (
522
`a` int(11) NOT NULL,
523
`b` int(11) DEFAULT NULL,
524
`c` char(10) DEFAULT NULL,
525
`d` varchar(20) DEFAULT NULL,
528
) ENGINE=InnoDB DEFAULT CHARSET=utf8
529
alter table t1 add unique index (c), add index (d);
530
insert into t1 values(11,11,'aaa','mmm');
540
select * from t1 force index(b) order by b;
549
select * from t1 force index(c) order by c;
558
select * from t1 force index(d) order by d;
567
explain select * from t1 force index(b) order by b;
568
id select_type table type possible_keys key key_len ref rows Extra
569
1 SIMPLE t1 index NULL b 5 NULL 7
570
explain select * from t1 force index(c) order by c;
571
id select_type table type possible_keys key key_len ref rows Extra
572
1 SIMPLE t1 index NULL c 31 NULL 7
573
explain select * from t1 force index(d) order by d;
574
id select_type table type possible_keys key key_len ref rows Extra
575
1 SIMPLE t1 index NULL d 63 NULL 7
576
show create table t1;
578
t1 CREATE TABLE `t1` (
579
`a` int(11) NOT NULL,
580
`b` int(11) DEFAULT NULL,
581
`c` char(10) DEFAULT NULL,
582
`d` varchar(20) DEFAULT NULL,
584
UNIQUE KEY `c` (`c`),
587
) ENGINE=InnoDB DEFAULT CHARSET=utf8
589
Table Op Msg_type Msg_text
590
test.t1 check status OK
592
create table t1(a int not null, b int) engine = innodb;
593
insert into t1 values (1,1),(1,1),(1,1),(1,1);
594
alter table t1 add unique index (a);
595
ERROR 23000: Duplicate entry '1' for key 'a'
596
alter table t1 add unique index (b);
597
ERROR 23000: Duplicate entry '1' for key 'b'
598
alter table t1 add unique index (a), add unique index(b);
599
ERROR 23000: Duplicate entry '1' for key 'a'
600
show create table t1;
602
t1 CREATE TABLE `t1` (
603
`a` int(11) NOT NULL,
604
`b` int(11) DEFAULT NULL
605
) ENGINE=InnoDB DEFAULT CHARSET=latin1
607
create table t1(a int not null, c int not null,b int, primary key(a), unique key(c), key(b)) engine = innodb;
608
alter table t1 drop index c, drop index b;
609
show create table t1;
611
t1 CREATE TABLE `t1` (
612
`a` int(11) NOT NULL,
613
`c` int(11) NOT NULL,
614
`b` int(11) DEFAULT NULL,
616
) ENGINE=InnoDB DEFAULT CHARSET=latin1
618
create table t1(a int not null, b int, primary key(a)) engine = innodb;
619
alter table t1 add index (b);
620
show create table t1;
622
t1 CREATE TABLE `t1` (
623
`a` int(11) NOT NULL,
624
`b` int(11) DEFAULT NULL,
627
) ENGINE=InnoDB DEFAULT CHARSET=latin1
629
create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb;
630
insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,3,'ac','ac'),(4,4,'afe','afe'),(5,4,'affe','affe');
631
alter table t1 add unique index (b), add unique index (c), add unique index (d);
632
ERROR 23000: Duplicate entry '4' for key 'b'
633
alter table t1 add unique index (c), add unique index (b), add index (d);
634
ERROR 23000: Duplicate entry 'ac' for key 'c'
635
show create table t1;
637
t1 CREATE TABLE `t1` (
638
`a` int(11) NOT NULL,
639
`b` int(11) DEFAULT NULL,
640
`c` char(10) DEFAULT NULL,
641
`d` varchar(20) DEFAULT NULL,
643
) ENGINE=InnoDB DEFAULT CHARSET=latin1
645
create table t1(a int not null, b int not null, c int, primary key (a), key(c)) engine=innodb;
646
insert into t1 values (5,1,5),(4,2,4),(3,3,3),(2,4,2),(1,5,1);
647
alter table t1 add unique index (b);
648
insert into t1 values (10,20,20),(11,19,19),(12,18,18),(13,17,17);
649
show create table t1;
651
t1 CREATE TABLE `t1` (
652
`a` int(11) NOT NULL,
653
`b` int(11) NOT NULL,
654
`c` int(11) DEFAULT NULL,
656
UNIQUE KEY `b` (`b`),
658
) ENGINE=InnoDB DEFAULT CHARSET=latin1
660
Table Op Msg_type Msg_text
661
test.t1 check status OK
662
explain select * from t1 force index(c) order by c;
663
id select_type table type possible_keys key key_len ref rows Extra
664
1 SIMPLE t1 index NULL c 5 NULL 9
665
explain select * from t1 order by a;
666
id select_type table type possible_keys key key_len ref rows Extra
667
1 SIMPLE t1 index NULL PRIMARY 4 NULL 9
668
explain select * from t1 force index(b) order by b;
669
id select_type table type possible_keys key key_len ref rows Extra
670
1 SIMPLE t1 index NULL b 4 NULL 9
671
select * from t1 order by a;
682
select * from t1 force index(b) order by b;
693
select * from t1 force index(c) order by c;
705
create table t1(a int not null, b int not null) engine=innodb;
706
insert into t1 values (1,1);
707
alter table t1 add primary key(b);
708
insert into t1 values (2,2);
709
show create table t1;
711
t1 CREATE TABLE `t1` (
712
`a` int(11) NOT NULL,
713
`b` int(11) NOT NULL,
715
) ENGINE=InnoDB DEFAULT CHARSET=latin1
717
Table Op Msg_type Msg_text
718
test.t1 check status OK
723
explain select * from t1;
724
id select_type table type possible_keys key key_len ref rows Extra
725
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
726
explain select * from t1 order by a;
727
id select_type table type possible_keys key key_len ref rows Extra
728
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using filesort
729
explain select * from t1 order by b;
730
id select_type table type possible_keys key key_len ref rows Extra
731
1 SIMPLE t1 index NULL PRIMARY 4 NULL 2
736
create table t1(a int not null) engine=innodb;
737
insert into t1 values (1);
738
alter table t1 add primary key(a);
739
insert into t1 values (2);
740
show create table t1;
742
t1 CREATE TABLE `t1` (
743
`a` int(11) NOT NULL,
745
) ENGINE=InnoDB DEFAULT CHARSET=latin1
747
Table Op Msg_type Msg_text
748
test.t1 check status OK
754
explain select * from t1;
755
id select_type table type possible_keys key key_len ref rows Extra
756
1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
757
explain select * from t1 order by a;
758
id select_type table type possible_keys key key_len ref rows Extra
759
1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
761
create table t2(d varchar(17) primary key) engine=innodb default charset=utf8;
762
create table t3(a int primary key) engine=innodb;
763
insert into t3 values(22),(44),(33),(55),(66);
764
insert into t2 values ('jejdkrun87'),('adfd72nh9k'),
765
('adfdpplkeock'),('adfdijnmnb78k'),('adfdijn0loKNHJik');
766
create table t1(a int, b blob, c text, d text not null)
767
engine=innodb default charset = utf8;
768
insert into t1 values (null,null,null,'null');
770
select a,left(repeat(d,100*a),65535),repeat(d,20*a),d from t2,t3;
772
select count(*) from t1 where a=44;
776
length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1;
777
a length(b) b=left(repeat(d,100*a),65535) length(c) c=repeat(d,20*a) d
778
NULL NULL NULL NULL NULL null
779
22 22000 1 4400 1 adfd72nh9k
780
22 35200 1 7040 1 adfdijn0loKNHJik
781
22 28600 1 5720 1 adfdijnmnb78k
782
22 26400 1 5280 1 adfdpplkeock
783
22 22000 1 4400 1 jejdkrun87
784
33 33000 1 6600 1 adfd72nh9k
785
33 52800 1 10560 1 adfdijn0loKNHJik
786
33 42900 1 8580 1 adfdijnmnb78k
787
33 39600 1 7920 1 adfdpplkeock
788
33 33000 1 6600 1 jejdkrun87
789
44 44000 1 8800 1 adfd72nh9k
790
44 65535 1 14080 1 adfdijn0loKNHJik
791
44 57200 1 11440 1 adfdijnmnb78k
792
44 52800 1 10560 1 adfdpplkeock
793
44 44000 1 8800 1 jejdkrun87
794
55 55000 1 11000 1 adfd72nh9k
795
55 65535 1 17600 1 adfdijn0loKNHJik
796
55 65535 1 14300 1 adfdijnmnb78k
797
55 65535 1 13200 1 adfdpplkeock
798
55 55000 1 11000 1 jejdkrun87
799
66 65535 1 13200 1 adfd72nh9k
800
66 65535 1 21120 1 adfdijn0loKNHJik
801
66 65535 1 17160 1 adfdijnmnb78k
802
66 65535 1 15840 1 adfdpplkeock
803
66 65535 1 13200 1 jejdkrun87
804
alter table t1 add primary key (a), add key (b(20));
805
ERROR 42000: All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead
806
delete from t1 where d='null';
807
alter table t1 add primary key (a), add key (b(20));
808
ERROR 23000: Duplicate entry '22' for key 'PRIMARY'
809
delete from t1 where a%2;
811
Table Op Msg_type Msg_text
812
test.t1 check status OK
813
alter table t1 add primary key (a,b(255),c(255)), add key (b(767));
814
select count(*) from t1 where a=44;
818
length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1;
819
a length(b) b=left(repeat(d,100*a),65535) length(c) c=repeat(d,20*a) d
820
22 22000 1 4400 1 adfd72nh9k
821
22 35200 1 7040 1 adfdijn0loKNHJik
822
22 28600 1 5720 1 adfdijnmnb78k
823
22 26400 1 5280 1 adfdpplkeock
824
22 22000 1 4400 1 jejdkrun87
825
44 44000 1 8800 1 adfd72nh9k
826
44 65535 1 14080 1 adfdijn0loKNHJik
827
44 57200 1 11440 1 adfdijnmnb78k
828
44 52800 1 10560 1 adfdpplkeock
829
44 44000 1 8800 1 jejdkrun87
830
66 65535 1 13200 1 adfd72nh9k
831
66 65535 1 21120 1 adfdijn0loKNHJik
832
66 65535 1 17160 1 adfdijnmnb78k
833
66 65535 1 15840 1 adfdpplkeock
834
66 65535 1 13200 1 jejdkrun87
835
show create table t1;
837
t1 CREATE TABLE `t1` (
838
`a` int(11) NOT NULL DEFAULT '0',
842
PRIMARY KEY (`a`,`b`(255),`c`(255)),
844
) ENGINE=InnoDB DEFAULT CHARSET=utf8
846
Table Op Msg_type Msg_text
847
test.t1 check status OK
848
explain select * from t1 where b like 'adfd%';
849
id select_type table type possible_keys key key_len ref rows Extra
850
1 SIMPLE t1 range b b 769 NULL 11 Using where
851
create table t2(a int, b varchar(255), primary key(a,b)) engine=innodb;
852
insert into t2 select a,left(b,255) from t1;
854
rename table t2 to t1;
856
select a from t1 limit 1 for update;
859
create index t1ba on t1 (b,a);
860
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
863
select a from t1 limit 1 lock in share mode;
866
create index t1ba on t1 (b,a);
867
drop index t1ba on t1;
868
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
870
explain select a from t1 order by b;
871
id select_type table type possible_keys key key_len ref rows Extra
872
1 SIMPLE t1 index NULL t1ba 261 NULL 15 Using index
873
select a,sleep(2+a/100) from t1 order by b limit 3;
877
drop index t1ba on t1;
882
explain select a from t1 order by b;
883
id select_type table type possible_keys key key_len ref rows Extra
884
1 SIMPLE t1 index NULL PRIMARY 261 NULL 15 Using index; Using filesort
885
select a from t1 order by b limit 3;
892
create table t1(a blob,b blob,c blob,d blob,e blob,f blob,g blob,h blob,
893
i blob,j blob,k blob,l blob,m blob,n blob,o blob,p blob,
894
q blob,r blob,s blob,t blob,u blob)
896
create index t1a on t1 (a(1));
897
create index t1b on t1 (b(1));
898
create index t1c on t1 (c(1));
899
create index t1d on t1 (d(1));
900
create index t1e on t1 (e(1));
901
create index t1f on t1 (f(1));
902
create index t1g on t1 (g(1));
903
create index t1h on t1 (h(1));
904
create index t1i on t1 (i(1));
905
create index t1j on t1 (j(1));
906
create index t1k on t1 (k(1));
907
create index t1l on t1 (l(1));
908
create index t1m on t1 (m(1));
909
create index t1n on t1 (n(1));
910
create index t1o on t1 (o(1));
911
create index t1p on t1 (p(1));
912
create index t1q on t1 (q(1));
913
create index t1r on t1 (r(1));
914
create index t1s on t1 (s(1));
915
create index t1t on t1 (t(1));
916
create index t1u on t1 (u(1));
917
ERROR HY000: Too big row
918
create index t1ut on t1 (u(1), t(1));
919
ERROR HY000: Too big row
920
create index t1st on t1 (s(1), t(1));
921
show create table t1;
923
t1 CREATE TABLE `t1` (
965
KEY `t1st` (`s`(1),`t`(1))
966
) ENGINE=InnoDB DEFAULT CHARSET=latin1