Oracle Database SQL Certified Associate
1 Introduction to SQL
1-1 Overview of SQL
1-2 History of SQL
1-3 SQL Standards
2 SQL Data Types
2-1 Numeric Data Types
2-2 Character Data Types
2-3 Date and Time Data Types
2-4 Large Object (LOB) Data Types
2-5 Miscellaneous Data Types
3 Creating and Managing Tables
3-1 Creating Tables
3-2 Modifying Tables
3-3 Dropping Tables
3-4 Table Constraints
3-5 Temporary Tables
4 Data Manipulation Language (DML)
4-1 Inserting Data
4-2 Updating Data
4-3 Deleting Data
4-4 Selecting Data
4-5 Using Subqueries
5 Data Control Language (DCL)
5-1 Granting Privileges
5-2 Revoking Privileges
6 Data Definition Language (DDL)
6-1 Creating Tables
6-2 Altering Tables
6-3 Dropping Tables
6-4 Creating Indexes
6-5 Dropping Indexes
6-6 Creating Views
6-7 Dropping Views
7 SQL Functions
7-1 Single-Row Functions
7-2 Aggregate Functions
7-3 Group Functions
7-4 Analytical Functions
8 Joins and Subqueries
8-1 Inner Joins
8-2 Outer Joins
8-3 Self-Joins
8-4 Cross Joins
8-5 Subqueries
9 Set Operators
9-1 UNION
9-2 UNION ALL
9-3 INTERSECT
9-4 MINUS
10 Grouping and Aggregation
10-1 GROUP BY Clause
10-2 HAVING Clause
10-3 ROLLUP and CUBE
10-4 GROUPING SETS
11 Transactions and Concurrency
11-1 Transaction Control Statements
11-2 Locking and Concurrency
11-3 Isolation Levels
12 Oracle SQL Developer
12-1 Overview of Oracle SQL Developer
12-2 Using SQL Worksheet
12-3 Managing Connections
12-4 Running Scripts
13 Advanced SQL Topics
13-1 Recursive Queries
13-2 Model Clause
13-3 PIVOT and UNPIVOT
13-4 Flashback Query
14 Performance Tuning
14-1 Query Optimization
14-2 Indexing Strategies
14-3 Analyzing Query Performance
15 Security and Auditing
15-1 User Management
15-2 Role Management
15-3 Auditing SQL Statements
16 Backup and Recovery
16-1 Backup Strategies
16-2 Recovery Strategies
16-3 Using RMAN
17 Oracle Database Architecture
17-1 Overview of Oracle Database Architecture
17-2 Memory Structures
17-3 Process Structures
17-4 Storage Structures
18 PLSQL Basics
18-1 Introduction to PLSQL
18-2 PLSQL Block Structure
18-3 Variables and Data Types
18-4 Control Structures
18-5 Exception Handling
19 Oracle SQL Certification Exam Preparation
19-1 Exam Objectives
19-2 Sample Questions
19-3 Practice Tests
19-4 Exam Tips
Storage Structures in Oracle Database

Storage Structures in Oracle Database

Key Concepts

Storage Structures in Oracle Database are fundamental components that define how data is stored, managed, and accessed. Understanding these structures is crucial for optimizing database performance and ensuring data integrity. The key concepts include:

1. Datafiles

Datafiles are physical files on disk that store the actual data of the database. Each datafile belongs to a specific tablespace and contains the data for one or more database objects.

Example:

Creating a datafile for a tablespace:

ALTER TABLESPACE users ADD DATAFILE '/u01/app/oracle/oradata/ORCL/users01.dbf' SIZE 100M;

2. Tablespaces

Tablespaces are logical storage units that group related datafiles together. Each tablespace can contain one or more datafiles and is used to organize database objects.

Example:

Creating a new tablespace:

CREATE TABLESPACE sales DATAFILE '/u01/app/oracle/oradata/ORCL/sales01.dbf' SIZE 200M;

3. Segments

Segments are portions of a tablespace that store the data for a specific database object, such as a table or index. Each segment is divided into one or more extents.

Example:

Creating a table with a segment in a specific tablespace:

CREATE TABLE employees (id NUMBER, name VARCHAR2(50)) TABLESPACE users;

4. Extents

Extents are contiguous blocks of storage allocated to a segment. When a segment requires more space, it is allocated in the form of extents.

Example:

Setting the initial and next extent sizes for a tablespace:

CREATE TABLESPACE sales DATAFILE '/u01/app/oracle/oradata/ORCL/sales01.dbf' SIZE 200M EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;

5. Blocks

Blocks are the smallest units of storage in Oracle Database. Each block corresponds to a specific number of bytes on disk and is the level at which data is read or written.

Example:

Setting the block size for a tablespace:

CREATE TABLESPACE sales DATAFILE '/u01/app/oracle/oradata/ORCL/sales01.dbf' SIZE 200M BLOCKSIZE 8K;

6. Control Files

Control files are critical for the operation of the database. They contain metadata about the database, including the names and locations of datafiles and redo log files.

Example:

Creating a control file:

ALTER DATABASE BACKUP CONTROLFILE TO '/u01/app/oracle/oradata/ORCL/control01.ctl';

7. Redo Log Files

Redo log files record all changes made to the database. They are essential for recovery operations, as they allow the database to replay changes and restore data to a consistent state.

Example:

Adding a redo log file to a group:

ALTER DATABASE ADD LOGFILE GROUP 3 ('/u01/app/oracle/oradata/ORCL/redo03a.log', '/u01/app/oracle/oradata/ORCL/redo03b.log') SIZE 50M;

8. Archived Redo Log Files

Archived redo log files are copies of redo log files that have been filled and archived. They are used for point-in-time recovery and maintaining data integrity.

Example:

Archiving redo log files:

ALTER SYSTEM ARCHIVE LOG ALL;

9. Temporary Tablespaces

Temporary tablespaces are used for temporary storage, such as sorting operations and hash joins. They are automatically created and managed by Oracle.

Example:

Creating a temporary tablespace:

CREATE TEMPORARY TABLESPACE temp TEMPFILE '/u01/app/oracle/oradata/ORCL/temp01.dbf' SIZE 100M;

10. Undo Tablespaces

Undo tablespaces store undo data, which is used to roll back transactions and provide read consistency. They are essential for maintaining data integrity.

Example:

Creating an undo tablespace:

CREATE UNDO TABLESPACE undotbs1 DATAFILE '/u01/app/oracle/oradata/ORCL/undotbs01.dbf' SIZE 200M;

11. System Tablespace

The system tablespace is the default tablespace used by Oracle to store system-related data, such as metadata and internal tables.

Example:

Adding a datafile to the system tablespace:

ALTER TABLESPACE SYSTEM ADD DATAFILE '/u01/app/oracle/oradata/ORCL/system02.dbf' SIZE 500M;

12. Default Tablespace

The default tablespace is the tablespace to which new database objects are automatically assigned if no tablespace is specified.

Example:

Setting the default tablespace for a user:

ALTER USER hr DEFAULT TABLESPACE users;

13. Temporary Tablespace Group

Temporary tablespace groups allow multiple temporary tablespaces to be grouped together, providing flexibility in managing temporary storage.

Example:

Creating a temporary tablespace group:

ALTER DATABASE TEMPFILE '/u01/app/oracle/oradata/ORCL/temp01.dbf' ADD TO GROUP temp_group;

14. Undo Tablespace Group

Undo tablespace groups allow multiple undo tablespaces to be grouped together, providing flexibility in managing undo storage.

Example:

Creating an undo tablespace group:

ALTER DATABASE DATAFILE '/u01/app/oracle/oradata/ORCL/undotbs01.dbf' ADD TO GROUP undo_group;

15. Automatic Storage Management (ASM)

ASM is a storage management feature that provides automatic storage management for Oracle databases. It simplifies storage management and improves performance.

Example:

Creating a disk group using ASM:

CREATE DISKGROUP data_dg NORMAL REDUNDANCY DISK '/dev/oracleasm/disks/ORCL_DATA01', '/dev/oracleasm/disks/ORCL_DATA02';

16. Fast Recovery Area (FRA)

The Fast Recovery Area is a disk-based storage area used for storing backup files, archived redo logs, and other recovery-related files. It simplifies the management of recovery files.

Example:

Configuring the Fast Recovery Area:

ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 10G; ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '/u01/fra';

17. Temporary Files

Temporary files are used by temporary tablespaces to store temporary data, such as sort operations and hash joins. They are automatically created and managed by Oracle.

Example:

Creating a temporary file:

ALTER TABLESPACE temp ADD TEMPFILE '/u01/app/oracle/oradata/ORCL/temp02.dbf' SIZE 100M;