create table supplier(
.
.
.
city varchar2(16) references city(city_name)
);
What’s the correct query?
alter table suppliers modify city varchar2(16);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The problem you have is that you have created a foreign key without giving a name to the constraint. This is bad practice, because it makes it harder to manipulate the constraint, as pretty much all Oracle DDL requires the object name.
When we don’t explicitly name the constraints Oracle generates a default one. These are all horribly similar and there is no way of telling what the constraint actually does. For instance, if you had three foreign key constraints on SUPPLIER you would need to join with the USER_CONS_COLUMNS view in order to see which constraint actually enforce a rule on the CITY column.
So, for future reference,
Anyway, right now you need to find the defaulted name of the foreign key constraint, so you can drop it. We’ll assume you were equally sloppy with the CITY table, so first we need to find its primary key (you can skip this stage if you actually know the name).
Next, feed that name into this query:
Finally, drop the constraint: