当前位置: 移动技术网 > IT编程>数据库>Mysql > mysql如何批量插入不重复uuid数据?

mysql如何批量插入不重复uuid数据?

2018年04月10日  | 移动技术网IT编程  | 我要评论

第一步:先把需要查询的数据列出来

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,搞定

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网