有些表在設計時沒有加約束條件,雖然有序列號,但是內容有很多重複的資料,比如
id 姓 名
1. 朱 亮
2. 朱 亮
3. 王 小丫
4. 張 三
declare
p_exists number:=0;
begin
select count(*) into p_exists from user_tables where table_name like upper('%t1%');
if p_exists = 1 then
execute immediate 'drop table t1';
end if;
execute immediate 'create table t1(id number not null, lastname varchar(20), firstname varchar(30))';
insert into t1 values(1,'朱','亮');
insert into t1 values(2,'朱','亮');
insert into t1 values(3,'朱','亮');
insert into t1 values(4,'王','小丫');
insert into t1 values(5,'張','三');
end;
/select * from t1;
delete from t1 where rowid not in
(select min(rowid) from t1 group by lastname, firstname
);
1 朱 亮
4 王 小丫
5 張 三
oracle刪除重複行
oracle刪除重複行,一定是設定主鍵才能用 delete from sys role function a where exists select from sys role function where srfu id oracle刪除重複行,可以不用主鍵,推薦使用 delete from sy...
oracle刪除重複行的方法
刪除重複行有兩種方法 資料準備 建表語句 create table a a varchar2 10 b varchar2 20 插入資料 insert into a values 11 22 insert into a values 11 22 insert into a values 11 22 ...
Linux刪除重複行
文字處理時,經常要刪除重複行,下面是三種方法 第一,用sort uniq,注意,單純uniq是不行的。sort n test.txt uniq 第二,用sort awk命令,注意,單純awk同樣不行,原因同上。sort n file awk 第三,用sort sed命令,同樣需要sort命令先排序。...