Friday, March 29, 2013

How can I find which tables reference a given table in Oracle

SELECT table_name
  FROM ALL_CONSTRAINTS
 WHERE constraint_type = 'R'
   AND r_constraint_name IN (
           SELECT constraint_name
             FROM ALL_CONSTRAINTS
            WHERE table_name = 'TEST'
              AND constraint_type IN ('U', 'F','P')
         )

Thursday, March 21, 2013

ORA-01940: Cannot drop user that is currently connected



select sid,serial#,osuser,machine from v$session where username='IPMS';

SID                    SERIAL#                OSUSER            MACHINE                                                        
---------------------- ---------------------- ------------------------------
139                    3262                   PRABHAKAR                       -Laptop              





alter system kill session '139,3262';


alter system kill succeeded.                     


DROP USER ABC CASCADE;





DROP USER ABC succeeded.
             

Thursday, March 14, 2013

update query

update a set a.name = (select new from b where a.name = b.new
 and b.name = 'a')
where exists
 (select new from b where a.name = b.new and b.name = 'a')