oracle 违反主键id错误,查看表中是否有重复的ID列的值,并删除重复数据
2015-07-21 15:38
716 查看
查询是否有重复数据:
select DEV_BRU_A(表的主键列) from u_hx_adm_sub_bureau(表名) group by DEV_BRU_A having count(DEV_BRU_A) > 1;
注:其中的‘DEV_BRU_A’是表的主键列,‘u_hx_adm_sub_bureau’为表名。
删除重复数据:
delete from u_hx_adm_sub_bureau where DEV_BRU_A in
(select DEV_BRU_A from u_hx_adm_sub_bureau group by DEV_BRU_A having count(DEV_BRU_A) > 1)
and rowid not in
(select min(rowid) from u_hx_adm_sub_bureau group by DEV_BRU_A having count(DEV_BRU_A) > 1);
select DEV_BRU_A(表的主键列) from u_hx_adm_sub_bureau(表名) group by DEV_BRU_A having count(DEV_BRU_A) > 1;
注:其中的‘DEV_BRU_A’是表的主键列,‘u_hx_adm_sub_bureau’为表名。
删除重复数据:
delete from u_hx_adm_sub_bureau where DEV_BRU_A in
(select DEV_BRU_A from u_hx_adm_sub_bureau group by DEV_BRU_A having count(DEV_BRU_A) > 1)
and rowid not in
(select min(rowid) from u_hx_adm_sub_bureau group by DEV_BRU_A having count(DEV_BRU_A) > 1);
相关文章推荐
- Android之获取手机上的图片和视频缩略图thumbnails
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- SQL中的三值逻辑
- 数据库链接字符串查询网站
- SQL Server 作业批量停止
- 结束SQL阻塞的进程
- 动态生成SQL Server视图作业
- Oracle Containers for J2EE远程安全漏洞(CVE-2014-0413)
- Oracle 10g R2不能使用EM的问题
- SQL Server 语句操纵数据库
- 表空间操作
- PreparedStatement中in子句的处理
- SQL(结构化查询语句)
- VMware下RedHat4.8_64位安装Oracle 10g RAC--简略脚本
- oracle sql日期比较