Tuesday, January 22, 2013

selecting objects in DB2 with a slash in them

Not having worked with DB2 for a while, I found myself in a bind today.
One of the developers had tried installing a package from somewhere, and it created a lot of objects with slashes in them. Like /DEV1/WEIRD_OBJECT and /DEV/WEIRD_OBJECT_V

After an attemt at uninstalling these I was asked to help. And I was kind of puzzled at first about why someone would use a command interpreted character in an objectname. But overcomming this obstacle was nonetheless my task. A simple command db2 "drop table tablename" didn't really do the trick. Looking at the manual just gave me todays first headache. Searching with bing and google returned no viable results, other than a lot of critism about using slashes in objectnames and some helpful hints for Oracle. Had this been oracle, the problem would have been much simpler. Just use double quotations.

I didn't have this option in DB2, because I have to send the command in the double quatation to begin with !

In the end I ended up using single AND double quotations like: db2 "select viewschema,viewname from syscat.views where viewname like '/DEV1/WEIRD%' "
That gave me a nice overview of the views (you can guess the command to view the tables :D ) and then it's just rinse and repeat for the drop commands.....

Headache is still here, but now at least the problem is gone....

No comments:

Post a Comment