đŸ§Ē Lab 1.2: Retrieving Data with the SELECT Statement

đŸ§Ē Lab 1.2: Retrieving Data with the SELECT Statement in Oracle SQL

đŸŽ¯ Objective:

This lab introduces the SELECT statement, the most fundamental and commonly used SQL command. Students will learn how to retrieve data from a table, display specific columns, and apply aliases for better readability.

🧰 Requirements:

  • Oracle SQL*Plus or SQL Developer
  • Valid Oracle Database connection
  • Access to tables like EMPLOYEES, DEPARTMENTS, or similar

🔍 Understanding the SELECT Statement

The SELECT statement is used to retrieve data from a database table. You can retrieve all data or just specific columns or rows.

🔹 Basic Syntax:

SELECT column1, column2, ...
FROM table_name;

📘 Section A: Retrieve All Columns

✅ Example 1: Display Full Employee Table

SELECT * FROM employees;

This shows every column and row from the employees table.

📘 Section B: Retrieve Specific Columns

✅ Example 2: Select First Name and Salary

SELECT first_name, salary
FROM employees;

📘 Section C: Using Column Aliases

✅ Example 3: Rename Columns for Readability

SELECT first_name AS "First Name", salary AS "Monthly Salary"
FROM employees;

📘 Section D: Display Unique Values

✅ Example 4: Get Unique Job IDs

SELECT DISTINCT job_id
FROM employees;

📘 Section E: Concatenating Columns

✅ Example 5: Combine First and Last Names

SELECT first_name || ' ' || last_name AS "Full Name"
FROM employees;

📝 Lab Exercise Tasks

  1. Write a query to show all records from the departments table.
  2. Show only department_name and manager_id columns.
  3. Display a list of distinct job IDs from the employees table.
  4. Use aliases to rename first_name as “First” and last_name as “Last”.
  5. Concatenate first_name and last_name into a single “Full Name” column.
  6. Try using an incorrect column name (e.g., sallary) and observe the error message.

✅ Learning Outcomes

  • Retrieve full or partial records from a table using SELECT.
  • Understand how to use aliases for readability.
  • Apply the DISTINCT keyword and string concatenation.
  • Interpret basic SQL error messages and correct mistakes.

🧠 Challenge Activity (Optional)

Write a query that shows the full name and salary of employees who work in department 90:

SELECT first_name || ' ' || last_name AS "Full Name", salary
FROM employees
WHERE department_id = 90;
oracle select statement lab, sql select tutorial, beginner sql lab, oracle sql lab tutorial, retrieve data using sql, select query examples, how to use select in sqlplus, oracle select from table, select with alias, distinct values sql, sql concatenation

āĻ•োāύ āĻŽāύ্āϤāĻŦ্āϝ āύেāχ:

āĻāĻ•āϟি āĻŽāύ্āϤāĻŦ্āϝ āĻĒোāϏ্āϟ āĻ•āϰুāύ