(1) DELETE FROM table_name A WHERE ROWID > (
SELECT min(rowid) FROM table_name B
WHERE A.key_values = B.key_values);
(2)create table table2 as select distinct * from table1;
drop table1;
rename table2 to table1;
(3) Delete from mytable where rowid not in(
select max(rowid) from mytable
group by column_name );
(4)delete from mytable t1
where exists (select 'x' from my_table t2
where t2.key_value1 = t1.key_value1
and t2.key_value2 = t1.key_value2
...
and t2.rowid > t1.rowid);
除了这4种方法,还有更好的吗?
对了这四种方法那个更好?
SELECT min(rowid) FROM table_name B
WHERE A.key_values = B.key_values);
(2)create table table2 as select distinct * from table1;
drop table1;
rename table2 to table1;
(3) Delete from mytable where rowid not in(
select max(rowid) from mytable
group by column_name );
(4)delete from mytable t1
where exists (select 'x' from my_table t2
where t2.key_value1 = t1.key_value1
and t2.key_value2 = t1.key_value2
...
and t2.rowid > t1.rowid);
除了这4种方法,还有更好的吗?
对了这四种方法那个更好?
解决方案 »
- oracle启动问题
- 求教:如何取近一个自然月平均值的sql的写法
- 为何我的JOB只执行一次,请各位大虾指教
- 一个很好玩的PL/SQL的东西,试试看!
- 关于模糊查询语句写法的问题
- 求助:远程用客户端登录oracle数据库,输入用户名及口令后,点击确定,出现“ora-12154:tns:无法处理服务名”错误,怎么回事?
- 不得了啦~!大家帮我啊~!
- 多个表 union all ,如何按以大到小的排序
- pro*c++ 中嵌入PL块,不知是否版本不对,编译时出错。
- 关于主子表更新的问题
- Oracle9i中引进了merge这样一个命令操作,请问该命令的语法格式怎样,能否举个例子,谢谢?
- 9I中有没有对表中记录管理的工具?
jaguarcts(jaguarcts)
请说说你的理由?
2: 可以剔除重复数据后再建立唯一索引,这也不是很麻烦,不就几百万条记录么?不要delete而用重新建表,
3:如果你的唯一索引可以允许以前的数据存在重复 的,只是今后不允许插入重复数据,可以建立约束的时候指定约束状态允许这种情况存在,但是会否对你的应用构成影响?所以建议:
alter session set sort_area_size = 10240000;
根据字段创建索引
analyze table xxx compute statistics;
create table t as select * from xxx a
where rowid = (select max(rowid) from xxx b where b.col1 = a.col1);
truncate table xxx;
insert into xxx select ... from t;
然后加唯一约束
insert into xxx select ... from t;8i中可以换做:drop table xxx;
rename t to xxx;
没有其他意见吗?