[reprint and save] MySQL does not set the primary key and uses the self growing ID method

MySQL can only have one auto growth field per table. This auto growth field can be used as a primary key or a non primary key. However, please note that when you use an auto growth field as a non primary key, you must add a unique index to it, otherwise the system will report an error. For example:

1. Set the auto grow field as the primary key.

create table t1 (id int auto_ increment Primary key,sid int);

2. Set the auto grow field to a non primary key. Note that the unique key must be added explicitly.

create table t2 (sid int primary key,id int auto_ increment Unique);

3. Set the auto growth field to a non primary key. If no unique index is added, an error will be reported * *, as shown in the following statement

create table t3 (sid int primary key,id int auto_ increment)。

MySQL is a relational database management system, developed by MySQL AB company of Sweden, which is a product of Oracle at present. MySQL is one of the most popular relational database management systems. In web application, MySQL is the best RDBMS (relational database management system) application software. MySQL is a kind of relational database management system. Relational database stores data in different tables instead of putting all data in a large warehouse, which increases the speed and flexibility. The SQL language used by MySQL is the most commonly used standardized language for accessing databases. MySQL software adopts dual authorization policy, which is divided into community version and commercial version. Because of its small size, fast speed, low total cost of ownership, especially the open source, MySQL is generally chosen as the website database for the development of small and medium-sized websites. Because of the excellent performance of its community version, it can form a good development environment with PHP and Apache

come from: https://zhidao.baidu.com/question/621026495899595372.html

Read More: