在sql server 2012中,我有一个包含超过2500万行且有重复项的表。该表没有唯一索引。它只有一个非聚集索引。我想消除重复项,所以我想到了以下内容
select distinct * into #temp_table from primary_table
truncate primary_table
select * into primary_table from #temp_table
我想知道 select unique * 查询有多昂贵。如果我的上述程序非常昂贵,我想知道是否还有其他替代方法。
我不知道它有多昂贵,但另一种方法是创建另一个带有主键的表,在那里插入所有数据并默默地拒绝重复项,如此处所述
http://web.archive.org/web/20180404165346/http://sqlblog.com:80/blogs/paul_white/archive/2013/02/01/a-creative-use-of-ignore-dup-key。 ASPX http://web.archive.org/web/20180404165346/http://sqlblog.com:80/blogs/paul_white/archive/2013/02/01/a-creative-use-of-ignore-dup-key.aspx
基本上,使用 IGNORE_DUP_KEY
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)