1

I have a oracle query as -

occupation varchar2(50) CHECK(occupation IN ('student','govt_service','private','business')));

now i need to remove the check constraint so i use the following query-

ALTER TABLE registration drop constraint occupation;

but since i haven't defined the constraint name it says invalid constraint name. Is there any way to delete the constraint ? I guess i can alter the table and add the name of the constraint, then delete it but is there any other way ?

2 Answers 2

1

run this query:

select * from all_constraints where table_name = 'REGISTRATION';

And you'll find the constraint name.

EDIT: I also recommend you to have a table Occupations and replace the current constraint with a foreign key. (If you are already want to do this, pls apologize me ). Further, normalising, the Occupations may have IDs and and the foreign should be defined on these ids.

Sign up to request clarification or add additional context in comments.

Comments

0

Try querying USER_CONSTRAINTS table for CONSTRAINT_NAME, it must have generated a system name for the constraint you have created.

select * from USER_CONSTRAINTS
where owner='<your_schema>' and CONSTRAINT_TYPE='C';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.