在大表的每一行上插入不同的UUID

时间:2022-05-26 15:01:21

I have a table with ~80k rows with imported data. Table structure is as follows:

我有一个具有~80k行、导入数据的表。表结构如下:

order_line_items  
  - id  
  - order_id  
  - product_id  
  - quantity  
  - price  
  - uuid  

On import, the order_id, product_id, quantity, and price were imported, but the uuid field was left null.

在导入时,将导入order_id、product_id、quantity和price,但是uuid字段保留为null。

Is there a way, using mysql's UUID() function, to add a uuid to each row of the table in bulk? I could use a script to cycle through each row and update it but if there is a MySQL solution, that would be fastest.

是否有一种方法,使用mysql的UUID()函数,将UUID批量添加到表的每一行?我可以使用脚本循环遍历每一行并更新它,但是如果有MySQL解决方案,那将是最快的。

1 个解决方案

#1


3  

Each call to uuid() returns a different, unique value.

每个对uuid()的调用都返回一个不同的、惟一的值。

So a simple

这样一个简单的

UPDATE order_line_items SET uuid = uuid();

should assign each uuid field a unique value.

应该为每个uuid字段分配一个惟一的值。

#1


3  

Each call to uuid() returns a different, unique value.

每个对uuid()的调用都返回一个不同的、惟一的值。

So a simple

这样一个简单的

UPDATE order_line_items SET uuid = uuid();

should assign each uuid field a unique value.

应该为每个uuid字段分配一个惟一的值。