Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

LAB 2: SQL COMMANDS

Objective: In this Lab, you will be using PyCharm to write, execute and verify the results of each steps in
the exercise. After this lab, you should have a better understanding and be able to handle basic SQL
commands. This is essential to understand the subsequent topics on SQL.

Please follow the steps below. Write SQL commands to accomplish the requirements in each step. After
each step, make sure that you check the content of the database to ensure the correctness of the results.

1. Create a SQL table called employees that stores employee_ID, last_name, first_name, salary,
dept_ID information.
2. Insert the following data into the table employees:
Employee_ID Last_name First_name Salary Dept_ID
1001 Smith John 62000 500
1002 Nguyen Jane 57600 500
1003 Tran Hang 71000 501
1004 Le Nguyen 42000 502

3. Select all the records from the employees table. Make sure the results is the same as the data in the
above table.
4. Select all the records from the employees table whose salary is less than or equal to $52,500.
5. Update the salary for “Smith John” to $62500
6. Update the dept_ID for all the records whose dept_ID equals to “501” to “5001”
7. Delete the employee whose name is “Smith John” from the table.
8. Delete all employees whose dept_ID equals to 500.
9. Delete all employees whose salary is less than $50,000 and belongs to department “5001”
10. Delete table employees.

Database Concepts/Lab 2 – RMIT University


1

You might also like