How to find table and column in DB2 with tbspaceid tableid specified in error message

北城余情 提交于 2019-12-03 11:43:09

问题


I get following error message when trying to insert an object in the database:

com.ibm.db2.jcc.am.SqlIntegrityConstraintViolationException: 
DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=TBSPACEID=2,
    TABLEID=19, COLNO=0, DRIVER=4.15.134

How can I retrieve the table/column name for which the error is thrown?


回答1:


Apparently at the package level, DB2 only works with the IDs and not the names.

You can find them back using the following query:

SELECT C.TABSCHEMA, C.TABNAME, C.COLNAME
FROM SYSCAT.TABLES AS T,
SYSCAT.COLUMNS AS C
WHERE T.TBSPACEID = 2
AND T.TABLEID = 19
AND C.COLNO = 0
AND C.TABSCHEMA = T.TABSCHEMA
AND C.TABNAME = T.TABNAME


来源:https://stackoverflow.com/questions/41467531/how-to-find-table-and-column-in-db2-with-tbspaceid-tableid-specified-in-error-me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!