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
- Modification method of starting value of MySQL auto increment ID
- Solution of duplicate entry ‘value’ for key ‘field name’ in MySQL
- Table ‘sell.hibernate_sequence‘ doesn‘t exist
- mysql ERROR 1025 (HY000): Error on rename of
- MySQL partitions the existing tables of the data table
- Duplicate entry ‘787192513’ for key ‘primary’
- [Oracle] when inserting data, “ora-00001: unique constraint” appears
- Error 3002: Problem in mapping fragments | c# linq to entities
- MySQL creates tables and sets auto increment of primary keys
- mysql ERROR 1050 (42S01): Table already exists
- Txt import MySQL: error 1062 (23000): duplicate entry ‘0’ for key ‘primary’
- What is the schema in the database?
- javax.persistence.EntityNotFoundException : unable to find error
- Error 1364 (HY000): field ‘SSL_ cipher’ doesn’t have a default value
- mysql error 1062
- Error: field * doesn’t have a default value
- The difference between hive and relational database
- django.db.utils .IntegrityError: NOT NULL constraint failed: blog_ blog.author_ ID error resolution
- MySQL:Foreign key fails with error Error Code: 1452.
- The solution of duplicate entry ‘for key’ primary ‘when inserting data in MySQL