1. 程式人生 > >mysql批量插入不重複uuid資料

mysql批量插入不重複uuid資料

第一步:先把需要查詢的資料列出來

select UUID(), a.Code, a.Name,a.Continent from country a, countrylanguage b where a.Code = b.CountryCode;

注意:UUID()不要分割,分割後,uuid相同

第二步:把資料插入到表中

insert into temptable (id,code,name,continent) (
   select UUID(), a.Code, a.Name,a.Continent from country a, countrylanguage b where a.Code = b.CountryCode
);

第三步:更新UUID,將“ - ”替換掉

update TEMPTABLE set id =select REPLACE(id,'-','')


OK,搞定

o