Sub topic 11
Connecting as SYSDBA and Other Privileged Roles
Assume you know basic SQL, can use a terminal, and have access to an Oracle Database account. This chapter focuses on administrative connections, not on granting privileges or changing database configuration.
What SYSDBA Means
SYSDBA is a special administrative privilege. It is more powerful than ordinary object privileges such as SELECT or UPDATE. A user connected as SYSDBA can start and stop the database, alter database files, recover the database, and access data outside normal schema boundaries.
SYSDBA is also a connection mode. It is not simply a role that you grant like a normal application role. The database authenticates the administrator through one of these methods:
- Operating system authentication on the database server.
- A password file, commonly for remote administrative connections.
- An external authentication system configured by the database administrator.
Other administrative modes include SYSOPER, SYSBACKUP, SYSDG, and SYSKM. These modes are narrower than SYSDBA and are intended for specific administrative duties.
| Mode | Typical purpose | Access level |
|---|---|---|
| SYSDBA | Full database administration | Highest |
| SYSOPER | Startup, shutdown, and limited operations | Lower than SYSDBA |
| SYSBACKUP | Backup and recovery operations | Task-specific |
| SYSDG | Data Guard administration | Task-specific |
| SYSKM | Transparent Data Encryption key management | Task-specific |
Connecting from SQLcl
For a local connection on the database server, operating system authentication can avoid putting a database password in the command:
sql / as sysdbaYou can also start SQLcl without connecting and enter the connection command interactively:
sql /nolog
SQL> connect / as sysdba
Connected.A remote SYSDBA connection normally uses a password-file-enabled account and a service or connect identifier:
SQL> connect sys@//dbhost.example.com:1521/orclpdb1.example.com as sysdba
Password? ********
Connected.The database server must be configured to allow remote administrative authentication. A valid service name and listener are also required. A normal schema password does not automatically permit SYSDBA access.
To request another administrative mode, place the mode after the connect identifier:
SQL> connect sys@ORCL as sysoper
Password? ********
Connected.Connecting from SQL Developer
Create a normal database connection in SQL Developer, then choose the appropriate value in the Role field:
- Select New Connection.
- Enter the username, normally SYS for password-based administration.
- Choose Basic or TNS as the connection type.
- Enter the host, port, and service name, or select a TNS alias.
- Set Role to SYSDBA.
- Test the connection before saving it.
The role is part of the connection configuration. A connection configured as Normal does not become SYSDBA merely because its username is SYS.
Verify the Administrative Session
After connecting, confirm both the identity and the privilege mode:
select
sys_context('USERENV', 'SESSION_USER') as session_user,
sys_context('USERENV', 'CURRENT_USER') as current_user,
sys_context('USERENV', 'SERVICE_NAME') as service_name,
sys_context('USERENV', 'ISDBA') as is_dba
from dual;ISDBA returns TRUE when the session has SYSDBA authority. Check the service name as well, because a privileged connection to the wrong database can still succeed.
The connection path can be viewed as follows:
Safer Administrative Practice
Do not place administrative passwords in scripts, command history, or source control. Prefer interactive password prompts, protected wallet or connection-store mechanisms, and separate named accounts for individual administrators. Use the least powerful administrative mode that completes the task, and disconnect when the task is finished.
Exercise
You connect successfully as SYS, but ISDBA is FALSE. What should you check first?
Show answer
Check the connection Role in SQL Developer or the SQLcl command. The session may have connected as a normal user instead of using the AS SYSDBA clause.