Question
Using Oracle SQL Developer Create a simple HR database based on below model. You should have 8 tables in total in your Database. The table
Using Oracle SQL Developer
Create a simple HR database based on below model. You should have 8 tables in total in your Database. The table columns are given on the left side and their respective data type is given on the right.
This is the code I currently have:
CREATE TABLE regions ( region_id NUMBER, region_name VARCHAR2(25), PRIMARY KEY ( region_id ) ); CREATE TABLE departments ( department_id NUMBER, department_name VARCHAR2(30), manager_id NUMBER, location_id NUMBER, PRIMARY KEY ( department ), FOREIGN KEY ( location_id ) REFERENCES locations ( location_id ) ); CREATE TABLE job_history ( employee_id NUMBER, start_date DATE, end_date DATE, job_id VARCHAR2(10), department_id NUMBER, PRIMARY KEY ( employee_id ), FOREIGN KEY ( job_id ) REFERENCES jobs ( job_id ) ); CREATE TABLE countries ( country_id CHAR(2), country_name VARCHAR2(40), region_id NUMBER, PRIMARY KEY ( region_id ), FOREIGN KEY ( region_id )REFERENCES regions ( region_id ) ); CREATE TABLE employees ( employee_id NUMBER, first_name VARCHAR2(20), last_name VARCHAR2(25), email VARCHAR2(25), phone_number VARCHAR2(20), hire_date DATE, job_id NUMBER, salary NUMBER, commission_pct NUMBER, manager_id NUMBER, department_id NUMBER, FOREIGN KEY ( employee_id ) REFERENCES job_history ( employee_id ), FOREIGN KEY ( job_id ) REFERENCES jobs ( job_id ), FOREIGN KEY ( department_id ) REFERENCES departments ( department_id ) ); CREATE TABLE locations ( location_id NUMBER, street_address VARCHAR(25), postal_code VARCHAR(12), city VARCHAR2(30), state_province VARCHAR2(12), country_id CHAR(2), PRIMARY KEY ( location_id ), FOREIGN KEY ( country_id ) REFERENCES countries ( country_id ) ); CREATE TABLE jobs ( job_id VARCHAR2(10), job_title VARCHAR2(35), min_salary NUMBER, max_salary NUMBER, PRIMARY KEY ( job_id ) ); CREATE TABLE job_grades ( grade_level VARCHAR2(2), lowest_sal NUMBER, higest_sal NUMBER );
and I get this error:
Error starting at line : 30 in command - CREATE TABLE employees ( employee_id NUMBER, first_name VARCHAR2(20), last_name VARCHAR2(25), email VARCHAR2(25), phone_number VARCHAR2(20), hire_date DATE, job_id NUMBER, salary NUMBER, commission_pct NUMBER, manager_id NUMBER, department_id NUMBER, FOREIGN KEY ( employee_id ) REFERENCES job_history ( employee_id ), FOREIGN KEY ( job_id ) REFERENCES jobs ( job_id ), FOREIGN KEY ( department_id ) REFERENCES departments ( department_id ) ) Error report - ORA-02267: column type incompatible with referenced column type 02267. 00000 - "column type incompatible with referenced column type" *Cause: The data type or collation of the referencing column was incompatible with the data type or collation of the referenced column. *Action: Select a compatible data type for the referencing column. Also, the collation of a character column in a foreign key must match the collation of the corresponding column in the primary key.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started