SQL Lab 2
SQL Lab 2
SQL Lab 2
1. Write a SQL statement to insert a record with your own value into the table countries against each
columns.
+--------------+---------------+------+-----+---------+-------+
+--------------+---------------+------+-----+---------+-------+
+--------------+---------------+------+-----+---------+-------+
2. Write a SQL statement to insert one row into the table countries against the column country_id and
country_name.
+--------------+---------------+------+-----+---------+-------+
+--------------+---------------+------+-----+---------+-------+
+--------------+---------------+------+-----+---------+-------+
3. Write a SQL statement to create duplicate of countries table named country_new with all structure
and data.
+--------------+---------------+------+-----+---------+-------+
+--------------+---------------+------+-----+---------+-------+
| COUNTRY_ID | varchar(2) | YES | | NULL | |
+--------------+---------------+------+-----+---------+-------+
4. Write a SQL statement to insert NULL values against region_id column for a row of countries table.
6. Write a SQL statement insert rows from country_new table to countries table.
Here is the rows for country_new table. Assume that, the countries table is empty.
+------------+--------------+-----------+
+------------+--------------+-----------+
| C0003 | UK | 1003 |
+------------+--------------+-----------+
7. Write a SQL statement to insert one row in jobs table to ensure that no duplicate value will be
entered in the job_id column.
8. Write a SQL statement to insert one row in jobs table to ensure that no duplicate value will be
entered in the job_id column.
9. Write a SQL statement to insert a record into the table countries to ensure that, a country_id and
region_id combination will be entered once in the table.
10. Write a SQL statement to insert rows into the table countries in which the value of country_id
column will be unique and auto incremented.
11. Write a SQL statement to insert records into the table countries to ensure that the country_id
column will not contain any duplicate data and this will be automatically incremented and the column
country_name will be filled up by 'N/A' if no value assigned for that column.
12. Write a SQL statement to insert rows in the job_history table in which one column job_id is
containing those values which are exists in job_id column of jobs table.
13. Write a SQL statement to insert rows into the table employees in which a set of columns
department_id and manager_id contains a unique value and that combined values must have exists into
the table departments.
14. Write a SQL statement to insert rows into the table employees in which a set of columns
department_id and job_id contains the values which must have exists into the table departments and
jobs.
Update:
1. Write a SQL statement to change the email column of employees table with 'not available' for all
employees.
------------+-------------+-------------+----------+--------------------+------------+------------+----------+----------------
+------------+---------------+
+-------------+-------------+-------------+----------+--------------------+------------+------------+----------+----------------
+------------+---------------+
+-------------+-------------+-------------+----------+--------------------+------------+------------+----------+----------------
+------------+--------------
+---------------+----------------------+------------+-------------+
| 60 | IT | 103 | 1400 |
2. Write a SQL statement to change the email and commission_pct column of employees table with 'not
available' and 0.10 for all employees.
3. 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.
4. 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
5. Write a SQL statement to change the email column of employees table with 'not available' for those
employees who belongs to the 'Accouning' department.
6. Write a SQL statement to change salary of employee to 8000 whose ID is 105, if the existing salary is
less than 5000.
8. Write a SQL statement to increase the salary of employees under the department 40, 90 and 110
according to the company rules that, salary will be increased by 25% for the department 40, 15% for
department 90 and 10% for the department 110 and the rest of the departments will remain same.
9. Write a SQL statement to increase the minimum and maximum salary of PU_CLERK by 2000 as well as
the salary for those employees by 20% and commission percent by .10.