home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / database / oracle / 1122 < prev    next >
Encoding:
Internet Message Format  |  1992-07-23  |  1.3 KB

  1. Path: sparky!uunet!lhdsy1!usho93!usho32.hou281.chevron.com!agmkne
  2. From: agmkne@usho32.hou281.chevron.com (M.K.Netzband)
  3. Newsgroups: comp.databases.oracle
  4. Subject: Re: Deleting Duplicates
  5. Message-ID: <1992Jul23.180919.24200@usho93.hou281.chevron.com>
  6. Date: 23 Jul 92 18:09:19 GMT
  7. References: <VN70NB1w165w@iowegia.uucp> <1992Jul23.091611.1@jaguar.uofs.edu>
  8. Sender: news@usho93.hou281.chevron.com (USENET News System)
  9. Organization: Chevron
  10. Lines: 23
  11.  
  12. In article <1992Jul23.091611.1@jaguar.uofs.edu> littlec1@jaguar.uofs.edu (Chris Little) writes:
  13. >In article <VN70NB1w165w@iowegia.uucp>, bob@iowegia.uucp (Bob Powers) writes:
  14. >> How can I delete duplicate rows in a table using SQL*PLUS.  This is
  15. >> an unindexed table and I would like to keep it that way.
  16. >
  17. >I'm relatively new at the job, but I suspect you could create a similar
  18. >table, do an INSERT SELECT UNIQUE from the old table to the new table,
  19. >delete all rows from the old table, copy all rows from the new table
  20. >to the old, and then drop the new one.  Maybe there's a better way.
  21. >
  22.  
  23. Try customizing the following...
  24.  
  25. delete from TABLE_NAME a
  26.  where a.rowid < (select max(b.rowid)
  27.                    from TABLE_NAME b
  28.                    where b.field1 = a.field1
  29.                    and   b.field2 = a.field2);
  30.  
  31.  
  32.  
  33. Mike
  34.  
  35.