mysql id increment to achieve

1, built in mysql table        

                                 

 

 2, use:

  >insert into 表名 values(id,'www',66);

Continuous operation five times Results:

                                                                                                

 

 

============================================================================================

id increment advantages and disadvantages:

advantage:

  1. Database automatic numbering, fast, and incremental growth, in order to store, retrieve very beneficial;
  2. Digital type, small space, it is easy to sort, in the program transfer is also convenient;
  3. If the increase in the recording by a non-system can not specify the field, do not worry about the primary key duplication

Disadvantages:

  1. Because the automatic growth, will become trouble in the manual you want to insert the specified ID record, especially when the system with other systems integration, data import when needed, it is difficult to ensure the ID of the original system does not conflict with the primary key. When the line especially in the new system, old and new systems exist in parallel, and in the case of heterogeneous databases different library bidirectional synchronization when required, the self-energizing primary key will be your nightmare ;
  2. Or when cutover system integration, if the new and old systems of different primary key is a numeric key will lead to modify the primary data type, there are other modifications which will lead to the foreign key table, equally serious consequences;
  3. If the system is digital type, when imported, in order to distinguish between the old and new data, you may want to unify plus a character ID before the old data of the primary key (for example, "o", old) to indicate that this is old data, then the automatic growth of digital type facing a challenge.

 

UUID: Universally Unique Identifier meaning, refers to the numbers on a machine-generated, which ensures the same for all machines in space and time are unique. Usually the platform will provide an API generated. In other words to ensure unique primary keys id within a certain range.

advantage:

  When data appears split, merge storage, can achieve global uniqueness of

Disadvantages:

  1. Effect insertion speed, and causes the hard disk to use low
  2. Comparison of the relative size of numbers between uuid a lot slower, affect the query speed.
  3. uuid occupy a large space, more if you build the index, the more seriously affected

 

 

reference:

https://www.jianshu.com/p/f5d87ceac754

Guess you like

Origin www.cnblogs.com/51python/p/11443602.html