write a query to delete similar records in same table
Answers were Sorted based on User's Feedback
I think simply we can do like the following..
1. First we have to transfer all data from a table to
temporary table
create table Temp_table as select * from original_table;
2. Delete all record from Original Table....
delete original_table;
3. Now we can write a query by using INSERT and UNION
If any issue let me know....
insert into original_table (select * from temp_table
UNION select * from UNION )
| Is This Answer Correct ? | 0 Yes | 3 No |
Answer / umadevi
--deletes records within table without changing table name
delete from temp t1 where rowid<(select max(rowid) from temp
t2 where t1.empno=t2.empno) order by empno;
or
--create new table n insert records.
create table t1 as select distinct * from temp;
or
(truncate table)
truncate table t1;
insert into t1 select distinct * from temp;
| Is This Answer Correct ? | 1 Yes | 5 No |
Answer / swapna
One way is to rename the original table to something else,
and copy the unique records into the original table.
rename 'Table2', 'Table1'
select distinct * into Table2 from Table1
drop table1
| Is This Answer Correct ? | 5 Yes | 13 No |
Which command is used to delete a package?
What is pl/sql table? Why it is used?
What is a ddl command?
Why we use triggers in mysql?
What are the types pl/sql code blocks?
How consistent is the view of the data between and within multiple sessions, transactions or statements ?
Mention what plvcmt and plvrb does in pl/sql?
what is not null constraint? : Sql dba
a. Can you delete data from a View. b. If Yes, can you delete it if there are multiple tables c. If No, can you delete if there is single source table which is joining.
How do you respond to dementia behavior?
differentiate between float and double. : Sql dba
what is indexing, searching and user interface?
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)