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

Oracle SQL Script Example

The document provides an Oracle SQL script that demonstrates creating a table for employees, inserting data, selecting, updating, and deleting records. It also includes creating an index and a view for employees with salaries greater than 5000, and concludes with a command to drop the table. This script serves as a comprehensive example of basic SQL operations in Oracle.

Uploaded by

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

Oracle SQL Script Example

The document provides an Oracle SQL script that demonstrates creating a table for employees, inserting data, selecting, updating, and deleting records. It also includes creating an index and a view for employees with salaries greater than 5000, and concludes with a command to drop the table. This script serves as a comprehensive example of basic SQL operations in Oracle.

Uploaded by

Muhammad shoaib
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Oracle SQL Script

-- Sample Oracle SQL Script

-- Create Table
CREATE TABLE employees (
employee_id NUMBER PRIMARY KEY,
name VARCHAR2(50),
department_id NUMBER,
salary NUMBER
);

-- Insert Data
INSERT INTO employees (employee_id, name, department_id, salary)
VALUES (1, 'John Doe', 10, 5000);
INSERT INTO employees (employee_id, name, department_id, salary)
VALUES (2, 'Jane Smith', 20, 6000);

-- Select Data
SELECT * FROM employees;

-- Update Data
UPDATE employees
SET salary = 7000
WHERE employee_id = 1;

-- Delete Data
DELETE FROM employees
WHERE employee_id = 2;

-- Create Index
CREATE INDEX idx_salary ON employees(salary);

-- Create View
CREATE VIEW employee_view AS
SELECT employee_id, name, salary
FROM employees
WHERE salary > 5000;

-- Drop Table
DROP TABLE employees;

You might also like