6 Connecting to Oracle Database Free
Connecting Locally using OS Authentication
When you install Oracle Database Free, your Windows user is automatically added to
the ORA_DBA
operating system group, which grants you the
SYSDBA
privileges. You can use the following commands to connect to the
database. In the commands, replace "oracle_home" with the path to your
Oracle Home; see Table 4-1 for more details about the Oracle Home:
cd oracle_home\bin
sqlplus / as sysdba
These commands connect you to the root container CDB$ROOT
of the multitenant database (CDB) as database user SYS
. This method of connecting to the database works even if the Net Services listener is not running.
Connecting to Oracle Database Using Easy Connect Naming Method
-
Multitenant container database: host[:port]
-
Pluggable database: host[:port]/service_name
FREEPDB1
is the service name defined for the first PDB
created by default. You can replace FREEPDB1
with the name of another PDB
you want to connect to.
Specifying the port is optional when the listener is setup with the default
port 1521
. You must specify the port number if you use another port.
Connection strings for local connections were provided on the final screen of the install. If you are connecting from a remote computer, you need to provide the hostname (where Free is installed) instead of localhost.
Please note that, Net Services database listener must be running on the database host on the specified port for the connections to succeed.
cd oracle_home\bin
sqlplus system@dbhost.example.com:1521
FREEPDB1
using the following
commands:cd oracle_home\bin
sqlplus system@dbhost.example.com:1521/FREEPDB1
Replace dbhost.example.com
with your database host name. If
needed, replace 1521
with the port number the listener listens on. You can
replace FREEPDB1
with the name of another PDB you want to connect to.
To shorten connect strings or to avoid hardcoding host name and port in
application code and DBA scripts, you can define an alias for the connect string in the
configuration file
oracle_base_home\network\admin\tnsnames.ora
on
database clients. See Configuring the Local Naming Method for
more details.
Net Services Listener and Default Services
The Net Services database listener for Oracle Database Free allows you to connect to the database over TCP/IP from the same machine or other machines on the network. The configuration of the Listener can be viewed using the following commands run from the command prompt:
cd oracle_home\bin
lsnrctl status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost.example.com)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 23.0.0.0.0 - Development Trace Level off Security ON: Local OS Authentication SNMP OFF Default Service FREE Listener Parameter File C:\install_dir\dbhomeFree\network\admin\listener.ora Listener Log File C:\install_dir\diag\tnslsnr\dbhost\listener\alert\log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbhost.example.com)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Services Summary... Service "dbhost.example.com" has 1 instance(s). Instance "FREE", status READY, has 1 handler(s) for this service... Service "FREE.dbhost.example.com" has 1 instance(s). Instance "FREE", status READY, has 1 handler(s) for this service... Service "FREEXDB.dbhost.example.com" has 1 instance(s). Instance "FREE", status READY, has 1 handler(s) for this service... Service "freepdb1.dbhost.example.com" has 1 instance(s). Instance "FREE", status READY, has 1 handler(s) for this service... The command completed successfully
lsnrctl
command shows values of a number of important parameters:
- the port the listener listens on
- the list of services registered with the listener
- the name of the configuration file used by the listener
- the name of the log file
You specify a service when connecting to the database through the listener. The
default services created by Oracle Database FREE are FREE
and
FREEPDB1
. The FREE
service connects you to the root
container of the database (CDB$ROOT
) and the FREEPDB1
service connects you to the default pluggable database (FREEPDB1
) created
at the installation time. For each new pluggable database (PDB) in the database, there will
be a new default service created with the same name as the PDB.
Note:
If the Oracle Database FREE instance is shut down, thelsnrctl
status command does not show any services you can connect
to.