0% found this document useful (0 votes)
5 views2 pages

Oracle SQL Practical File

This practical file covers essential SQL concepts and queries for Oracle database management, including Views, Sequences, Indexes, Triggers, and Cursors. It provides syntax and examples for each concept to aid in understanding and application. The document serves as a comprehensive guide for executing SQL commands and managing database operations.

Uploaded by

t0450766
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Oracle SQL Practical File

This practical file covers essential SQL concepts and queries for Oracle database management, including Views, Sequences, Indexes, Triggers, and Cursors. It provides syntax and examples for each concept to aid in understanding and application. The document serves as a comprehensive guide for executing SQL commands and managing database operations.

Uploaded by

t0450766
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Oracle SQL Practical File

This practical file contains important SQL concepts and queries required for database management
using Oracle. It includes Views, Sequences, Indexes, DDL & DML commands, Operators, Clauses,
Functions, and essential SQL programs.

1. Views

A view is a virtual table based on the result of a SQL query. It does not store data physically but
provides a way to represent data from one or more tables.
Syntax:
CREATE VIEW view_name AS
SELECT column1, column2 FROM table_name WHERE condition;
Example:
CREATE VIEW EmployeeView AS
SELECT name, salary FROM Employees WHERE salary > 50000;

2. Sequences

A sequence is a database object used to generate unique numerical values, commonly used for
primary keys.
Syntax:
CREATE SEQUENCE sequence_name
START WITH start_value
INCREMENT BY increment_value;
Example:
CREATE SEQUENCE Emp_Seq START WITH 1 INCREMENT BY 1;

3. Indexes

An index is used to speed up data retrieval operations in a database.


Syntax:
CREATE INDEX index_name ON table_name (column_name);
Example:
CREATE INDEX idx_emp_name ON Employees (name);
4. Triggers

A trigger is a stored procedure that executes automatically when a specified event occurs.
Syntax:
CREATE TRIGGER trigger_name
BEFORE|AFTER INSERT|UPDATE|DELETE ON table_name FOR EACH ROW BEGIN
-- SQL statements
END;
Example:
CREATE TRIGGER BeforeInsertEmployee
BEFORE INSERT ON Employees
FOR EACH ROW BEGIN
INSERT INTO Logs (action, timestamp) VALUES ('Insert', SYSDATE);
END;

5. Cursors

A cursor is a pointer used to retrieve data row-by-row from a result set.


Syntax:
DECLARE cursor_name CURSOR FOR SELECT statement;
OPEN cursor_name;
FETCH cursor_name INTO variable;
CLOSE cursor_name;
Example:
DECLARE EmpCursor CURSOR FOR SELECT name, salary FROM Employees;
OPEN EmpCursor;
FETCH EmpCursor INTO empName, empSalary;
CLOSE EmpCursor;

You might also like