SUPPORT / SAMPLES & SAS NOTES
 

Support

Usage Note 38106: Defining a schema in SAS/ACCESS® Interface to DB2

DetailsAboutRate It

When you use SAS/ACCESS Interface to DB2 to connect to the DB2 database, the SAS® System looks for tables that are owned or created by the user ID that is listed in the LIBNAME statement. If the software does not find any tables associated with that user ID, the SAS log still shows that the library was assigned successfully, as shown in the following example output:

libname mylib db2 user=user-id password=password datasrc=data-source-name;
NOTE: Libref MYLIB was successfully assigned as follows:
Engine:        DB2

However, no tables appear in the library in the SAS Explorer window, as shown here:

Explorer Window

The library does not show any tables because there are no tables owned or created by the user ID from the LIBNAME statement. Therefore, you need to define a schema in the LIBNAME statement. A schema is the owner or creator of tables. To see tables that are owned or created by a different user, you must use the SCHEMA=schema-name option in the LIBNAME statement.

To determine the schema for your tables, follow these steps:

  1. Submit the following code using your DB2 user ID, password, and data source:
    proc sql; connect to db2 (datasrc=data-source-name user=user-id password=password); create table work.db2schema as select * from connection to db2 (select TABSCHEMA, TABNAME from syscat.tables order by tabschema); disconnect from db2; quit;

    After you run the code, open the created table to see the schema and table names:

    VIEWTABLE

  2. Scroll through the Work.db2schema table to find the owner name for the table that you want to see.
  3. Use the owner name for that table as the value in the SCHEMA= option in your LIBNAME statement. For example, if you want to see the MY_CLASS table, you must use SCHEMA=DBITEST in the LIBNAME statement, as shown here:
    libname mylib db2 user=user-id password=password datasrc=data-source-name schema=dbitest;

When you submit the LIBNAME statement in this example, the tables with a schema value of DBITEST appear in the Explorer window.

Explorer Window

Note: When you connect to DB2, the schema name can, at times, case sensitive. Therefore, you need to try the schema name in the following four ways:

  • all lowercase (for example, schema=dbitest)
  • all uppercase (for example, schema=DBITEST)
  • all lowercase with double quotation marks (for example, schema="dbitest")
  • all uppercase with double quotation marks (for example, schema="DBITEST")


Operating System and Release Information

Product FamilyProductSystemSAS Release
ReportedFixed*
SAS SystemSAS/ACCESS Interface to DB2Linux on Itanium9.1 TS1M3 SP4
Solaris for x649.1 TS1M3 SP4
Linux9.1 TS1M3 SP4
64-bit Enabled Solaris9.1 TS1M3 SP4
64-bit Enabled AIX9.1 TS1M3 SP4
64-bit Enabled HP-UX9.1 TS1M3 SP4
Microsoft Windows XP Professional9.1 TS1M3 SP4
Windows Vista9.1 TS1M3 SP4
Microsoft Windows Server 2003 Standard Edition9.1 TS1M3 SP4
Microsoft Windows Server 2003 Enterprise Edition9.1 TS1M3 SP4
Microsoft Windows Server 2003 Datacenter Edition9.1 TS1M3 SP4
Microsoft Windows 2000 Professional9.1 TS1M3 SP4
Microsoft Windows 2000 Server9.1 TS1M3 SP4
Microsoft Windows 2000 Datacenter Server9.1 TS1M3 SP4
Microsoft Windows 2000 Advanced Server9.1 TS1M3 SP4
Microsoft Windows XP 64-bit Edition9.1 TS1M3 SP4
Microsoft Windows Server 2003 Enterprise 64-bit Edition9.1 TS1M3 SP4
HP-UX IPF9.1 TS1M3 SP4
Microsoft Windows NT Workstation9.1 TS1M3 SP4
Microsoft Windows Server 2003 Datacenter 64-bit Edition9.1 TS1M3 SP4
Microsoft® Windows® for 64-Bit Itanium-based Systems9.1 TS1M3 SP4
* For software releases that are not yet generally available, the Fixed Release is the software release in which the problem is planned to be fixed.