1

The issue is when querying a table created using Aqua Data Studio in our IBM DB2 database, column names can't be specified unless I use the system name. Tables made a short time ago don't have this issue. The query can find the column names just fine in them. There also is not a problem using wildcards and the column names display just fine. For clarity:

  • this works : SELECT * FROM WUNITS.DVIRS
  • this works : SELECT ID___00001 FROM WUNITS.DVIRS
  • This doesn't : SELECT Id FROM WUNITS.DVIRS
  • This does work for older tables created the same way : SELECT Id FROM WUNITS.DVIRS

Here is a screenshot of the column definitions

enter image description here

What am I doing wrong?

2
  • Are you able to connect to the database without this client (Aqua Data Studio)? Say through linux console? It seems that this client is creating aliases to show the table structure instead of the real table structure. Try running on it: describe table WUNITS.DVIRS and edit your question with the result Commented Jan 4, 2018 at 0:15
  • select "Id" from mytable. Looks like the lower case has been enabled. Commented Jan 4, 2018 at 17:10

1 Answer 1

3

Since you mention system name, I'll assume you're using Db2 for IBM i....

I suspect you've created the table with quoted column names...you wouldn't see mixed case column names otherwise, they would be all CAPITALS.

For example:

create table dtcwilt.dvirs (
  "Id" bigint
  , "AssetNumber" varchar(25)
  , WoNumber bigint
  , WoStatusId int
)

Not sure what tool you're using to display the columns, but the ACS schema tool would show the quoted name.

enter image description here

The quotes are actually part of the name, you'd need to use the quoted name, with proper capitalization, in your select:

This should work:

SELECT "Id" FROM WUNITS.DVIRS

This would not:

SELECT "ID" FROM WUNITS.DVIRS
Sign up to request clarification or add additional context in comments.

1 Comment

That's it! I've spent too much time in the Microsoft world. Now I just have to go fix a half dozen tables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.