Learn how Oracle Database is put together: instances, memory, files, tablespaces, schemas and pluggable databases, plus editions and a quick way to start a practice database.
Oracle Database is a commercial relational database management system from Oracle Corporation. It stores data in tables, is queried with SQL, runs procedural code in PL/SQL, and is built around strong transactional guarantees, read consistency without read locks, and tooling for very large, highly available systems. The company was founded in 1977 and shipped its first commercial SQL database in 1979.
This overview covers the vocabulary and architecture you need before any Oracle tutorial makes sense, plus the quickest way to get a database to practise on.
Releases and editions
Oracle labels some releases as long-term support releases and others as short-lived innovation releases. Two matter in practice:
Oracle Database 19c, the previous long-term release, still widely deployed and still supported.
Oracle AI Database 26ai, the current long-term release. It is the renamed continuation of 23ai; a 23ai database becomes 26ai by applying a release update rather than a full upgrade.
Check Oracle's lifetime support policy for the exact support dates of the release you plan to use.
Edition
Cost
Notes
Free
No licence fee
Limited to 2 CPUs, 2 GB of RAM and 12 GB of user data. Good for learning and small apps
Standard Edition 2 (SE2)
Licensed
Core database; no partitioning, parallel query, or Data Guard
Enterprise Edition (EE)
Licensed
Full feature set, with extra-cost options such as Partitioning, RAC and Advanced Security
Cloud services
Subscription
Autonomous Database, Base Database Service and Exadata Database Service run the same engine as managed services
The older Express Edition (XE) has been succeeded by the Free edition.
Instance and database are different things
This distinction explains most Oracle error messages.
The database is the set of files on disk.
The instance is the memory and background processes that open those files.
You can have files without a running instance (the database is shut down), and with Real Application Clusters (RAC) several instances on different servers open one database at once.
Your long query needed undo that was already overwritten. How Oracle read consistency uses undo, how to read V$UNDOSTAT, and why committing inside a loop causes it.
SGA (System Global Area) is shared by all sessions. Its main parts are the buffer cache (copies of data blocks), the shared pool (parsed SQL and dictionary data) and the redo log buffer.
PGA (Program Global Area) is private to each server process and is used for sorts, hash joins and session variables.
Background processes
Process
Job
DBWn (database writer)
Writes changed blocks from the buffer cache to data files
LGWR (log writer)
Writes redo to the online redo logs; a commit returns once its redo is on disk
CKPT (checkpoint)
Records checkpoint positions in the control file and data file headers
SMON, PMON
Instance recovery and cleanup after failed sessions
ARCn (archiver)
Copies filled redo logs to archive storage when ARCHIVELOG mode is on
A committed transaction is durable because its redo is on disk, even if the changed data blocks have not been written yet. After a crash, the instance replays redo to recover them.
Physical storage
File type
Contains
Data files
Table and index data, undo, and the data dictionary
Online redo log files
A circular record of every change, used for recovery
Control files
The database's structure: file names, checkpoint data, backup records
Archived redo logs
Copies of filled redo logs, needed for point-in-time recovery
Parameter file (spfile)
Instance settings such as memory sizes
Lose all copies of the control file or the current redo log and recovery becomes difficult, which is why Oracle lets you multiplex both across disks.
Logical storage
Oracle places a logical layer between your tables and the files.
A tablespace is a named storage container made of one or more data files. SYSTEM and SYSAUX hold Oracle's own metadata, UNDO holds undo data, TEMP holds sort spill, and USERS is the default for application data.
A segment is the storage for one object such as a table, an index or a partition.
An extent is a contiguous run of blocks allocated to a segment.
A data block is the smallest unit of I/O, 8 KB by default.
So a table is a segment, made of extents, made of blocks, stored in a tablespace, which lives in data files.
Users, schemas and the data dictionary
In Oracle a schema is the set of objects owned by a user, and the two share a name. Creating the user hr creates the schema hr. There is no separate CREATE DATABASE step per application as in MySQL; you create a user.
The data dictionary is a set of read-only views describing everything in the database. They come in three scopes:
USER_*: objects you own (USER_TABLES).
ALL_*: objects you can access (ALL_TABLES).
DBA_*: everything, for privileged users (DBA_TABLES).
V$ views such as V$SESSION and V$INSTANCE expose live instance state.
The multitenant architecture
A current Oracle database is a container database (CDB) that holds one or more pluggable databases (PDBs). The CDB owns the instance, memory and redo. Each PDB has its own users, tablespaces and service name and looks like a standalone database to applications. The older single-database (non-CDB) layout is no longer supported in current releases.
The practical consequence: you connect to a PDB's service name, not to the CDB root, and you create application users inside a PDB.
Transactions and read consistency
A transaction starts implicitly with your first DML statement and ends with COMMIT or ROLLBACK. There is no autocommit on the server; some client tools add it.
DDL statements such as CREATE TABLE commit implicitly, before and after they run.
Before a block is changed, the old values are written to undo. Queries use undo to see the data as it was when the query started, so readers never block writers and writers never block readers.
The default isolation level is READ COMMITTED. SERIALIZABLE is also available.
Try it
The fastest route to a working database is the Free edition container image:
Wait until docker logs oracle-free reports that the database is ready, then connect to the default PDB, FREEPDB1, with SQL*Plus or SQLcl:
sqlplus system@//localhost:1521/FREEPDB1
A few queries show the concepts above:
SELECT instance_name, version_full, status FROM v$instance;
SELECT name, open_mode FROM v$pdbs;
SELECT tablespace_name, contents FROM dba_tablespaces;
SELECT file_name, tablespace_name FROM dba_data_files;
Create a schema and a table to work with:
CREATEUSER demo IDENTIFIED BY "Dem0#Passw0rd"
DEFAULT TABLESPACE users QUOTA 100M ON users;
GRANTCREATE SESSION, CREATE TABLETO demo;
CREATE TABLE demo.departments (
department_id NUMBER GENERATED ALWAYS ASIDENTITYPRIMARY KEY,
department_name VARCHAR2(50) NOT NULL
);
INSERT INTO demo.departments (department_name) VALUES ('Finance');
COMMIT;
SELECT*FROM demo.departments;
Create, find, drop, disable and enable primary keys in Oracle, including composite keys, identity columns, the index behind the constraint and the ORA errors you will hit.