The database is organized as a container database hosting one or more pluggable databases.
XE).XEPDB1).A session is always positioned in exactly one container. Admins can move between them:
-- show where you are SHOW CON_NAME; -- switch between CDB root and the PDB ALTER SESSION SET CONTAINER = XEPDB1; ALTER SESSION SET CONTAINER = CDB$ROOT;
XE) or a PDB (XEPDB1).MTITEK, SYS, C##ADMIN.
In Oracle, user and schema are essentially the same thing.
This differs from databases like PostgreSQL, where users and schemas are independent objects.
If you create a user called MTITEK, Oracle also creates a schema called MTITEK.
MTITEK.MY_TABLE_1 means the table MY_TABLE_1 owned by the schema MTITEK.
C## (e.g., C##ADMIN), exists across all containers (CDB root and all PDBs). When granting privileges to a common user, CONTAINER=ALL applies the grant across the CDB and all PDBs.MTITEK in XEPDB1). This is the choice for application accounts.SYSDBA role).SYSDBA needed).-- common user: exists across all containers ALTER SESSION SET CONTAINER = CDB$ROOT; CREATE USER C##ADMIN IDENTIFIED BY CADMINPWD CONTAINER = ALL; GRANT DBA TO C##ADMIN CONTAINER = ALL;
-- local user: exists only in the current PDB ALTER SESSION SET CONTAINER = XEPDB1; CREATE USER MTITEK IDENTIFIED BY MTITEKPWD; GRANT CONNECT, RESOURCE TO MTITEK;
Connection roles are selected at connect time (the "Role" field in SQL Developer or the AS SYSDBA clause in sqlplus).
They allow you to connect to a database instance (even when it's idle/closed) and perform system operations.
They are not stored in the database's data dictionary; instead, they are controlled outside the database (via OS groups or password files).
Database roles are standard database-level permissions that are granted to users and live inside the database.
They are predefined, groupable sets of permissions created to manage the everyday tasks of developers, application owners, and database administrators (schema management and security).
They are listed in the DBA_ROLES view and can be granted to users.
CREATE SESSION).CONNECT, RESOURCE is enough for most application schemas.A service is a named access point to a database, used in connection strings. Oracle XE 21c exposes these services out of the box:
XE: the CDB root, used for SYSDBA/admin connections.XEPDB1: the default PDB, used for application connections.XECDB: internal CDB service.SYS$BACKGROUND and SYS$USERS: internal services for background processes and user sessions.
For a local XE installation you only need these two services: XE for admin work and XEPDB1 for application work.
XE.
A SID connects directly to the instance with no flexibility.
A service name supports load balancing and PDBs.
PDB connections (e.g., XEPDB1) require a service name. Oracle does not register a SID for individual PDBs — only the CDB has a SID — so PDBs cannot be reached using SID-style connection syntax.
host:port:SID jdbc:oracle:thin:@localhost:1521:XEService Name syntax:
host:port/service jdbc:oracle:thin:@//localhost:1521/XEPDB1
listener.ora.tnsnames.ora maps a connection alias to a host, port, and service name, so clients can connect using a simple name instead of full connection details.username=SYS role=SYSDBA service=XEApplication work:
username=MTITEK role=DEFAULT service=XEPDB1Common user (granted at CDB level):
username=C##ADMIN role=DEFAULT service=XEPDB1Roles and services combinations:
SYSDBA + XE = CDB root, full admin access across all PDBs SYSDBA + XEPDB1 = directly into the PDB as admin DEFAULT + XEPDB1 = normal application user connection
SYSTEM, USERS, UNDOTBS1, TEMP.Analogy: the tablespace is the physical filing cabinet (where data lives on disk); the schema is the labeled folder inside the cabinet (who owns which documents).
USERS) where its objects are physically stored, with disk usage limited via QUOTA.ALTER SESSION SET CONTAINER = XEPDB1; CREATE TABLESPACE MTITEK_DATA_TS DATAFILE '/opt/oracle/oradata/XE/XEPDB1/mtitek_data_ts_1.dbf' SIZE 500M AUTOEXTEND ON; CREATE USER MTITEK_APP IDENTIFIED BY MTITEKPWD DEFAULT TABLESPACE MTITEK_DATA_TS QUOTA UNLIMITED ON MTITEK_DATA_TS; GRANT CONNECT, RESOURCE TO MTITEK_APP;
MTITEK_APP is the schema/user.
MTITEK_DATA_TS is the tablespace that physically stores its data.
SYSDBA/SYSOPER authentication outside the database (needed when the database is down).FLASHBACK DATABASE to rewind the entire database to a previous point in time.