How to understand the specification of naming primary key index in Alibaba development manual?

this is the definition of the index in the MySQL table recommendation in Alibaba"s Java development manual, where: the primary key index is named pk_ field name
isn"t an index created for the primary key by default? how do you name this index?
ask Boss MySQL to answer questions

clipboard.png

Jan.29,2022

Primary key index naming should be for Oracle or other databases. MySQL has not found the syntax for specifying the primary key index name. Generally, the primary key index name defaults to PRIMARY.
MySQL and Oracle have differences in primary key indexes. Oracle's primary key index is an additional index with unique and non-empty attributes, while MySQL's table itself is a clustered index, and the index key is the primary key, so instead of building an index for the primary key, the primary key is used as the index key and the B-tree structure is used to organize the table data.
for the name of the primary key index, it is only for the database that can manually specify the name of the primary key index. During management, no one is sure what the name of the index is. The first is the uncertainty within the database, you can't predict what the index name is, and the second is related to the specification. In the absence of normative constraints, some people let the database determine the index name, and some people like to specify the name themselves. So when managing the primary key, it is inevitable to confirm which columns are the primary key and what the corresponding index is.
so for ease of management and standardization, simply unify the naming conventions for primary keys.


the name automatically created is different each time, which is not convenient for subsequent scripted management.

you can use

create table testpk(
id int,
nm text,
CONSTRAINT `pk_id` PRIMARY KEY (`id`)
);

specifies the constraint name, but ignores the name assigned to the primary key for Primary key, MySQL.

In MySQL, the name of a PRIMARY KEY is PRIMARY.

https://dev.mysql.com/doc/ref.

Menu