I created two tables product_type
and product
its script is as below:
create table product_type
(
product_type_id integer constraint product_type_pk primary key,
name varchar2(10) not null
);
create table product
(
product_id integer constraint product_id_pk primary key,
product_type_id integer constraint products_fk_product_types references product_type(product_type_id),
product_name varchar2(30),
description varchar2(50),
price number(5,2)
);
Now suppose I rename my first table "product_type"
to "product_types"
alter table product_type rename to product_types
then what will be its impact in second table because I used a foreign key there which references product_type
which is now product_types
What do I have to alter in my second table now?
Oracle takes care of the second table in the database: if you look at the foreign key details in SQL Developer or similar tool you will see that the constraint now references PRODUCT_TYPES. There is nothing for you to do.
However, your script is now out of date - if you want to use that script again somewhere you need to fix all references to PRODUCT_TYPE in it.
There is no effect on the main table. oracle handle all change of the refernces table.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.