首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

oracle凭借rowid选择或删除重复行

2012-09-10 
oracle借助rowid选择或删除重复行有表:create table t_test1(idnumber,namevarchar2(50),agenumber,birthd

oracle借助rowid选择或删除重复行

有表:create table t_test1(   id        number,   name      varchar2(50),   age       number,   birthday  date);1、选择出重复的行select a.* from t_test1 a where rowid <> (select max(rowid)                   from t_test1 b                  where a.id = b.id  -- where语句后面的条件是你定义重复的规则                    and a.name = b.name                    and a.age = b.age                    and a.birthday = b.birthday);2、删除重复的行delete from t_test1 a where rowid <> (select max(rowid)                   from t_test1 b                  where a.id = b.id                    and a.name = b.name                    and a.age = b.age                    and a.birthday = b.birthday);

热点排行