黑松山资源网 Design By www.paidiu.com
1、第一种重复很容易解决,不同数据库环境下方法相似:
以下为引用的内容:
Mysql
create table tmp select distinct * from tableName;
drop table tableName;
create table tableName select * from tmp;
drop table tmp;
SQL Server
select distinct * into #Tmp from tableName;
drop table tableName;
select * into tableName from #Tmp;
drop table #Tmp;
Oracle
create table tmp as select distinct * from tableName;
drop table tableName;
create table tableName as select * from tmp;
drop table tmp;
发生这种重复的原因是由于表设计不周而产生的,增加唯一索引列就可以解决此问题。
2、此类重复问题通常要求保留重复记录中的第一条记录,操作方法如下。 假设有重复的字段为Name,Address,要求得到这两个字段唯一的结果集
Mysql
以下为引用的内容:
alter table tableName add autoID int auto_increment not null;
create table tmp select min(autoID) as autoID from tableName group by Name,Address;
create table tmp2 select tableName.* from tableName,tmp where tableName.autoID = tmp.autoID;
drop table tableName;
rename table tmp2 to tableName;
SQL Server
select identity(int,1,1) as autoID, * into #Tmp from tableName;
select min(autoID) as autoID into #Tmp2 from #Tmp group by Name,Address;
drop table tableName;
select * into tableName from #Tmp where autoID in(select autoID from #Tmp2);
drop table #Tmp;
drop table #Tmp2;
Oracle
DELETE FROM tableName t1 WHERE t1.ROWID > (SELECT MIN(t2.ROWID) FROM tableName t2 WHERE t2.Name = t1.Name and t2.Address = t1.Address);
说明:
1. MySQL和SQL Server中最后一个select得到了Name,Address不重复的结果集(多了一个autoID字段,在大家实际写时可以写在select子句中省去此列)
2. 因为MySQL和SQL Server没有提供rowid机制,所以需要通过一个autoID列来实现行的唯一性,而利用Oracle的rowid处理就方便多了。而且使用ROWID是最高效的删除重复记录方法。
以下为引用的内容:
Mysql
create table tmp select distinct * from tableName;
drop table tableName;
create table tableName select * from tmp;
drop table tmp;
SQL Server
select distinct * into #Tmp from tableName;
drop table tableName;
select * into tableName from #Tmp;
drop table #Tmp;
Oracle
create table tmp as select distinct * from tableName;
drop table tableName;
create table tableName as select * from tmp;
drop table tmp;
发生这种重复的原因是由于表设计不周而产生的,增加唯一索引列就可以解决此问题。
2、此类重复问题通常要求保留重复记录中的第一条记录,操作方法如下。 假设有重复的字段为Name,Address,要求得到这两个字段唯一的结果集
Mysql
以下为引用的内容:
alter table tableName add autoID int auto_increment not null;
create table tmp select min(autoID) as autoID from tableName group by Name,Address;
create table tmp2 select tableName.* from tableName,tmp where tableName.autoID = tmp.autoID;
drop table tableName;
rename table tmp2 to tableName;
SQL Server
select identity(int,1,1) as autoID, * into #Tmp from tableName;
select min(autoID) as autoID into #Tmp2 from #Tmp group by Name,Address;
drop table tableName;
select * into tableName from #Tmp where autoID in(select autoID from #Tmp2);
drop table #Tmp;
drop table #Tmp2;
Oracle
DELETE FROM tableName t1 WHERE t1.ROWID > (SELECT MIN(t2.ROWID) FROM tableName t2 WHERE t2.Name = t1.Name and t2.Address = t1.Address);
说明:
1. MySQL和SQL Server中最后一个select得到了Name,Address不重复的结果集(多了一个autoID字段,在大家实际写时可以写在select子句中省去此列)
2. 因为MySQL和SQL Server没有提供rowid机制,所以需要通过一个autoID列来实现行的唯一性,而利用Oracle的rowid处理就方便多了。而且使用ROWID是最高效的删除重复记录方法。
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年04月27日
2024年04月27日
- Sweety.2005-十七岁不温柔【丰华】【WAV+CUE】
- [ABC唱片]-《金色大厅音箱测试壹号》[德国版HD-159]【WAV+CUE】
- 张玉华.2002-属于自己【环球】DTS【WAV分轨】
- 林小宝《细水长流HQCD》[低速原抓WAV]
- 包娜娜.1976-情海(2016梦田复黑版)【凯联机构】【WAV+CUE】
- 陈柏全.1991-关于昨夜【歌林】【FLAC分轨】
- 戴佩妮.2005-爱疯了【EMI百代】【WAV+CUE】
- 林志炫《炫音王子(德国黑胶CD)》[WAV+CUE][615M]
- 降央卓玛《天籁女王》2CD[WAV+CUE][1.2G]
- 飞利浦试音碟《环球群星监听录》[DFF][847M]
- 姜育恒.2003-金曲3CD【光美】【WAV+CUE】
- 黎子菱.1997-守候【低空飞行】【WAV+CUE】
- 关心妍.2016-SMILE2CD【星娱乐】【WAV+CUE】
- 汤宝如.1998-自选精选30首2CD【宝丽金】【WAV+CUE】
- 群星.2000-永恒的杰出美声【瑞华】【WAV+CUE】