[go: up one dir, main page]

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

Database SQL

Oracle Database is a powerful relational database management system (RDBMS) developed by Oracle Corporation, designed for storing, managing, and securing large amounts of structured data. Key features include support for SQL, high availability, security, scalability, and a multitenant architecture. It utilizes various database objects such as tables, views, indexes, and procedures to facilitate data organization and manipulation.

Uploaded by

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

Database SQL

Oracle Database is a powerful relational database management system (RDBMS) developed by Oracle Corporation, designed for storing, managing, and securing large amounts of structured data. Key features include support for SQL, high availability, security, scalability, and a multitenant architecture. It utilizes various database objects such as tables, views, indexes, and procedures to facilitate data organization and manipulation.

Uploaded by

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

🔍 What Is Oracle Database?

Oracle Database is a relational database management system (RDBMS) developed by


Oracle Corporation. It is one of the most widely used and powerful enterprise
databases in the world.

📘 In Simple Terms:

Oracle Database is a system that helps you store, manage, retrieve, and secure data
— typically used by businesses to handle large amounts of information in a
structured and reliable way.

🧱 Key Features of Oracle Database


Feature Description
Relational Database Stores data in tables (rows and columns) with relationships
between them.
SQL Support Uses SQL (Structured Query Language) to interact with the data.
PL/SQL Oracle’s proprietary language for writing complex
procedures, functions, and scripts.
High Availability Supports failover, backup, replication, and clustering (e.g.,
RAC) to keep systems running 24/7.
Security Advanced features like encryption, user roles, fine-grained
access control.
Scalability Designed to handle very large datasets and thousands of users
simultaneously.
Multitenant From Oracle 12c onward, supports multi-tenant architecture
(multiple databases inside one container).

💡 Common Uses of Oracle Database

Banking systems

ERP applications (like Oracle E-Business Suite)

Government databases

Telecommunications

Healthcare systems

Large-scale web applications

📊 Example of a Table in Oracle


CREATE TABLE employees (
id NUMBER PRIMARY KEY,
name VARCHAR2(100),
job_title VARCHAR2(50),
hire_date DATE,
salary NUMBER(10, 2)
);

You can then run a query like:

SELECT name, salary FROM employees WHERE job_title = 'Manager';

Tools to Work with Oracle


SQL*Plus – Command-line tool

SQL Developer – Free GUI tool from Oracle

Toad for Oracle – Popular third-party GUI tool

Oracle Enterprise Manager – For DB monitoring & administration

what is the difference between data and information


ChatGPT said:

Great question! Understanding the difference between data and information is


fundamental in IT, databases, and analytics.

📊 Difference Between Data and Information


Aspect Data Information
Definition Raw, unprocessed facts or figures Processed, organized, or
interpreted data
Meaning Has no meaning by itself Has meaning and context
Form Numbers, symbols, text, images, etc. Summaries, patterns,
insights, decisions
Example 92, 75, 88, Alice, 2025-09-03 “Alice scored an average of
85 in her tests.”
Purpose Collected and stored Used for decision-making
or understanding
Context No context Comes with context

🔍 What is a Schema in Oracle Database?

In Oracle Database, a schema is essentially a collection of database objects that


belong to a specific user account. These objects include:

Tables

Views

Indexes

Sequences

Stored procedures

Synonyms

Triggers

and more...

🧠 Think of it like this:

A schema is a container or namespace for all the database objects that a particular
user owns.

🔑 Key Points:
Concept Description
Owner = Schema Name In Oracle, the user who owns the objects is the schema
name.
One-to-One Every user has exactly one schema with the same name as their
username.
Objects Are Owned When you create a table as user HR, it goes into the HR schema.
Access Control Other users can access your schema's objects only if you
grant them permission.

📦 Example:

Let’s say you have a user called HR:

CREATE USER HR IDENTIFIED BY password;

Then, if HR creates a table:

CREATE TABLE employees (


id NUMBER,
name VARCHAR2(100)
);

This table is stored in the HR schema and can be referenced by:

SELECT * FROM HR.employees;

🧭 How It Differs from a Database (in Oracle)

Unlike systems like MySQL or SQL Server, in Oracle:

The database is the whole container (data files, users, memory, etc.).

A schema is just the set of objects owned by a specific user within that database.

Viewing Your Schema’s Objects

You can use Oracle views like:

SELECT * FROM user_tables; -- Your own tables


SELECT * FROM all_tables; -- Tables you can access (yours + granted)
SELECT * FROM dba_tables; -- All tables (requires DBA privileges)

✅ Summary
Term Description
User A database account
Schema All objects owned by that user
Database The entire Oracle DB system

📦 What Are Database Objects?

Database objects are the building blocks of a schema in Oracle. They represent the
various structures used to store, organize, manipulate, and secure data.

🔑 Main Database Objects in Oracle (Explained in Detail)


1. 🧱 Tables

Purpose: Store data in rows and columns.

Example:
CREATE TABLE employees (
emp_id NUMBER PRIMARY KEY,
name VARCHAR2(100),
salary NUMBER(10, 2),
hire_date DATE
);

Details:

Each row = one record.

Columns = fields like name, salary, etc.

Supports constraints: PRIMARY KEY, NOT NULL, UNIQUE, etc.

2. 👓 Views

Purpose: Provide a virtual table based on one or more tables.

Example:

CREATE VIEW high_salary_employees AS


SELECT name, salary FROM employees WHERE salary > 10000;

Details:

Doesn’t store data itself.

Used to simplify complex queries or restrict access.

Can be read-only or updatable in some cases.

3. 🧮 Indexes

Purpose: Improve the speed of data retrieval.

Example:

CREATE INDEX idx_name ON employees(name);

Details:

Works like a book index.

Can be on one or more columns.

Oracle uses them automatically during queries.

4. 🔢 Sequences

Purpose: Generate unique numbers, usually for primary keys.

Example:

CREATE SEQUENCE emp_seq START WITH 1 INCREMENT BY 1;


Usage:

INSERT INTO employees (emp_id, name) VALUES (emp_seq.NEXTVAL, 'Alice');

5. 📜 Synonyms

Purpose: Provide alternate names for database objects.

Example:

CREATE SYNONYM emp FOR hr.employees;

Details:

Simplifies access to remote or complex object names.

Can be public (visible to all) or private (schema-specific).

6. ⚙️ Procedures

Purpose: Store and execute reusable PL/SQL blocks.

Example:

CREATE PROCEDURE give_raise (p_id NUMBER, p_amount NUMBER) AS


BEGIN
UPDATE employees SET salary = salary + p_amount WHERE emp_id = p_id;
END;

Details:

Can accept parameters.

Used to encapsulate business logic.

7. 🧠 Functions

Purpose: Like procedures, but must return a value.

Example:

CREATE FUNCTION get_salary (p_id NUMBER) RETURN NUMBER AS


v_salary NUMBER;
BEGIN
SELECT salary INTO v_salary FROM employees WHERE emp_id = p_id;
RETURN v_salary;
END;

8. 🔁 Triggers

Purpose: Automatically execute code in response to DML events.

Example:

CREATE TRIGGER before_insert_emp


BEFORE INSERT ON employees
FOR EACH ROW
BEGIN
:NEW.hire_date := SYSDATE;
END;

Details:

Can fire BEFORE or AFTER INSERT, UPDATE, DELETE.

Can be row-level or statement-level.

9. 🔐 Constraints

Purpose: Enforce rules on data in tables.

Types:

PRIMARY KEY – Unique + Not Null

FOREIGN KEY – Reference to another table

UNIQUE – No duplicate values

CHECK – Custom condition

NOT NULL – Prevents null values

Example:

CREATE TABLE employees (


emp_id NUMBER PRIMARY KEY,
salary NUMBER CHECK (salary > 0)
);

10. 📚 Packages

Purpose: Group related procedures, functions, and variables.

Example:

CREATE PACKAGE emp_pkg AS


PROCEDURE give_bonus(p_id NUMBER);
FUNCTION get_tax(p_id NUMBER) RETURN NUMBER;
END;

Details:

Improves organization and performance.

Has a specification and body.

11. Materialized Views

Purpose: Store the results of a query physically (unlike views).

Example:
CREATE MATERIALIZED VIEW emp_summary AS
SELECT dept_id, AVG(salary) FROM employees GROUP BY dept_id;

Details:

Used in data warehousing.

Can be refreshed manually or on a schedule.

12. 📋 Types (User-Defined Data Types)

Purpose: Define custom data structures.

Example:

CREATE TYPE emp_type AS OBJECT (


emp_id NUMBER,
name VARCHAR2(100)
);

Details:

Useful in object-relational features.

Can be used in tables or PL/SQL.

✅ Summary Table
Object Type Purpose / Use
Table Store data in rows and columns
View Virtual table (query result)
Index Speed up data access
Sequence Auto-generate unique values
Synonym Shortcut name for an object
Procedure Stored logic (no return)
Function Stored logic (returns a value)
Trigger Auto-executed logic on data changes
Constraint Data validation rules
Package Group of procedures/functions
Materialized View Stored query result for performance
Type User-defined structure

You might also like