Write a postgre SQL statement to add a foreign key on job_id column of job_history table referencing to the primary key job_id of jobs table
- Postgre SQL
- 2021-09-29
- mhanasmh00489829403
الأجوبة
ALTER TABLE job_history
ADD FOREIGN KEY(job_id)
REFERENCES jobs(job_id);
Output:
Now see the structure of the table job_history after being altered.
postgres=# \d job_history
Column | Type | Modifiers
---------------+-----------------------+-----------
employee_id | numeric(6,0) |
start_date | date |
end_date | date |
job_id | character varying(10) |
department_id | numeric(4,0) |
Foreign-key constraints:
"job_history_job_id_fkey" FOREIGN KEY (job_id) REFERENCES jobs(job_id)أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
معلومات ذات صلة