+ 3

CREATE TABLE Users ( id int NOT NULL AUTO_INCREMENT, username varchar(40) NOT NULL, password varchar(10) NOT NULL, PRIMARY

why we need to add Auto_increment with ID ??

14th Jul 2017, 2:24 PM
Ramesh
Ramesh - avatar
6 Réponses
+ 4
You can set it to start at a particular number, if you don't want it to start at 1. 1 is the default value, and it'll increase from there. You can change its default to 1000 if you want, and it'll start at 1000 instead of 1.
14th Jul 2017, 2:34 PM
AgentSmith
+ 4
Each time you create a new record, the ID will increase by 1 so you don't have two records being referenced by the same ID.
14th Jul 2017, 2:25 PM
AgentSmith
+ 3
Yes. Each new record is +1 from the previous record ID number. If default is 1000: Record 1: 1000 Record 2: 1001 Record 3: 1002 etc... If default is 1: Record 1: 1 Record 2: 2 Record 3: 3 etc....
14th Jul 2017, 2:42 PM
AgentSmith
+ 1
It's comfortable to use auto-increment, we don't need to think about id increment, during insertion. But it's not necessarily. You coud increment id yourself, or use some guid as id, for example.
14th Jul 2017, 3:01 PM
shaldem
shaldem - avatar
0
but as you can see the ID field has not given any specific limit. So if the table is made then what will be the first ID ??
14th Jul 2017, 2:30 PM
Ramesh
Ramesh - avatar
0
Say the ID starts with 1 and then it will be incremented right ??
14th Jul 2017, 2:37 PM
Ramesh
Ramesh - avatar