Creating MySQL table with distinct id:s
I'm using MySQL in PHPMyAdmin. I would like to create table where one can find distinct id's for every user. Can this be done by auto_i开发者_开发知识库ncrement, like
`user_id` SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY
or what does the auto_increment mean?
Yes, that would work. AUTO_INCREMENT means that every time you add a new row, it automatically makes the id the previous + 1. You also don't specify a user_id when you add a new user.
auto increment means that mysql automatically creates the value in the field and increments it by 1 every new record.
You don't have to manage that at all.
Hmmm...maybe I misunderstood the question. If you make the drop down for the "extra" field in phpMyAdmin "auto_increment" it will make it auto increment the field value as described above.
That should cover it :o)
AUTO INCREMENT means that you don't need to fill this field, it will be filled automatically. If you want find distinct id you should make it PK (primary key) or unique. Both of them make this values distinct
精彩评论