CREATE TABLE customers ( cust_id int NOT NULL AUTO_INCREMENT, cust_name char(50) NOT NULL , PRIMARY KEY (cust_id) ) ENGINE=InnoDB;
When executed for the first time:
insert into customers values(1,'aaa');
When executed for the second time:
insert into customers values(null,'bbb');
The primary key of the second record is 2
Insert the third record:
insert into customers2(cust_name) values('ccc');
When using it, it is best to use the third record to prevent the table from increasing later. When, the sql statement that inserts data reports an error.
Insert the fourth and fifth records:
insert into customers2 (cust_name) values ('ee'),('ff');
When inserting more than 2 statements together, separate them with commas.
The meaning of ENGINE=InnoDB:
The storage engine is innodb. nnoDB is the first data storage engine on MySQL to provide foreign key constraints. In addition to providing transaction processing, InnoDB also supports row locks, providing the same consistent lock-free reading as Oracle, which can increase the number of concurrent reading users and Improves performance without increasing the number of locks. InnoDB is designed to maximize performance when processing large volumes of data, and its CPU utilization is the most efficient of any other disk-based relational database engine.
InnoDB is a complete database system placed in the MySQL backend. InnoDB has its own buffer pool that can buffer data and indexes. InnoDB also stores data and indexes in table spaces, which may contain several files. , which is completely different from the MyISAM table. In MyISAM, the table is stored in a separate file. The size of the InnoDB table is only limited by the size of the operating system file, which is generally 2GB.
The above is the content of primary key increment in mysql. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!