oracle删除重复行delete repeat
2015-09-09数据库产生大量的重复数据需要批量删除。
1、 创建表保存rowid
create table t1 (r varchar2(20));
2、insert into t1 select max(rowid) from chat_recorder_201509 where create_time between TO_DATE('20150907 19:00:00',
'YYYYMMDD HH24:MI:SS') and TO_DATE('20150908 01:00:00', 'YYYYMMDD HH24:MI:SS') group by RECORDER_ID having count(*) > 1;
28335 rows created.
3、删除rowid包含在t1表
delete from chat_recorder_201509 where rowid in (select r from t1);
28335 rows deleted.
4、检查结果select count(*) from chat_201509 where create_time between TO_DATE('20150907 19:00:00', 'YYYYMMDD HH24:MI:SS') and TO_DATE('20150908 01:00:00', 'YYYYMMDD HH24:MI:SS');
5、==========================================
select vst_phone from message_new where message_id in (select message_id from (select a.message_id,row_number() over(partition by message order by message) as n from message_new a where company_id=39415 and create_time > trunc(sysdate-2)) where n > 1);
6、delete from message_new where message_id in (select message_id from (select a.message_id,row_number() over(partition by message,vst_phone order by message) as n from message_new a where company_id=39415 ) where n > 1);
7、select user_name,count(1) row_number from customer group by user_name having count(user_name) > 1;
8、select cid,count(1) from CONFIG group by cid having count(1) > 150 order by count(1);
相关日志
- rman-0level全备份及恢复
- nagios监测dbbak
- oracle限制远程访问
- 给left join关联关系字段加索引
- Oracle ASM
- Oracle Database 18c
- DG两个数据库SID不同
- DG-Dgmgrl
- Oracle中的BLOB和CLOB
- oracle 启动错误:MEMORY_TARGET not supported on this system
- create bigfile tablespace
- Oracle11G新特性:分区表分区默认segment大小64k变为8M
- oracle增加md5函数
- rollback回滚 (1)
- oracle中drop一个表,让数据文件释放空间
- CentOS 5.11 x64静默安装(slient install)oracle 11.2.0.4 x64
- sqlplus USER/PWD@IP:PORT/SID
- oracle删除所有表
- oracle查询长整数实例
- oracle设置NLS_DATE_FORMAT参数实例
- ORA-00600和ORA-08103错误(oracle10g)
- oracle user passwd用户密码
- oracle导入txt数据文件实例
- conn user as sysdba
- SGA/PGA的设置与调整 (9)
- ORA-01843: not a valid month (3)
- oracle表空间(tablespace)的增删改查(create/drop/rename,move/select) (2)
- rlwrap实现sqlplus使用上下键查历史命令