Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to set mysql auto-insert id
How to set mysql auto-insert id
Set mysql? To insert the id automatically, you need to set the id as the primary key of plastic auto-growth. The following describes the setting method.

Use an example to illustrate:

Students, create a table.

Create? Table? Students (

id? int(5)? Isn't it? null? Automatic incremental therapy,

Name? varchar(20)? Isn't it? Empty,

Age? int(3)? Isn't it? Empty,

Elementary? Key (id)););

You don't need to insert an id when inserting data. You can do this:

Insert? Become? Student (name, age)? Value ('Xiaobai',12); By default, the first inserted data id is 1.

Insert? Become? Student? (name, age)? Value ('Xiaoming',11); The second insert data id is 2 by default, and the third insert data ID, the fourth insert data ID and the second insert data ID are automatically increased in turn.

From the above example, we can see that when inserting data into the table, it can be inserted automatically without inserting id.