MySQL SQL statements generated 32 UUID

In operations, sometimes encounter the single line, the line register, you need to generate batch data was imported in the scene database.

At this point if your table is not the primary key auto-increment integer Int but 32 of the UUID this case how to do it?

 

MySQL actually achieve the UUID, and provides a UUID () function for us. Usage is as follows:

 

 

  1. mysql> SELECT UUID();
  2. mysql> c2cb8f66-351f-11e7-b3ed-00163e0429b6
  3. MySQL> the SELECT the REPLACE ( the UUID (), '-', ''); # a '-' symbol to replace
  4. mysql> 45c87fa0352211e78d40d4977a9ea871



 

() Function, the first three sets of numbers generated from the time stamp in the UUID MySQL, temporarily holds the fourth group of unique time stamp,
The fifth set of numbers is a punctuation IEEE 802 node values, the only secure a space. Using the UUID () function, you may be generated temporally, spatially values ​​are unique.
It is said that as long as the use UUID, can not see two duplicate UUID values.

Guess you like

Origin www.cnblogs.com/zhuyeshen/p/11890148.html