primary key is foreign key for the same table?

Answer Posted / javed a. khan

Yes this is possible and it will allow.

CREATE TABLE learn_01(book_id NUMBER,
book_name VARCHAR2(100),
book_genre VARCHAR2(100),
isbn_number NUMBER ,
author VARCHAR2(100),
ref_book_id NUMBER)


alter table learn_01 add constraint book_pk primary key (book_id)

alter table learn_01 add constraint foreign key book_rf (ref_book_id) references learn_01

ALTER TABLE learn_01 add CONSTRAINT book_fk1 FOREIGN KEY (book_id) REFERENCES learn_01(book_id);

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to work with data objects interactively?

549


Explain about the analyze command in oracle?

580


21. Using a set operator, display the client number of all clients who have ever placed an order and whose whose name does not contain the string Sm.

1617


What are ddl statements in oracle?

587


How to define a cusotmer as a supplier in ORACLE R12

1726






How to assign a table row to a record variable?

575


Where is the export dump file located?

567


Explain the difference between sql and oracle?

574


How to drop an index in oracle?

600


What is a oracle database?

602


What is a named program unit?

576


What will be the syntax to find current date and time in format "yyyy-mm-dd"?

565


Explain the use of parfile option in exp command.

519


How to count duplicated values in a column in oracle?

550


What is a package in oracle?

562