In Oracle, the terms Schema, Database, and User are related but have distinct meanings. Here’s how they differ:
1. What is an Oracle Schema?
- A schema is a collection of database objects (tables, views, indexes, procedures, etc.) owned by a specific user.
- It is automatically created when a user is created.
- Example: If a user John owns tables like employees and departments, they belong to John’s schema.
- Schema = User’s objects (but not the user itself).
2. What is an Oracle User?
- A user is an account that can connect to the database and own schema objects.
- Users can exist without owning a schema (i.e., they don’t need to own tables).
- Users are primarily for authentication and authorization in Oracle.
Example:
CREATE USER john IDENTIFIED BY password;
ALTER USER john QUOTA UNLIMITED ON users;
A user can be granted privileges to access another user's schema objects.
3. What is an Oracle Database?
A database is a collection of schemas, datafiles, control files, and redo logs.
It provides storage and management for multiple schemas.
Contains metadata, users, and instance configurations.
Example: An Oracle database can have multiple schemas, like HR, Sales, and Finance.
Key Differences
Feature
Schema
User
Database
Definition
Collection of objects owned by a user
Account that can access the database
Entire Oracle system managing schemas and data
Contains
Tables, views, indexes, etc.
Credentials, roles, privileges
Multiple schemas, data, system files
Created When
A user is created
Explicitly using CREATE USER
CREATE DATABASE command
Example
HR.employees (HR schema)
User HR owns schema objects
Oracle DB with multiple schemas
Conclusion
- User ≠ Schema, but a user owns a schema.
- A database contains multiple schemas, and each schema belongs to a user.
- Understanding these differences helps in managing access, security, and data organization in Oracle.