Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Creating table - primary key and foreign key issue

user490795Feb 10 2017 — edited Feb 10 2017

Hello Firends

I have tables employees and job_history. Employee_id is the primary key in the employee table. In the job_history table, I have employee_id and start_date both as primary key.

How can refer this employee_if (from job_history table) with employee table?

This is query I wrote.

create table job_history (

employee_id number(5) constraint emp_pk primary key

                  constraint emp\_fk references scott.employee(employee\_id),

start_date date default sysdate constraint sd_pk primary key ,

end_date date default sysdate,

job_id number (5) constraint jobs_fk references scott.jobs(job_id),

department_id number(5) constraint dep_fk references scott.department(department_id)

);

pastedImage_0.png

Your help is highly appreciated.

This post has been answered by AndrewSayer on Feb 10 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 10 2017
Added on Feb 10 2017
3 comments
287 views