Details
-
Bug
-
Status: Open (View Workflow)
-
Trivial
-
Resolution: Unresolved
-
10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5(EOL), 10.6, 10.7(EOL)
-
None
-
None
Description
MariaDB syntax allows any combination of UNIQUE and primary key.
And if both are present in that column definition, then only primary key index is created:
MariaDB [test]> CREATE or replace TABLE t1 ( i INT primary key UNIQUE UNIQUE UNIQUE primary key unique );
|
Query OK, 0 rows affected (0.09 sec)
|
|
|
MariaDB [test]> show create table t1;
|
+-------+--------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+--------------------------------------------------------------------------------------------------------+
|
| t1 | CREATE TABLE `t1` (
|
`i` int(11) NOT NULL,
|
PRIMARY KEY (`i`)
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
|
+-------+--------------------------------------------------------------------------------------------------------+
|
1 row in set (0.00 sec)
|
|
|
MariaDB [test]> CREATE or replace TABLE t1 ( i INT UNIQUE UNIQUE UNIQUE);
|
Query OK, 0 rows affected (0.10 sec)
|
|
|
MariaDB [test]> show create table t1;
|
+-------+---------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+---------------------------------------------------------------------------------------------------------------+
|
| t1 | CREATE TABLE `t1` (
|
`i` int(11) DEFAULT NULL,
|
UNIQUE KEY `i` (`i`)
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
|
+-------+---------------------------------------------------------------------------------------------------------------+
|
1 row in set (0.00 sec)
|
mysql 5.6-8.0 creates in such case both unique + primary indexes:
CREATE TABLE `t1` ( `i` int(11) NOT NULL, PRIMARY KEY (`i`), UNIQUE KEY `i` (`i`) ) ENGINE=InnoDB
|