398
395
CREATE TABLE t1 (a int not null, b int not null,c int not null,
399
396
key(a),primary key(a,b), unique(c),key(a),unique(b));
400
397
show index from t1;
401
Table Unique Key_name Seq_in_index Column_name
398
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
399
t1 0 PRIMARY 1 a A # NULL NULL BTREE
400
t1 0 PRIMARY 2 b A # NULL NULL BTREE
401
t1 0 c 1 c A # NULL NULL BTREE
402
t1 0 b 1 b A # NULL NULL BTREE
403
t1 1 a 1 a A # NULL NULL BTREE
404
t1 1 a_2 1 a A # NULL NULL BTREE
409
406
create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
410
407
alter table t1 engine=innodb;
1132
1128
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
1133
1129
insert t2 select * from t1;
1134
1130
insert t3 select * from t1;
1131
checksum table t1, t2, t3, t4;
1138
Error 1146 Table 'test.t4' doesn't exist
1139
checksum table t1, t2, t3, t4;
1146
Error 1146 Table 'test.t4' doesn't exist
1147
checksum table t1, t2, t3, t4;
1154
Error 1146 Table 'test.t4' doesn't exist
1135
1155
drop table t1,t2,t3;
1136
1156
create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb;
1137
1157
insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
1155
1175
show create table t1;
1156
1176
Table Create Table
1157
1177
t1 CREATE TABLE `t1` (
1160
1180
UNIQUE KEY `id` (`id`,`id2`)
1161
) ENGINE=InnoDB COLLATE = utf8_general_ci
1162
1182
show create table t2;
1163
1183
Table Create Table
1164
1184
t2 CREATE TABLE `t2` (
1166
1186
KEY `t1_id_fk` (`id`),
1167
1187
CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1168
) ENGINE=InnoDB COLLATE = utf8_general_ci
1169
1189
create index id on t2 (id);
1170
1190
show create table t2;
1171
1191
Table Create Table
1172
1192
t2 CREATE TABLE `t2` (
1174
1194
KEY `id` (`id`),
1175
1195
CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1176
) ENGINE=InnoDB COLLATE = utf8_general_ci
1177
1197
create index id2 on t2 (id);
1178
1198
show create table t2;
1179
1199
Table Create Table
1180
1200
t2 CREATE TABLE `t2` (
1182
1202
KEY `id` (`id`),
1183
1203
KEY `id2` (`id`),
1184
1204
CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1185
) ENGINE=InnoDB COLLATE = utf8_general_ci
1186
1206
drop index id2 on t2;
1187
1207
drop index id on t2;
1188
1208
Got one of the listed errors
1189
1209
show create table t2;
1190
1210
Table Create Table
1191
1211
t2 CREATE TABLE `t2` (
1193
1213
KEY `id` (`id`),
1194
1214
CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1195
) ENGINE=InnoDB COLLATE = utf8_general_ci
1197
1217
create table t2 (id int not null, id2 int not null, constraint t1_id_fk foreign key (id,id2) references t1 (id,id2)) engine = innodb;
1198
1218
show create table t2;
1199
1219
Table Create Table
1200
1220
t2 CREATE TABLE `t2` (
1203
1223
KEY `t1_id_fk` (`id`,`id2`),
1204
1224
CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`)
1205
) ENGINE=InnoDB COLLATE = utf8_general_ci
1206
1226
create unique index id on t2 (id,id2);
1207
1227
show create table t2;
1208
1228
Table Create Table
1209
1229
t2 CREATE TABLE `t2` (
1212
1232
UNIQUE KEY `id` (`id`,`id2`),
1213
1233
CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`, `id2`) REFERENCES `t1` (`id`, `id2`)
1214
) ENGINE=InnoDB COLLATE = utf8_general_ci
1216
1236
create table t2 (id int not null, id2 int not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
1217
1237
show create table t2;
1218
1238
Table Create Table
1219
1239
t2 CREATE TABLE `t2` (
1222
1242
UNIQUE KEY `id` (`id`,`id2`),
1223
1243
KEY `t1_id_fk` (`id2`,`id`),
1224
1244
CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`)
1225
) ENGINE=InnoDB COLLATE = utf8_general_ci
1227
1247
create table t2 (id int not null, id2 int not null, unique (id,id2), constraint t1_id_fk foreign key (id) references t1 (id)) engine = innodb;
1228
1248
show create table t2;
1229
1249
Table Create Table
1230
1250
t2 CREATE TABLE `t2` (
1233
1253
UNIQUE KEY `id` (`id`,`id2`),
1234
1254
CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1235
) ENGINE=InnoDB COLLATE = utf8_general_ci
1237
1257
create table t2 (id int not null, id2 int not null, unique (id,id2),constraint t1_id_fk foreign key (id2,id) references t1 (id,id2)) engine = innodb;
1238
1258
show create table t2;
1239
1259
Table Create Table
1240
1260
t2 CREATE TABLE `t2` (
1243
1263
UNIQUE KEY `id` (`id`,`id2`),
1244
1264
KEY `t1_id_fk` (`id2`,`id`),
1245
1265
CONSTRAINT `t1_id_fk` FOREIGN KEY (`id2`, `id`) REFERENCES `t1` (`id`, `id2`)
1246
) ENGINE=InnoDB COLLATE = utf8_general_ci
1248
1268
create table t2 (id int not null auto_increment, id2 int not null, constraint t1_id_fk foreign key (id) references t1 (id), primary key (id), index (id,id2)) engine = innodb;
1249
1269
show create table t2;
1250
1270
Table Create Table
1251
1271
t2 CREATE TABLE `t2` (
1252
`id` INT NOT NULL AUTO_INCREMENT,
1272
`id` int NOT NULL AUTO_INCREMENT,
1254
1274
PRIMARY KEY (`id`),
1255
1275
KEY `id` (`id`,`id2`),
1256
1276
CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1257
) ENGINE=InnoDB COLLATE = utf8_general_ci
1259
1279
create table t2 (id int not null auto_increment, id2 int not null, constraint t1_id_fk foreign key (id) references t1 (id)) engine= innodb;
1260
1280
show create table t2;
1261
1281
Table Create Table
1262
1282
t2 CREATE TABLE `t2` (
1263
`id` INT NOT NULL AUTO_INCREMENT,
1283
`id` int NOT NULL AUTO_INCREMENT,
1265
1285
KEY `t1_id_fk` (`id`),
1266
1286
CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1267
) ENGINE=InnoDB COLLATE = utf8_general_ci
1268
1288
alter table t2 add index id_test (id), add index id_test2 (id,id2);
1269
1289
show create table t2;
1270
1290
Table Create Table
1271
1291
t2 CREATE TABLE `t2` (
1272
`id` INT NOT NULL AUTO_INCREMENT,
1292
`id` int NOT NULL AUTO_INCREMENT,
1274
1294
KEY `id_test` (`id`),
1275
1295
KEY `id_test2` (`id`,`id2`),
1276
1296
CONSTRAINT `t1_id_fk` FOREIGN KEY (`id`) REFERENCES `t1` (`id`)
1277
) ENGINE=InnoDB COLLATE = utf8_general_ci
1279
1299
create table t2 (id int not null, id2 int not null, constraint t1_id_fk foreign key (id2,id) references t1 (id)) engine = innodb;
1280
1300
ERROR 42000: Incorrect foreign key definition for 't1_id_fk': Key reference and table reference don't match
1282
1302
show create table t2;
1283
1303
Table Create Table
1284
1304
t2 CREATE TABLE `t2` (
1285
`a` INT NOT NULL AUTO_INCREMENT,
1286
`b` INT DEFAULT NULL,
1305
`a` int NOT NULL AUTO_INCREMENT,
1306
`b` int DEFAULT NULL,
1287
1307
PRIMARY KEY (`a`),
1288
1308
UNIQUE KEY `b_2` (`b`),
1290
1310
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
1291
) ENGINE=InnoDB COLLATE = utf8_general_ci
1293
1313
create table t2 (a int auto_increment primary key, b int, foreign key (b) references t1(id), foreign key (b) references t1(id), unique(b)) engine=innodb;
1294
1314
show create table t2;
1295
1315
Table Create Table
1296
1316
t2 CREATE TABLE `t2` (
1297
`a` INT NOT NULL AUTO_INCREMENT,
1298
`b` INT DEFAULT NULL,
1317
`a` int NOT NULL AUTO_INCREMENT,
1318
`b` int DEFAULT NULL,
1299
1319
PRIMARY KEY (`a`),
1300
1320
UNIQUE KEY `b` (`b`),
1301
1321
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`b`) REFERENCES `t1` (`id`),
1302
1322
CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`b`) REFERENCES `t1` (`id`)
1303
) ENGINE=InnoDB COLLATE = utf8_general_ci
1304
1324
drop table t2, t1;
1305
1325
create table t1 (c char(10), index (c,c)) engine=innodb;
1306
1326
ERROR 42S21: Duplicate column name 'c'
1445
1444
show variables like "innodb_sync_spin_loops";
1446
1445
Variable_name Value
1447
1446
innodb_sync_spin_loops 20
1448
set @@global.innodb_sync_spin_loops = @my_innodb_sync_spin_loops;
1449
set @my_innodb_thread_concurrency = @@global.innodb_thread_concurrency;
1450
1447
show variables like "innodb_thread_concurrency";
1451
1448
Variable_name Value
1452
1449
innodb_thread_concurrency 0
1453
1450
set global innodb_thread_concurrency=1001;
1455
Error 1524 Error setting innodb_thread_concurrency. Given value 1001 (> 1000)
1452
Error 1292 Truncated incorrect thread_concurrency value: '1001'
1456
1453
show variables like "innodb_thread_concurrency";
1457
1454
Variable_name Value
1458
innodb_thread_concurrency 0
1455
innodb_thread_concurrency 1000
1459
1456
set global innodb_thread_concurrency=0;
1460
1457
show variables like "innodb_thread_concurrency";
1461
1458
Variable_name Value
1505
1501
insert into t1 values('+ ', '+ ', '+ ');
1506
1502
set @a=repeat(' ',20);
1507
1503
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
1508
ERROR 22001: Data too long for column 'v' at row 1
1509
set @a=repeat(' ',10);
1510
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
1511
ERROR 22001: Data too long for column 'v' at row 1
1512
set @a=repeat(' ',9);
1513
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
1505
Note 1265 Data truncated for column 'v' at row 1
1506
Note 1265 Data truncated for column 'c' at row 1
1514
1507
select concat('*',v,'*',c,'*',t,'*') from t1;
1515
1508
concat('*',v,'*',c,'*',t,'*')
1518
1511
show create table t1;
1519
1512
Table Create Table
1520
1513
t1 CREATE TABLE `t1` (
1521
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1522
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1523
`t` TEXT COLLATE utf8_general_ci
1524
) ENGINE=InnoDB COLLATE = utf8_general_ci
1514
`v` varchar(10) DEFAULT NULL,
1515
`c` varchar(10) DEFAULT NULL,
1525
1518
create table t2 like t1;
1526
1519
show create table t2;
1527
1520
Table Create Table
1528
1521
t2 CREATE TABLE `t2` (
1529
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1530
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1531
`t` TEXT COLLATE utf8_general_ci
1532
) ENGINE=InnoDB COLLATE = utf8_general_ci
1522
`v` varchar(10) DEFAULT NULL,
1523
`c` varchar(10) DEFAULT NULL,
1533
1526
create table t3 select * from t1;
1534
1527
show create table t3;
1535
1528
Table Create Table
1536
1529
t3 CREATE TABLE `t3` (
1537
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1538
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1539
`t` TEXT COLLATE utf8_general_ci
1540
) ENGINE=InnoDB COLLATE = utf8_general_ci
1530
`v` varchar(10) DEFAULT NULL,
1531
`c` varchar(10) DEFAULT NULL,
1541
1534
alter table t1 modify c varchar(10);
1542
1535
show create table t1;
1543
1536
Table Create Table
1544
1537
t1 CREATE TABLE `t1` (
1545
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1546
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1547
`t` TEXT COLLATE utf8_general_ci
1548
) ENGINE=InnoDB COLLATE = utf8_general_ci
1538
`v` varchar(10) DEFAULT NULL,
1539
`c` varchar(10) DEFAULT NULL,
1549
1542
alter table t1 modify v char(10);
1550
1543
show create table t1;
1551
1544
Table Create Table
1552
1545
t1 CREATE TABLE `t1` (
1553
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1554
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1555
`t` TEXT COLLATE utf8_general_ci
1556
) ENGINE=InnoDB COLLATE = utf8_general_ci
1546
`v` varchar(10) DEFAULT NULL,
1547
`c` varchar(10) DEFAULT NULL,
1557
1550
alter table t1 modify t varchar(10);
1552
Note 1265 Data truncated for column 't' at row 2
1558
1553
show create table t1;
1559
1554
Table Create Table
1560
1555
t1 CREATE TABLE `t1` (
1561
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1562
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1563
`t` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
1564
) ENGINE=InnoDB COLLATE = utf8_general_ci
1556
`v` varchar(10) DEFAULT NULL,
1557
`c` varchar(10) DEFAULT NULL,
1558
`t` varchar(10) DEFAULT NULL
1565
1560
select concat('*',v,'*',c,'*',t,'*') from t1;
1566
1561
concat('*',v,'*',c,'*',t,'*')
1789
1784
alter table t1 modify v varchar(300), drop key v, drop key v_2, add key v (v);
1791
Warning 1071 Specified key was too long; max key length is 1023 bytes
1786
Warning 1071 Specified key was too long; max key length is 767 bytes
1792
1787
show create table t1;
1793
1788
Table Create Table
1794
1789
t1 CREATE TABLE `t1` (
1795
`v` VARCHAR(300) COLLATE utf8_general_ci DEFAULT NULL,
1796
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1797
`t` TEXT COLLATE utf8_general_ci,
1790
`v` varchar(300) DEFAULT NULL,
1791
`c` varchar(10) DEFAULT NULL,
1799
1794
KEY `t` (`t`(10)),
1801
) ENGINE=InnoDB COLLATE = utf8_general_ci
1802
1797
select count(*) from t1 where v='a';
1820
1815
explain select count(*) from t1 where v='a ';
1821
1816
id select_type table type possible_keys key key_len ref rows Extra
1822
1 SIMPLE t1 ref v v 1023 const # Using where
1817
1 SIMPLE t1 ref v v 767 const # Using where
1823
1818
explain select count(*) from t1 where v like 'a%';
1824
1819
id select_type table type possible_keys key key_len ref rows Extra
1825
1 SIMPLE t1 range v v 1023 NULL # Using where
1820
1 SIMPLE t1 range v v 767 NULL # Using where
1826
1821
explain select count(*) from t1 where v between 'a' and 'a ';
1827
1822
id select_type table type possible_keys key key_len ref rows Extra
1828
1 SIMPLE t1 ref v v 1023 const # Using where
1823
1 SIMPLE t1 ref v v 767 const # Using where
1829
1824
explain select count(*) from t1 where v between 'a' and 'a ' and v between 'a ' and 'b\n';
1830
1825
id select_type table type possible_keys key key_len ref rows Extra
1831
1 SIMPLE t1 ref v v 1023 const # Using where
1826
1 SIMPLE t1 ref v v 767 const # Using where
1832
1827
explain select * from t1 where v='a';
1833
1828
id select_type table type possible_keys key key_len ref rows Extra
1834
1 SIMPLE t1 ref v v 1023 const # Using where
1829
1 SIMPLE t1 ref v v 767 const # Using where
1835
1830
select v,count(*) from t1 group by v limit 10;
1951
1946
alter table t1 modify v varchar(600), drop key v, add key v (v);
1953
Warning 1071 Specified key was too long; max key length is 1023 bytes
1948
Warning 1071 Specified key was too long; max key length is 767 bytes
1954
1949
show create table t1;
1955
1950
Table Create Table
1956
1951
t1 CREATE TABLE `t1` (
1957
`v` VARCHAR(600) COLLATE utf8_general_ci DEFAULT NULL,
1958
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
1959
`t` TEXT COLLATE utf8_general_ci,
1952
`v` varchar(600) DEFAULT NULL,
1953
`c` varchar(10) DEFAULT NULL,
1961
1956
KEY `t` (`t`(10)),
1963
) ENGINE=InnoDB COLLATE = utf8_general_ci
1964
1959
select v,count(*) from t1 group by v limit 10;
2032
2027
show create table t1;
2033
2028
Table Create Table
2034
2029
t1 CREATE TABLE `t1` (
2035
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
2036
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
2037
`t` TEXT COLLATE utf8_general_ci,
2030
`v` varchar(10) DEFAULT NULL,
2031
`c` varchar(10) DEFAULT NULL,
2038
2033
KEY `v` (`v`(5)),
2039
2034
KEY `c` (`c`(5)),
2040
2035
KEY `t` (`t`(5))
2041
) ENGINE=InnoDB COLLATE = utf8_general_ci
2043
2038
create table t1 (v char(10));
2044
2039
show create table t1;
2045
2040
Table Create Table
2046
2041
t1 CREATE TABLE `t1` (
2047
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
2048
) ENGINE=InnoDB COLLATE = utf8_general_ci
2042
`v` varchar(10) DEFAULT NULL
2050
2045
create table t1 (v varchar(10), c char(10));
2051
2046
show create table t1;
2052
2047
Table Create Table
2053
2048
t1 CREATE TABLE `t1` (
2054
`v` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL,
2055
`c` VARCHAR(10) COLLATE utf8_general_ci DEFAULT NULL
2056
) ENGINE=InnoDB COLLATE = utf8_general_ci
2049
`v` varchar(10) DEFAULT NULL,
2050
`c` varchar(10) DEFAULT NULL
2057
2052
insert into t1 values('a','a'),('a ','a ');
2058
2053
select concat('*',v,'*',c,'*') from t1;
2059
2054
concat('*',v,'*',c,'*')
2072
2067
create table t1 (v varchar(16383), key(v));
2074
Warning 1071 Specified key was too long; max key length is 1023 bytes
2076
create table t1 (v varchar(16383));
2077
show create table t1;
2079
t1 CREATE TABLE `t1` (
2080
`v` VARCHAR(16383) COLLATE utf8_general_ci DEFAULT NULL
2081
) ENGINE=InnoDB COLLATE = utf8_general_ci
2083
create table t1 (v varchar(16383));
2084
show create table t1;
2086
t1 CREATE TABLE `t1` (
2087
`v` VARCHAR(16383) COLLATE utf8_general_ci DEFAULT NULL
2088
) ENGINE=InnoDB COLLATE = utf8_general_ci
2069
Warning 1071 Specified key was too long; max key length is 767 bytes
2071
create table t1 (v varchar(16383));
2072
show create table t1;
2074
t1 CREATE TABLE `t1` (
2075
`v` varchar(16383) DEFAULT NULL
2078
create table t1 (v varchar(16383));
2079
show create table t1;
2081
t1 CREATE TABLE `t1` (
2082
`v` varchar(16383) DEFAULT NULL
2090
2085
set storage_engine=InnoDB;
2091
2086
create table t1 (v varchar(16383)) engine=innodb;
2190
2196
create table t7 (col1 text, index(col1(767)))
2191
2197
engine = innodb;
2193
Warning 1071 Specified key was too long; max key length is 1023 bytes
2199
Warning 1071 Specified key was too long; max key length is 767 bytes
2194
2200
create table t8 (col1 blob, index(col1(767)))
2195
2201
engine = innodb;
2196
2202
create table t9 (col1 varchar(512), col2 varchar(512), index(col1, col2))
2197
2203
engine = innodb;
2199
Warning 1071 Specified key was too long; max key length is 1023 bytes
2200
Warning 1071 Specified key was too long; max key length is 1023 bytes
2205
Warning 1071 Specified key was too long; max key length is 767 bytes
2206
Warning 1071 Specified key was too long; max key length is 767 bytes
2201
2207
show create table t9;
2202
2208
Table Create Table
2203
2209
t9 CREATE TABLE `t9` (
2204
`col1` VARCHAR(512) COLLATE utf8_general_ci DEFAULT NULL,
2205
`col2` VARCHAR(512) COLLATE utf8_general_ci DEFAULT NULL,
2206
KEY `col1` (`col1`(255),`col2`(255))
2207
) ENGINE=InnoDB COLLATE = utf8_general_ci
2210
`col1` varchar(512) DEFAULT NULL,
2211
`col2` varchar(512) DEFAULT NULL,
2212
KEY `col1` (`col1`(191),`col2`(191))
2208
2214
drop table t1, t2, t4, t5, t6, t7, t8, t9;
2209
2215
create table t1 (col1 varchar(768), index(col1))
2210
2216
engine = innodb;
2212
Warning 1071 Specified key was too long; max key length is 1023 bytes
2218
Warning 1071 Specified key was too long; max key length is 767 bytes
2213
2219
create table t2 (col1 varbinary(768), index(col1))
2214
2220
engine = innodb;
2222
Warning 1071 Specified key was too long; max key length is 767 bytes
2215
2223
create table t3 (col1 text, index(col1(768)))
2216
2224
engine = innodb;
2218
Warning 1071 Specified key was too long; max key length is 1023 bytes
2226
Warning 1071 Specified key was too long; max key length is 767 bytes
2219
2227
create table t4 (col1 blob, index(col1(768)))
2220
2228
engine = innodb;
2230
Warning 1071 Specified key was too long; max key length is 767 bytes
2221
2231
show create table t1;
2222
2232
Table Create Table
2223
2233
t1 CREATE TABLE `t1` (
2224
`col1` VARCHAR(768) COLLATE utf8_general_ci DEFAULT NULL,
2225
KEY `col1` (`col1`(255))
2226
) ENGINE=InnoDB COLLATE = utf8_general_ci
2234
`col1` varchar(768) DEFAULT NULL,
2235
KEY `col1` (`col1`(191))
2227
2237
drop table t1, t2, t3, t4;
2228
2238
create table t1 (col1 varchar(768) primary key)
2229
2239
engine = innodb;
2230
ERROR 42000: Specified key was too long; max key length is 1023 bytes
2231
create table t2 (col1 varbinary(1024) primary key)
2240
ERROR 42000: Specified key was too long; max key length is 767 bytes
2241
create table t2 (col1 varbinary(768) primary key)
2232
2242
engine = innodb;
2233
ERROR 42000: Specified key was too long; max key length is 1023 bytes
2243
ERROR 42000: Specified key was too long; max key length is 767 bytes
2234
2244
create table t3 (col1 text, primary key(col1(768)))
2235
2245
engine = innodb;
2236
ERROR 42000: Specified key was too long; max key length is 1023 bytes
2237
create table t4 (col1 blob, primary key(col1(1024)))
2246
ERROR 42000: Specified key was too long; max key length is 767 bytes
2247
create table t4 (col1 blob, primary key(col1(768)))
2238
2248
engine = innodb;
2239
ERROR 42000: Specified key was too long; max key length is 1023 bytes
2249
ERROR 42000: Specified key was too long; max key length is 767 bytes
2240
2250
CREATE TABLE t1
2242
2252
id INT PRIMARY KEY
2260
2270
INSERT INTO t2 VALUES(3);
2261
2271
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`))
2273
create table t1(a int not null) engine=innodb;
2274
insert into t1 values (1),(2);
2279
insert into t1 values(3);
2289
create table t1(a int not null) engine=innodb;
2290
insert into t1 values (1),(2);
2296
insert into t1 values(3);
2263
2301
set foreign_key_checks=0;
2264
2302
create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
2265
2303
create table t1(a char(10) primary key, b varchar(20)) engine = innodb;