| 1 |
create table t1(a integer) engine=innodb; |
| 2 |
ERROR 42000: This table type requires a primary key |
| 3 |
show warnings; |
| 4 |
Level Code Message |
| 5 |
Error 1173 This table type requires a primary key |
| 6 |
create table t1(a integer unique key) engine=innodb; |
| 7 |
ERROR 42000: This table type requires a primary key |
| 8 |
show warnings; |
| 9 |
Level Code Message |
| 10 |
Error 1173 This table type requires a primary key |
| 11 |
create table t1(a integer not null, b integer, |
| 12 |
unique key(a,b)) engine=innodb; |
| 13 |
ERROR 42000: This table type requires a primary key |
| 14 |
show warnings; |
| 15 |
Level Code Message |
| 16 |
Error 1173 This table type requires a primary key |
| 17 |
create table t1(a integer not null primary key) engine=innodb; |
| 18 |
show create table t1; |
| 19 |
Table Create Table |
| 20 |
t1 CREATE TABLE `t1` ( |
| 21 |
`a` int(11) NOT NULL, |
| 22 |
PRIMARY KEY (`a`) |
| 23 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 24 |
show warnings; |
| 25 |
Level Code Message |
| 26 |
drop table t1; |
| 27 |
create table t1(a integer not null unique key) engine=innodb; |
| 28 |
show create table t1; |
| 29 |
Table Create Table |
| 30 |
t1 CREATE TABLE `t1` ( |
| 31 |
`a` int(11) NOT NULL, |
| 32 |
UNIQUE KEY `a` (`a`) |
| 33 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 34 |
show warnings; |
| 35 |
Level Code Message |
| 36 |
drop table t1; |
| 37 |
set global innodb_force_primary_key = 0; |
| 38 |
create table t1(a integer) engine=innodb; |
| 39 |
show warnings; |
| 40 |
Level Code Message |
| 41 |
insert into t1 values (1),(2),(3); |
| 42 |
set global innodb_force_primary_key = 1; |
| 43 |
select * from t1; |
| 44 |
a |
| 45 |
1 |
| 46 |
2 |
| 47 |
3 |
| 48 |
create table t2(a integer) engine=innodb; |
| 49 |
ERROR 42000: This table type requires a primary key |
| 50 |
show warnings; |
| 51 |
Level Code Message |
| 52 |
Error 1173 This table type requires a primary key |
| 53 |
drop table t1; |
| 54 |
create table t1 (i int not null, key(i)) engine=innodb; |
| 55 |
ERROR 42000: This table type requires a primary key |
| 56 |
create table t1 (i int not null, unique key(i)) engine=innodb; |
| 57 |
show warnings; |
| 58 |
Level Code Message |
| 59 |
show create table t1; |
| 60 |
Table Create Table |
| 61 |
t1 CREATE TABLE `t1` ( |
| 62 |
`i` int(11) NOT NULL, |
| 63 |
UNIQUE KEY `i` (`i`) |
| 64 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci |
| 65 |
drop table t1; |