Link to home
Start Free TrialLog in
Avatar of sam2929
sam2929

asked on

ORA-02449 error

Trying to drop a table

drop table test

getting
ORA-02449 error

unique/primary keys in table refrenced by foreign keys

How can i fund all the refrences for test1 and then want to disable them.
Avatar of johnsone
johnsone
Flag of United States of America image

You cannot disable them, you have to drop them.

This query should get you the names of the constraints that are referencing the primary key.

SELECT constraint_owner, 
       constraint_name, 
       table_name 
FROM   dba_constraints 
WHERE  ( r_constraint_owner, r_constraint_name ) IN (SELECT constraint_name, 
                                                            constraint_owner 
                                                     FROM   dba_constraints 
                                                     WHERE 
              constraint_type IN ( 'P', 'U' ) 
              AND table_name = 'TEST'); 

Open in new window

Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

I would just generate the DDL and look at the constraints:
select dbms_metadata.get_ddl('TABLE','TEST') from dual;
Avatar of sam2929

ASKER

select dbms_metadata.get_ddl('TABLE','Currency_Type_Dim') from dual;

i am getting ORA-31603 and ora-06512 error and yes table do exist there
Objects in Oracle are converted to UPPER case:
select dbms_metadata.get_ddl('TABLE','CURRENCY_TYPE_DIM') from dual;
If this isn't a 'test' table, are you sure you want to drop it if there are constraints on it?

If you recreate it, you will need to rebuild all the constraints to make sure everything is back to the way it was.
Avatar of sam2929

ASKER

i don't want to drop any constraint all i want is to see all constraints related to that table in other tables
If this is just a test system you may consider dropping the constraints as well:

drop table test cascade constraints;

(be careful)

<edit>

Never mind, did not see your last post as I posted this one.
Then use the SQL posted by johnsone.  I didn't run it but it looks good to me.
Avatar of sam2929

ASKER

select dbms_metadata.get_ddl('TABLE','CURRENCY_TYPE_DIM') from dual;

i get no result but i know this table have constraints to fact tables
Avatar of sam2929

ASKER

SELECT constraint_name
                                                          --constraint_owner
                                                     FROM   dba_constraints
                                                     WHERE
              constraint_type IN ( 'P', 'U' )
              AND table_name = 'Currency_Type_Dim'

no result it dn't like   --constraint_owner
>>i get no result but i know this table have constraints to fact tables

That just generates the DDL for the TABLE.  It would have constraints to other tables not what constraints on other tables have to it.

I guess I missed the actual question here.

Use johnsone's SQL.
>>AND table_name = 'Currency_Type_Dim'

Again:  OBJECT_NAMES in UPPER case.
ASKER CERTIFIED SOLUTION
Avatar of johnsone
johnsone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial