đ§Ē Lab 1.1: Exploring SQL*Plus (Command-Line Interface)
đ¯ Objective: To help students become comfortable with Oracle SQL*Plus, the command-line interface used to interact with Oracle Databases by executing SQL statements directly.
đ§° Requirements:
- Oracle Database (XE or full version)
- SQL*Plus (installed with Oracle)
- Valid database user (e.g.,
HR
,SCOTT
) - Basic terminal or command line access
⚙️ Steps to Use SQL*Plus
✅ Step 1: Open SQL*Plus
- Windows: Open Command Prompt and type:
sqlplus
- Linux/macOS: Open terminal and type:
sqlplus
✅ Step 2: Connect to Oracle Database
sqlplus hr/hr@localhost:1521/xe
Replace hr/hr
with your actual username/password and xe
with your service name.
✅ Step 3: Run Basic SQL Commands
SELECT table_name FROM user_tables; DESC employees; SELECT first_name, last_name, salary FROM employees WHERE department_id = 90; SELECT first_name, salary FROM employees ORDER BY salary DESC;
✅ Step 4: Format Output (Optional)
COLUMN first_name FORMAT A15 COLUMN last_name FORMAT A15 SELECT first_name, last_name, salary FROM employees; -- Clear screen (Windows): HOST CLS
đ Step 5: Exit SQL*Plus
EXIT;
đ Lab Tasks
- Log in to SQL*Plus using your assigned credentials.
- Display all tables in your schema.
- View the structure of the
EMPLOYEES
table. - Write a query to list employees earning more than 10000.
- Sort employees by hire date in ascending order.
- Exit SQL*Plus after completing all commands.
đĄ Tips
- SQL*Plus is script-friendly and fast for repeated tasks.
- Use
SET PAGESIZE
andSET LINESIZE
for cleaner output. - Great for automation, lightweight environments, and scripting.
✅ Learning Outcomes
- Execute SQL queries directly via terminal or command prompt.
- Understand how to retrieve, format, and sort data using SQL.
- Gain comfort using Oracle's command-line tool for database access.
āĻোāύ āĻŽāύ্āϤāĻŦ্āϝ āύেāĻ:
āĻāĻāĻি āĻŽāύ্āϤāĻŦ্āϝ āĻĒোāϏ্āĻ āĻāϰুāύ