Home

Friday, November 29, 2013

Menghapus duplikat rows

Di bawah ini cara mudah untuk menghapus dupilkat records pada table di database oracle :

SQL> create table test_data
  2  (id number, ename varchar2(200))
  3  /
Table created.
SQL>
 SQL> insert into test_data values(1, 'Scott')
  2  /
1 row created.
SQL> insert into test_data values(2, 'Scott') 
2  /
1 row created.
SQL> set linesize 100
SQL> set linesize 100
SQL> column id format 99
SQL> column ename format a32
SQL>
SQL> select * from test_Data
  2  /
ID ENAME--- -------------------------------- 
1 Scott 
2 Scott
SQL> delete from test_Data where rowid not in
2  (select max(rowid) from test_data group by ename)
3  /
1 row deleted.
SQL>
SQL> select * from tes

Selamat Mencoba :)

No comments:

Post a Comment