![]() Previous: Write a SQL statement to create a table job_history including columns employee_id, start_date, end_date, job_id and department_id and make sure that, the employee_id column does not contain any duplicate value at the time of insertion and the foreign key column job_id contain only those values which are exists in the jobs table. Have another way to solve this solution? Contribute your code (and comments) through Disqus. | DEPARTMENT_ID | decimal(4,0) | YES | MUL | NULL | | | MANAGER_ID | decimal(6,0) | YES | | NULL | | | COMMISSION_PCT | decimal(2,2) | YES | | NULL | | | SALARY | decimal(8,2) | YES | | NULL | | | PHONE_NUMBER | varchar(20) | YES | | NULL | | | LAST_NAME | varchar(25) | NO | | NULL | | | FIRST_NAME | varchar(20) | YES | | NULL | | | EMPLOYEE_ID | decimal(6,0) | NO | PRI | NULL | | Here is the structure of the table: mysql> DESC employees Let execute the above code in MySQL 5.6 command prompt REFERENCES departments(DEPARTMENT_ID,MANAGER_ID) Sample Solution: CREATE TABLE IF NOT EXISTS employees (ĮMPLOYEE_ID decimal(6,0) NOT NULL PRIMARY KEY,ĬOMMISSION_PCT decimal(2,2) DEFAULT NULL, | LOCATION_ID | decimal(4,0) | YES | | NULL | | ![]() | MANAGER_ID | decimal(6,0) | NO | PRI | 0 | | | DEPARTMENT_NAME | varchar(30) | NO | | NULL | | | DEPARTMENT_ID | decimal(4,0) | NO | PRI | 0 | | | Field | Type | Null | Key | Default | Extra | Write a SQL statement to create a table employees including columns employee_id, first_name, last_name, email, phone_number hire_date, job_id, salary, commission, manager_id and department_id and make sure that, the employee_id column does not contain any duplicate value at the time of insertion and the foreign key columns combined by department_id and manager_id columns contain only those unique combination values, which combinations are exists in the departments table.Īssume the structure of departments table below. MySQL Create Tables: Exercise-15 with Solutionġ5.
0 Comments
Leave a Reply. |