-
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
-
Hi,
You have two options:
1) use ROWID
2) Delete both, insert one (if you don't have referential integrity enabled)
-
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.
-
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.
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|