how to delete duplicate rows from a specified table(only
single table)
how do you know which join is need to be used
Answers were Sorted based on User's Feedback
Answer / mkumar.it
delete <table_name> where rowid not in (select min(rowid)
from <table_name> group by <dup_rec_col>)
max(rowid) can also be used provided you have to retain the
latest value other wise min(rowid) is fine.
| Is This Answer Correct ? | 8 Yes | 0 No |
Answer / dinesh mohan upadhyay
delete from emp
where rowid>any(select min(rowid) from emp a where
a.col1=col1)
| Is This Answer Correct ? | 15 Yes | 8 No |
DELETE FROM tablename A WHERE ROWID>(SELECT MIN(ROWID) FROM
tablename B WHERE A.key_values=B.key_values);
| Is This Answer Correct ? | 6 Yes | 2 No |
Answer / lakshya
SELECT * FROM table_name
WHERE ROWID NOT IN (SELECT MIN(ROWID) FROM table_name GROUP
BY table_columns);
| Is This Answer Correct ? | 9 Yes | 8 No |
Answer / raghavendraprasad
delete from table_name where rowid not in (select max
(rowid) from table group by duplicate_values_field_name);
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / jas
delete from table_name where rowid > (select min(rowid)
from table_name where a.col_name=b.col_name)
create new_table as select distinct * from table_name;
drop table_name;
create table_name as select * from new_table;
drop new_table;
delete from table_name where rowid not in (select max
(rowid) from table_name where a.col_name=b.col_name)
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / venkateswararao
delete from emp p where rowid<(select max(rowid) from emps where p.ename=s.ename)
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / kishor solanki @ 9904762204
CREATE TABLE new_table as SELECT * FROM test GROUP BY url;
DROP TABLE test;
RENAME TABLE new_table TO test;
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / arif jameel
First add an Identity Column in table
Alter table <tblname>
Add < New_columnID > int identity(1,1)
Delete from <tblname> where < New_columnID> in
(select max(New_columnID)from <tblname>
Group by <tbl_columnname>
having count (<tbl_columnname>)>1)
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / kishor solanki @ 9904762204
create table newtable as select * from oldtable order by dupcol;
drop oldtable;
rename newtable to oldtable;
| Is This Answer Correct ? | 0 Yes | 0 No |
What are schema-level triggers?
What is a join?Explain the different types of joins?
6 Answers Bank Of India, CitiGroup, Google, ICICI, Saama Tech, SkyTech, TCS,
What is the main difference between sql and pl/sql?
Why truncate is faster than delete?
How to fix oracle error ora-00942: table or view does not exist
Is sqlite thread safe?
What does t sql mean?
wht is the difference between truncat,drop in sqlserver wht is the difference between function and stored procedure
1. is it possible to use the cursor atttibutes (%found ,% rowcount , %isopen , %notfound ) to our user defined cursor names ....... cursor cursor_name is select * from scott.emp if you use... cursor_name%found , %rowcount ,%isopen,%notfound...will it work... -------------------------- 2.what is the difference between the varray and index by table .. -------- 3. type type_name is table of number(8,3) index by binary_integer; identifier_name type_name; first , last , prior , next ,trim are the methods we can use it for the above type...simillary is there any way to apply for cursors... with thanks and regards..sarao...
What is the difference between execution of triggers and stored procedures?
What are the limitations of sql express?
Is sql dba a good career? : SQL DBA
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)