Database Reference
In-Depth Information
my $dbh = DBI->connect( "DBI:Oracle:(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TC
P)(HOST=dbserver.oradbpro.com)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=TEN)))", "nde
bes", "secret") or die "Connect failed: $DBI::errstr";
Again, use of
SERVICE_NAME
in the
CONNECT_DATA
section is preferred over
SID
.
Easy Connect
In Oracle10
g
and subsequent releases, Oracle Net easy connect may be used in connect strings.
An easy connect specification has the format
host_name
:
port
/
instance_service_name
. All the
information required to contact a listener is embedded in the connect string, such that Net
service name resolution is not required. Following is an example DBI connect call that uses
easy connect:
my $dbh = DBI->connect("DBI:Oracle:dbserver:1521/ELEVEN", "ndebes", "secret") or die
"Connect failed: $DBI::errstr";
Easy connect is preferred over the old format host=
host_name
;port=
port_number
;sid=
ORACLE_SID
, since it uses an instance service name.
6
Connecting with SYSDBA or SYSOPER Privileges
Since DBMS release Oracle9
i
, connecting as user
SYS
is only possible with
SYSDBA
privileges.
SYSDBA
privileges are assigned either by means of operating system group membership or by
granting
SYSDBA
while a password file is in use (
REMOTE_LOGIN_PASSWORDFILE=exclusive
or
shared
).
Care must be taken to distinguish between
SYSDBA
(or
SYSOPER
) privileges and operating system
authentication, discussed in the next section. The connect string
"/
AS SYSDBA"
uses both. The
slash (
/
) indicates that operating system authentication instead of a password is to be used,
while
AS
SYSDBA
signals that
SYSDBA
privileges are requested for the session. I will first show how
to connect as
SYSDBA
with database password authentication. The following requirements exist:
The DBMS instance must have been started with
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
or
SHARED
.
A password file, which was previously created with
orapwd
, must exist (otherwise the
instance would not start with the above parameter setting). On UNIX systems, the
password file path name is
$ORACLE_HOME/ dbs/orapw$ORACLE_SID
, on Windows it is
%ORACLE_HOME%\database\pwd%ORACLE_SID%.ora
.
SYSDBA
privilege must be granted to the user who wants to connect
AS
SYSDBA
(in
sqlnet.ora
on Windows,
SQLNET.AUTHENTICATION_SERVICES
is not set or does not include
NTS
; other-
wise operating system authentication might be used).
When these requirements are met, it is possible to connect
AS
SYSDBA
with SQL*Plus using
any of the protocol adapters bequeath, IPC, or TCP/IP.
6.
Please refer to the Introduction at the beginning of the topic for a definition of the term instance
service name.