Issues about SQuirrelSQL with IBM DB2 Databases | Generated by AI

Home PDF

When using the Squirrel SQL client to connect to your IBM DB2 database named ADB and running the query SELECT * FROM ADB.EDATA, you’re encountering an “undefined name” error. This error typically means that the database cannot find the object (in this case, EDATA) you’re trying to query. Let’s break down why this might be happening and how to resolve it step by step.

Why the Error Occurs

The “undefined name” error (often associated with SQLCODE -204 and SQLSTATE 42704 in DB2) suggests one of the following issues:

  1. The table EDATA doesn’t exist in the ADB schema.
  2. The schema or table name is misspelled or uses a different case.
  3. You don’t have sufficient privileges to access the table.
  4. The connection or configuration in Squirrel SQL isn’t pointing to the right database or schema.

Since you mentioned that the database ADB has “a lot of objects, like EDATA,” it implies that EDATA should exist, but we need to confirm its exact location and accessibility.

Steps to Diagnose and Fix the Issue

1. Verify Your Database Connection

First, ensure that Squirrel SQL is connected to the correct database, ADB. In DB2, you connect to a database, and within that database, there are multiple schemas. Check your connection settings in Squirrel SQL:

If you’re connected to a different database, update the connection settings and reconnect.

2. Confirm the Schema Name

In your query, ADB.EDATA assumes that ADB is the schema containing the table EDATA. However, ADB might be the database name rather than the schema name. In DB2, the schema is a separate namespace within the database. To list all schemas in the ADB database, run this query:

SELECT SCHEMANAME FROM SYSCAT.SCHEMATA

3. Check for the Table in the ADB Schema

Assuming ADB is the schema, verify that EDATA exists within it. Run this query to list all tables in the ADB schema:

SELECT TABNAME FROM SYSCAT.TABLES WHERE TABSCHEMA = 'ADB'

4. Handle Case Sensitivity

In DB2, schema and table names are case-sensitive if created with quotes (e.g., "EDATA"). By default, unquoted names are folded to uppercase. Since you wrote ADB.EDATA, DB2 interprets it as ADB.EDATA (all uppercase). If the table was created with a different case (e.g., "EData"), you’ll need to match it exactly. Try this:

SELECT * FROM "ADB"."EDATA"

If that works, the issue is case sensitivity. Alternatively, check the exact name:

SELECT TABNAME FROM SYSCAT.TABLES WHERE TABSCHEMA = 'ADB'

Look at the exact spelling and case of EDATA in the results, and adjust your query accordingly (e.g., SELECT * FROM ADB."EData" if it’s listed as EData).

5. Search Across All Schemas

If EDATA isn’t in the ADB schema, it might be in another schema. Search the entire database for EDATA:

SELECT TABSCHEMA, TABNAME FROM SYSCAT.TABLES WHERE TABNAME = 'EDATA'

6. Check Object Type

EDATA might not be a table but a view, alias, or nickname (e.g., for a remote table). Check these possibilities:

7. Verify Permissions

Although “undefined name” typically indicates the object doesn’t exist, it’s worth checking your privileges:

SELECT GRANTOR, GRANTEE, SELECTAUTH FROM SYSCAT.TABAUTH WHERE TABSCHEMA = 'ADB' AND TABNAME = 'EDATA'

8. Look for Typos or Similar Names

If EDATA isn’t found, there might be a typo. Search for similar table names:

SELECT TABNAME FROM SYSCAT.TABLES WHERE TABSCHEMA = 'ADB' AND TABNAME LIKE '%EDATA%'

If you see something like E_DATA or EDATA1, use that name instead (e.g., SELECT * FROM ADB.E_DATA).

How to Fix It

Based on the above diagnostics, here’s how to resolve the issue:

Example Resolution

Suppose you run SELECT TABSCHEMA, TABNAME FROM SYSCAT.TABLES WHERE TABNAME = 'EDATA' and get:

TABSCHEMA | TABNAME
----------|---------
USER1     | EDATA

Then, your query should be:

SELECT * FROM USER1.EDATA

If the table doesn’t appear anywhere, it likely doesn’t exist, and you’ll need to clarify its name or location.

Final Notes

Start by running the diagnostic queries in Squirrel SQL to pinpoint the issue. The most likely cause, given the “undefined name” error, is that EDATA isn’t in the ADB schema or has a different name/case. Once you identify the correct schema and table name, your query should work. If you’re still stuck, check the detailed error message in Squirrel SQL (e.g., SQLCODE) for more clues or consult your database administrator.


When you run the query SELECT * FROM SYSCAT.TABLES in Squirrel SQL Client connected to an IBM DB2 database and then commit, seeing only “commit successfully” without any results can be confusing. The SYSCAT.TABLES view in DB2 should display a list of all tables in the database, including system tables, so you would expect to see some output. Let’s walk through why this might be happening and how to resolve it.

Understanding the Behavior

First, it’s worth noting that a SELECT statement doesn’t modify data, so committing after running it doesn’t affect the query’s results. The “commit successfully” message likely relates to the transaction state in Squirrel SQL Client (e.g., if “Auto Commit” is off), but it’s unrelated to whether results are displayed. The key issue is that no data appears in the “Results” tab, which suggests a problem with the query execution, permissions, or how the tool is displaying the output.

Steps to Diagnose and Fix the Issue

1. Verify the Query Execution in Squirrel SQL Client

2. Test Basic Connectivity and Permissions

3. Investigate Permissions on SYSCAT.TABLES

4. Confirm Database Content

5. Rule Out Tool-Specific Issues

Likely Cause and Solution

The most probable reason you’re not seeing results is that your user account lacks the necessary permissions to query SYSCAT.TABLES. This is common in DB2 environments where access to system catalog views is restricted. Here’s what to do:

If permissions are confirmed and the problem persists, focus on Squirrel SQL Client settings (e.g., row limits, tab selection) or verify the database connection.

Final Notes

By following these steps, you should identify whether the issue is due to permissions, tool configuration, or an unexpected database state. Start with the simple tests (SYSIBM.SYSDUMMY1) and escalate to your administrator if needed. Once resolved, SELECT * FROM SYSCAT.TABLES should display the expected list of tables.


When you run SELECT * FROM SYSCAT.TABLES in Squirrel SQL Client and only see system tables, it’s likely because the results include both system and user tables, but the system tables are more prominent or the user tables are not being filtered correctly. The SYSCAT.TABLES system catalog view in IBM DB2 contains metadata about all tables in the database, including both system tables (typically in schemas like SYSIBM, SYSCAT, SYSSTAT, and SYSTOOLS) and user-defined tables (in user-created schemas). To display only the user’s tables, you need to filter out the system tables by modifying your query.

Solution

To show only user-defined tables, run the following SQL query:

SELECT * FROM SYSCAT.TABLES 
WHERE TABSCHEMA NOT IN ('SYSIBM', 'SYSCAT', 'SYSSTAT', 'SYSTOOLS')

This query excludes the main system schemas and will display only tables from user-defined schemas.

Explanation

If your database has additional system schemas beyond these four, you can expand the list in the NOT IN clause. Alternatively, you could use a broader filter like WHERE TABSCHEMA NOT LIKE 'SYS%', which excludes any schema starting with SYS. However, this might be less precise if some user schemas also begin with SYS, so the NOT IN approach is generally safer.

Additional Steps to Verify and Troubleshoot

If the above query doesn’t show the user tables you expect, here are some steps to investigate further:

  1. List All Schemas
    To see all schemas (both system and user-defined) that contain tables, run:
    SELECT DISTINCT TABSCHEMA FROM SYSCAT.TABLES
    

    This will return a list of unique schema names. Check if your user schemas (e.g., ADB or others) appear alongside the system schemas like SYSIBM or SYSCAT.

  2. Check a Specific Schema
    If you know the schema where your user tables should be (e.g., ADB), run:
    SELECT * FROM SYSCAT.TABLES WHERE TABSCHEMA = 'ADB'
    

    This will show all tables in that specific schema. If no rows are returned, either the schema doesn’t exist, or it contains no tables.

  3. Check Squirrel SQL Client Settings
    Sometimes the issue isn’t with the query but with how Squirrel SQL Client displays the results:
    • Row Limit: Go to the SQL menu and check the “Limit Rows” setting. If it’s set to a low number (e.g., 100), and system tables dominate the top of the result set, user tables might not appear. Increase the limit or disable it.
    • Sorting: Sort the results by TABSCHEMA or TABNAME (e.g., SELECT * FROM SYSCAT.TABLES ORDER BY TABSCHEMA) to make user schemas easier to spot.
  4. Confirm User Tables Exist
    To count the number of user tables, run:
    SELECT COUNT(*) FROM SYSCAT.TABLES WHERE TABSCHEMA NOT IN ('SYSIBM', 'SYSCAT', 'SYSSTAT', 'SYSTOOLS')
    

    If this returns a number greater than zero, user tables exist, and the issue is with how the results are being viewed.

Why You’re Seeing Only System Tables

Without a filter, SELECT * FROM SYSCAT.TABLES returns all tables, but system tables (e.g., in SYSIBM or SYSCAT) often outnumber user tables or appear first in the result set, especially if no sorting is applied. By explicitly excluding system schemas, as shown in the solution, you’ll isolate the user tables.

If you still don’t see user tables after applying the filter, it’s possible that:

Try the filtered query first, and use the troubleshooting steps if needed to confirm the presence of user tables.


Back 2025.03.06 Donate