首页 > Linux操作系统 > Linux操作系统 > 记录一下避免排序和删除重复行
select distinct owner, table_name from test_sort2 order by owner,table_name;
建立一个所以再OWNER ,TABLE_NAME
这样可以避免排序
select owner, table_name
from test_sort2 a
where A.ROWID = (select /*+ no_unnest */ max(rowid)
from test_sort2 b
where a.owner = b.owner
and a.table_name = b.table_name)
order by owner,table_name;
删除重复的行
SQL> select * from oo;
IT
---------------------------------------
1
1
2
2
SQL>
SQL> delete oo a where a.rowid <> (select max(rowid)
2 from oo b
3 where a.it = b.it);
2 rows deleted
SQL> commit;
Commit complete
SQL> select * from oo;
IT
---------------------------------------
1
2
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7728585/viewspace-745223/ ,如需转载,请注明出处,否则将追究法律责任。