DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: how to drop/remove a single row ??

  1. #1
    Join Date
    Mar 2008
    Posts
    21

    how to drop/remove a single row ??

    Hello,

    How would u go about deleting a signle row form a table?? As the data got duplicated on that table. Same data is there twice and i just need to remove one of them rows?? How would u go about doing that??? is there a drop row cmd or something like that?? Thanks

  2. #2
    Join Date
    Sep 2007
    Location
    Mexico
    Posts
    19
    Hi,

    You have two options:
    1) use ROWID
    2) Delete both, insert one (if you don't have referential integrity enabled)

  3. #3
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    You don't drop rows, you drop objects; rows can be deleted.

    1- Save one of your rows in a temp table, you can create your temp table as select * from your-table where your-conditions and rownum < 2; commit;

    2- Check you have your row safe

    3- Delete both rows as OracleDisected said.

    4- Insert your saved row from your temp table.

    You may want to consider PK constraint or at least a Unique Index in that table.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  4. #4
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    You might also rename the table and recreate the table with a group by to fitler out the duplicates. For non-key rows you need a way to specify which one you want, i.e. max, min, etc.

  5. #5
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,492

    Cool

    Or if you are very brave:

    Code:
    DELETE FROM The_Table T
     WHERE ROWID > (
      SELECT MIN(ROWID) FROM The_Table X
       WHERE X.Key = T.Key);
    "The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width