write a query to delete similar records in particular
fields(columns) in different tables

Answers were Sorted based on User's Feedback



write a query to delete similar records in particular fields(columns) in different tables..

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

write a query to delete similar records in particular fields(columns) in different tables..

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

write a query to delete similar records in particular fields(columns) in different tables..

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

write a query to delete similar records in particular fields(columns) in different tables..

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

write a query to delete similar records in particular fields(columns) in different tables..

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

write a query to delete similar records in particular fields(columns) in different tables..

Answer / rajesh

DELETE emp WHERE ROWID NOT IN(SELECT MIN(eid)FROM emp GROUP
BY eid);

Is This Answer Correct ?    1 Yes 5 No

Post New Answer

More SQL PLSQL Interview Questions

My select statement is not working as expected, So, to overcome from such issues what are the steps needed to be taken care?

2 Answers   CG,


Why select is used in sql?

0 Answers  


what is sql profiler? : Sql dba

0 Answers  


How many subqueries can be nested in a statement?

0 Answers  


What are the return values of functions SQLCODE and SQLERRM ?

2 Answers   PreVator,






What is the purpose of the partition table?

0 Answers  


A table was given with 3 columns like Manager id,Manager Name and Employee name. Question was to create hierarchy.

2 Answers   TCS,


What is the difference between DELETE and TRUNCATE?

15 Answers   Johns Hopkins University, Tech Mahindra,


Table Order_Name has a column Order_Date which gives the date & Time at which the order is passed.Find the table to write a query to find out the latest order.

5 Answers   Thomson,


counting the no.of characters occurs in a string by using pl/sql function

1 Answers   TCS,


What are the types of index in sql?

0 Answers  


ename empno deptno amar 1 10 akbar 2 20 anthonny 3 30 jonathan 4 40 write a procedure to dispaly the column values ina row separated by a deleimiter eg - input - select ename from emp '|' output - amar|akbar|anthony|jonathan input - select empno from emp '@' o/p - 1@2@3@4 input - select deptno from emp '/' o/p - 10/20/30/40 Pls answer this questn.

2 Answers  


Categories