LIBNAME Statement for the Oracle Engine

Overview

This section describes the LIBNAME statement that SAS/ACCESS Interface to Oracle supports. For general information about this feature, see LIBNAME Statement for Relational Databases.

Here is the LIBNAME statement syntax for accessing Oracle.

For general information about the LIBNAME statement that is not specific to SAS/ACCESS, see LIBNAME Statement in SAS Global Statements: Reference.

Arguments

libref

specifies any SAS name that serves as an alias to associate SAS with a database, schema, server, or group of tables and views.

oracle

specifies the SAS/ACCESS engine name for the Oracle interface.

connection-options

provide connection information and control how SAS manages the timing and concurrence of the connection to the DBMS. Here is how these options are defined.

Note: All of these connection options are valid when used in the CONNECT statement with the SQL procedure.

If you specify the appropriate system options or environment variables for Oracle, you can often omit the options from your LIBNAME statements. See your Oracle documentation for details.

USER=<'>Oracle-user-name<'>

specifies an optional Oracle user name. If the user name contains blanks or national characters, enclose it in quotation marks. If you omit an Oracle user name and password, the default Oracle user ID OPS$sysid is used, if it is enabled.

Alias: UID=

Restriction: When you specify <'>Oracle-user-name<'> in the LIBNAME statement, SAS changes the user name to uppercase characters, even if the user name uses quotation marks.

How Oracle Treats the User Name

User Name Conditions

What to Know or Do

Enclosed in single quotation marks:

'scott'

The SAS/ACCESS Oracle engine ignores the single quotation marks, and Oracle converts characters to all uppercase (from scott to SCOTT).

Contains lowercase or mixed-case characters:

scott

Scott

First enclose characters in double quotation marks, and then enclose everything in single quotation marks:

'"scott"'

'"Scott"'

Contains blanks or national characters:

scott smith

Enclose characters in single or double quotation marks:

'scott smith'

"scott smith"

Contains a macro reference:

&name

Enclose characters in double quotation marks:

"&name"

Contains one or more of these SQL*Loader special characters: = @ /

scott@

Enclose all characters in single quotation marks, and then enclose everything in double quotation marks.

"'scott@'"

Required: If you specify USER=, you must also specify PASSWORD=.

PASSWORD=<'>Oracle-password<'>

specifies an optional Oracle password that is associated with the Oracle user name. If you omit it, the password for the default Oracle user ID OPS$sysid is used if it is enabled. If the password contains spaces or nonalphanumeric characters, you must enclose it in quotation marks.

Alias: ORAPW=, PASS=, PWD=, PW=

Required: If you specify USER=, you must also specify PASSWORD=.

Important: The SQL*Loader that the BULKLOAD= data set option calls takes user name and password as command-line arguments. This means that a user who runs the ps command while the SQL*Loader is running could see the user credentials. To conceal the user name and password, be sure that the BL_PARFILE= data set option is also specified.

Tip: If you do not wish to enter your Oracle password in uncoded text, see PROC PWENCODE in the Base SAS Procedures Guide for a method to encode it.

PATH=<'>Oracle-database-specification<'>

specifies the Oracle driver, node, and database. Aliases are required if you are using SQL*Net Version 2.0 or later. In some operating environments, you can enter the information that is required by the PATH= statement before invoking SAS.

SAS/ACCESS uses the same Oracle path designation that you use to connect to Oracle directly. See your database administrator to determine the databases that have been set up in your operating environment and also the default values if you do not specify a database. To learn more about how to set up default connections to an Oracle database without specifying a value for the PATH environment variable, refer to the information about TWO_TASK (on UNIX) or LOCAL (on Windows) in the environment variables section of your Oracle documentation.

READBUFF=number-of-rows

specifies the number of rows to retrieve from an Oracle table or view with each fetch. Using this option can improve the performance of any query to Oracle. By specifying the value of the READBUFF= option in your SAS programs, you can find the optimal number of rows for a given query on a given table.

Alias: BUFF= and BUFFSIZE= are aliases for READBUFF=.

Default: 250 rows per fetch

Restriction: Although this value can be up to 2,147,483,647 rows per fetch, this depends on available memory. A practical limit for most applications is less, so the total maximum buffer size must not exceed 2GB.

PRESERVE_COMMENTS

lets you pass additional information (called hints) to Oracle for processing. These hints might direct the Oracle query optimizer to choose the best processing method based on your hint.

You specify PRESERVE_COMMENTS as an option in the CONNECT statement. You then specify the hints in the Oracle SQL query for the CONNECTION TO component. Hints are entered as comments in the SQL query and are passed to and processed by Oracle.

Restriction: This option is valid only in the CONNECTION statement, not in the LIBNAME statement. For the LIBNAME statement, you can use the PRESERVE_COMMENTS= LIBNAME option.

LIBNAME-options

specify how SAS processes DBMS objects. Some LIBNAME options can enhance performance, and others determine locking or naming behavior. The table below describes the LIBNAME options for SAS/ACCESS Interface to Oracle, with the applicable default values. This table also identifies LIBNAME options that are valid in the CONNECT statement in the SQL procedure.For more information, see LIBNAME Options for Relational Databases.

SAS/ACCESS LIBNAME Options for Oracle

Option

Default Value

Valid in CONNECT

ACCESS=

none

ADJUST_BYTE_SEMANTIC_COLUMN_ LENGTHS=

conditional

ADJUST_NCHAR_COLUMN_ LENGTHS=

YES

AUTHDOMAIN=

none

BL_DEFAULT_DIR=

<database-name>

CONNECTION=

SHAREDREAD

CONNECTION_GROUP=

none

DB_LENGTH_SEMANTICS_BYTE=

YES

DB_OBJECTS=

(TABLES VIEWS)

DBCLIENT_ENCODING_FIXED=

YES or NO, based on the SAS encoding

DBCLIENT_MAX_BYTES=

matches the maximum number of bytes per single character of the SAS session encoding

DBCOMMIT=

1000 (when inserting rows), 0 (when updating, deleting, or appending to an existing table)

DBCONINIT=

none

DBCONTERM=

none

DBCREATE_TABLE_OPTS=

none

DBGEN_NAME=

DBMS

DBINDEX=

NO

DBLIBINIT=

none

DBLIBTERM=

none

DBLINK=

the local database

DBMAX_TEXT=

1024

DBMSTEMP=

NO

DBNULLKEYS=

YES

DBNULLWHERE=

YES

DBPROMPT=

NO

DBSERVER_ENCODING_FIXED=

YES or NO, based on the Oracle server encoding

DBSERVER_MAX_BYTES=

usually 1

DBSLICEPARM=

THREADED_APPS,2

DEFER=

NO

DIRECT_EXE=

none

DIRECT_SQL=

YES

INSERTBUFF=

500

1 is the forced default when REREAD_EXPOSURE=YES

LOCKWAIT=

YES

MAX_STRING_SIZE=

NONE

MULTI_DATASRC_OPT=

NONE

POST_STMT_OPTS=

none

OR_BINARY_DOUBLE=

YES

OR_ENABLE_INTERRUPT=

NO

OR_UPD_NOWHERE=

YES

POST_DML_STMT_OPTS=

none

PRESERVE_COL_NAMES=

NO

PRESERVE_COMMENTS=

NO

PRESERVE_TAB_NAMES=

NO

READBUFF=

250

READ_ISOLATION_LEVEL=

see Locking in the Oracle Interface

READ_LOCK_TYPE=

NOLOCK

REREAD_EXPOSURE=

NO

SCHEMA=

SAS accesses objects in the default and public schemas

SHOW_SYNONYMS=

NO

SPOOL=

YES

SQL_FUNCTIONS=

none

SQL_FUNCTIONS_COPY=

none

SQLGENERATION=

none

UPDATE_ISOLATION_LEVEL=

see Locking in the Oracle Interface

UPDATE_LOCK_TYPE=

NOLOCK

UPDATEBUFF=

1

UTILCONN_TRANSIENT=

NO

Oracle LIBNAME Statement Examples

This example uses default values for the connection options to make the connection. If you specify the appropriate system options or environment variables for Oracle, you can often omit the connection options from your LIBNAME statements. See your Oracle documentation for details.

libname myoralib oracle;

In this next example, the MYDBLIB libref uses the Oracle interface to connect to an Oracle database. SAS/ACCESS connection options are USER=, PASSWORD=, and PATH=. PATH= specifies an alias for the database specification, which SQL*Net requires.

libname mydblib oracle user=myusr1 password=mypwd1 path=mysrv1;

proc print data=mydblib.employees;
   where dept='CSR010';
run;

This next example connects to Oracle using the CONNECT_DATA= descriptor.

libname x oracle user=myusr1 pw=mypwd1
     path="(DESCRIPTION =
             (ADDRESS_LIST =
               (ADDRESS = (PROTOCOL = TCP) (HOST = pinkfloyd) (PORT = 1521))
              )
             (CONNECT_DATA =
                 (SID = alien )
             )
           )"
           ;
Last updated: February 3, 2026