易截截图软件、单文件、免安装、纯绿色、仅160KB

oracle数据库 - Oracle / 高级技术

在Oracle中怎么删除重复的行,但要保留一条记录。



delete table where rowid not in (select max(rowid) from table group by col1,col2,...,coln);

对,用rowid 来过滤.

delete tb a
where a.rowid > (select min(b.rowid)
from tb b
where b.xx = a.xx)

引用
在Oracle中怎么删除重复的行,但要保留一条记录。

靠,我面试时就考了这题,当时紧张没写出来,郁闷死了。2楼正解

delete 表名 where rowid not in (select max(rowid) from 表名 group by 列名);(注这里的列名就是你根据那个列判断重复的,可以为多列)

delete from table where rowid in (select a.rowid from table a, table b  
where a.rowid>b.rowid and a.col1=b.col1 and a.col2 = b.col2 and ...)

使用rowid时最后的解决办法,表中每行记录的rowid都是唯一的
delete from table_A a
  where a.rowid < (select max(b.rowid) 
  from table_A b 
  where a.column1 = b.column1
  and a.column2 = b.column2
  ... --有多少列就写多少列,方法同上
  );

112223


相关问答:

oracle 10g web登陆EM的问题? - Oracle / 基础和管理

安装了Oracle 10g,默认安装了orcl数据库,这个数据库能不能删除啊,还有我如果新建了其他数据库,怎么知道在web中登陆不同数据库的地址啊?

1
可以删除
2
在WEB地址栏中输入地址的时候指定新创建的数据库的IP ......

Oracle 数据导出问题 - Oracle / 高级技术

exp user/password@dbname file=c:\table.dmp tables=jbitaku,jbitakum grants=y
然後按回車鍵 說明:  user/password@dbname  分別表示用戶名,密碼和服務名 f ......

一个pl/sql问题 - Oracle / 开发

我是在toad中输入下段sql
  declare
  TYPE test_rec IS record(
  code varchar(10),
  name varchar(30)
  );
  v_book test_rec;
    ......

oracle 安装 01092 错误 - Oracle / 基础和管理

oracle 11g 安装 01092 错误,
日志信息:
[oracle@linux trace]$ vi alert_orcl.log 
MMON started with pid=14, OS id=9089
RESETLOGS after incomplete recovery UNTIL CHANGE 522752
Errors in file / ......

oracle - Oracle / 基础和管理

oracle数据库有哪些对象
这问得太笼统了,友情帮顶.

这是一个大问题,很大的问题。


帮顶......
------------------------------------------------------------------------------ 
Blog: http://b ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号