write a query to delete similar records in particular
fields(columns) in different tables
Answers were Sorted based on User's Feedback
Answer / ram
Guys, Please see the question again. It is related to
deleting different tables. I guess, the question is
intented to get the answer - ON DELETE CASCADE. We give
foreign constraints on tables and when the parent record is
deleted, the child records are automatically deleted when
you give command as ON DELETE CASCADE
| Is This Answer Correct ? | 5 Yes | 1 No |
Answer / madhu
delete from emp where emp_no in
(select emp_no from emp2 where emp.emp_no=emp2.emp_no)
| Is This Answer Correct ? | 7 Yes | 4 No |
Answer / ramkumar v
CREATE OR REPLACE PROCEDURE DUP AS
DECLARE
TABLENAME_TMP TABLE;
CURSOR C1 IS
SELECT M.TABLE_NAME
FROM USER_TAB_COLS M
WHERE M.COLUMN_NAME LIKE 'EMPNO';
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO TABLENAME_TMP;
WHEN C1%NOTFOUND THEN EXIT;
DELETE FROM TABLENAME_TMP A WHERE ROWID NOT IN
(SELECT MAX(ROWID) FROM TABLENAME_TMP B
WHERE A.EMPNO>=B.EMPNO);
ENDLOOP;
CLOSE C1;
END DUP;
| Is This Answer Correct ? | 4 Yes | 4 No |
Answer / khandu shinde
delete from emp where rowid not in ( select max(rowid) from
emp group by empno)
| Is This Answer Correct ? | 7 Yes | 9 No |
Answer / satyam kumar
Hi,
I have manipulated Khandu Shinde answer because it will
delete complete row.
delete from emp where rowid not in ( select max(rowid) from
emp group by empno having count(redundantcolumnName) > 1)
Note: work only with Oracle.
| Is This Answer Correct ? | 1 Yes | 5 No |
Answer / rajesh
DELETE emp WHERE ROWID NOT IN(SELECT MIN(eid)FROM emp GROUP
BY eid);
| Is This Answer Correct ? | 1 Yes | 5 No |
What are dml commands?
what is the differnce between procedure and function? in both dml operations can work and in procedure through out parameter you can return value ,then what is the differce?
display records from 5 to 9 using rowid or rownum
What are the difference between Functions/Stored Procs and Triggers and where are they used.
Which software is used for pl sql programming?
What is sql and also describe types of sql statements?
Difference between SUBSTR and INSTR?
What is the advantage of index in sql?
What is the Subquery?
what are string data types? : Sql dba
What is the difference between drop and truncate commands?
What are the rules to be applied to nulls whilst doing comparisons?
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)