SAS/ACCESS Interface for MySQL |
Overview |
This section describes the LIBNAME statements that SAS/ACCESS Interface to MySQL supports and includes examples. For details about this feature, see Overview of the LIBNAME Statement for Relational Databases.
Here is the LIBNAME statement syntax for accessing MySQL.
LIBNAME libref mysql <connection-options><LIBNAME-options>; |
Arguments |
specifies any SAS name that serves as an alias to associate SAS with a database, schema, server, or group of tables.
specifies the SAS/ACCESS engine name for MySQL interface.
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.
specifies the MySQL user login ID. If this argument is not specified, the current user is assumed. If the user name contains spaces or nonalphanumeric characters, you must enclose the user name in quotation marks.
specifies the MySQL password that is associated with the MySQL login ID. If the password contains spaces or nonalphanumeric characters, you must enclose the password in quotation marks.
specifies the MySQL database to which you want to connect. If the database name contains spaces or nonalphanumeric characters, you must enclose the database name in quotation marks.
specifies the server name or IP address of the MySQL server. If the server name contains spaces or nonalphanumeric characters, you must enclose the server name in quotation marks.
specifies the port used to connect to the specified MySQL server. If you do not specify a value, 3306 is used.
define how SAS processes DBMS objects. Some LIBNAME options can enhance performance, while others determine locking or naming behavior. The following table describes the LIBNAME options for SAS/ACCESS Interface to MySQL, with the applicable default values. For more detail about these options, see LIBNAME Options for Relational Databases.
Option | Default Value |
---|---|
ACCESS= |
none |
AUTHDOMAIN= |
none |
AUTOCOMMIT= |
YES |
CONNECTION= |
SHAREDREAD |
CONNECTION_GROUP= |
none |
DBCOMMIT= |
1000 when inserting rows; 0 when updating rows, deleting rows, or appending rows to an existing table |
DBCONINIT= |
none |
DBCONTERM= |
none |
DBCREATE_TABLE_OPTS= |
none |
DBGEN_NAME= |
DBMS |
DBINDEX= |
NO |
DBLIBINIT= |
none |
DBLIBTERM= |
none |
DBMAX_TEXT= |
1024 |
DBMSTEMP= |
NO |
DBPROMPT= |
NO |
DBSASLABEL= |
COMPAT |
DEFER= |
NO |
DIRECT_EXE= |
none |
DIRECT_SQL= |
YES |
ESCAPE_BACKSLASH= |
|
INSERTBUFF= |
0 |
MULTI_DATASRC_OPT= |
none |
PRESERVE_COL_NAMES= |
YES |
PRESERVE_TAB_NAMES= |
YES |
QUALIFIER= |
none |
REREAD_EXPOSURE= |
NO |
SPOOL= |
YES |
SQL_FUNCTIONS= |
none |
SQL_FUNCTIONS_COPY= |
none |
UTILCONN_TRANSIENT= |
NO |
MySQL LIBNAME Statement Examples |
In the following example, the libref MYSQLLIB uses SAS/ACCESS Interface to MySQL to connect to a MySQL database. The SAS/ACCESS connection options are USER=, PASSWORD=, DATABASE=, SERVER=, and PORT=.
libname mysqllib mysql user=testuser password=testpass database=mysqldb server=mysqlserv port=9876; proc print data=mysqllib.employees; where dept='CSR010'; run;
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.