我有一张表A [id,name],据说有1000万条记录。我需要用1000万个唯一名称替换所有名称。所以,为此我有一个文本文件作为查找文件,它有1000万个名字,由新行分隔。所以,一堆问题:
答案 0 :(得分:1)
好吧,让我们想一想,你有很多名字,它们不能全部加载到内存中,所以我们将尽可能找到解决方案。
对于随机方法,您可以在数据库中创建临时列,在其上创建唯一键并始终使用:
1)take a name on line "x" (by random or whatever you want)
2)random record "y" in database which was not replaced yet (it can be tracked with just one boolean)
3)try to add the name on line x to the record y AND to the same record add x to the temp column.
4)if Unique errorcomes, it means the name was already given to someone, repeat once more with another x.
如果我们可以跟踪“x”并且我们确定,我们没有使用alredy给定的名称,我们不需要Unique修饰符。
答案 1 :(得分:1)