DBMS Lab 1
DBMS Lab 1
LAB 1 Exercises:
1. Display the last name concatenated with the job ID, separated by a comma and space, and name
the column Employee and Title.
QUERY:
SELECT LAST_NAME || ', ' || JOB_ID AS "Employee and Title" FROM HR.EMPLOYEES;
2. Create a query to display all the data from the EMPLOYEES table. Separate each column by a
comma. Name the column THE_OUTPUT.
QUERY:
SELECT EMPLOYEE_ID || ', ' || FIRST_NAME || ', ' || LAST_NAME || ', ' || EMAIL || ', '
|| PHONE_NUMBER || ', ' || HIRE_DATE || ', ' || JOB_ID || ', ' || SALARY || ', ' ||
COMMISSION_PCT || ', ' || MANAGER_ID || ', ' || DEPARTMENT_ID AS "THE_OUTPUT"
FROM HR.EMPLOYEES;
3. Show the structure of the DEPARTMENTS table. Select all data from the table.
QUERY:
SELECT * FROM HR.DEPARTMENTS;
4. Show the structure of the EMPLOYEES table. Create a query to display the last name, job code,
hire date, and employee number for each employee, with employee number appearing first.
QUERY:
SELECT EMPLOYEE_ID, LAST_NAME, JOB_ID, HIRE_DATE FROM HR.EMPLOYEES;
5. Create a query to display unique job codes from the EMPLOYEES table.
QUERY:
SELECT DISTINCT JOB_ID FROM HR.EMPLOYEES;
6. There are four coding errors in this statement. Can you identify them?
SELECT employee_id, last_name sal x 12 ANNUAL SALARY FROM employees;
ERRORS:
1) No Comma between last name and sal
2) Use * for multiplication instead of x
3) AS keyword before ANNUAL SALARY to use alias
4) ANNUAL SALARY should be in inverted commas
1)
2)
3)
4)
5)