Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 . Create a schema employee 2 . Write a SQL statement to create a simple table countries including columns country _ id , country

1. Create a schema employee
2. Write a SQL statement to create a simple table countries including
columns country_id,country_name and region_id.
3. Write a SQL statement to create a table named jobs including columns
job_id, job_title, min_salary, max_salary and check whether the
max_salary amount exceeding the upper limit 25000.
4. 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.
Here is the structure of the table jobs;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| JOB_ID | varchar(10)| NO | PRI |||
| JOB_TITLE | varchar(35)| NO || NULL ||
| MIN_SALARY | decimal(6,0)| YES || NULL ||
| MAX_SALARY | decimal(6,0)| YES || NULL ||
+------------+--------------+------+-----+---------+-------+
5. Write a SQL statement to create a table departments
| Field | Type | Null | Key | Default |
Extra |
+-----------------+--------------+------+-----+---------+-----
--+
| DEPARTMENT_ID | decimal(4,0)| NO | PRI |0|
|
| DEPARTMENT_NAME | varchar(30)| NO || NULL |
|
| MANAGER_ID | decimal(6,0)| NO | PRI |0|
|
| LOCATION_ID | decimal(4,0)| YES || NULL |
|
+-----------------+--------------+------+-----+---------+-----
--+
6. 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.
7. Write a SQL statement to change the email column of employees table
with 'not available' for all employees.
8. Write a SQL statement to change the email and commission column of
employees table with 'not available' and 0.10 for all employees.
9. Write a SQL statement to change the email column of employees table
with 'not available' for those employees whose department_id is 80 and
gets a commission_pct is less than .20.
10. Write a SQL statement to change the email and commission_pct
column of employees table with 'not available' and 0.10 for those
employees whose department_id is 110.
11. Write a SQL statement to change salary of employee to 8000
whose ID is 105, if the existing salary is less than 5000.
12. Write a SQL statement to add a primary key for the columns
location_id in the locations table.
Here is the sample table employees.
Sample table: locations
Here is the structure of the table locations.
mysql> SHOW COLUMNS FROM locations;
+----------------+--------------+------+-----+---------+------
-+
| Field | Type | Null | Key | Default | Extra
|
+----------------+--------------+------+-----+---------+------
-+
| LOCATION_ID | decimal(4,0)| YES || NULL |
|
| STREET_ADDRESS | varchar(40)| YES || NULL |
|
| POSTAL_CODE | varchar(12)| YES || NULL |
|
| CITY | varchar(30)| YES || NULL |
|
| STATE_PROVINCE | varchar(25)| YES || NULL |
|
| COUNTRY_ID | varchar(2)| YES || NULL |
|
+----------------+--------------+------+-----+---------+------
-+
13. Write a SQL statement to rename the table countries to
country_new.
14. Write a SQL statement to add a column region_id to the table
locations.
15. Write a SQL statement to add a columns ID as the first column of
the table locations.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions