如何使用错误消息中指定的tbspaceid tableid在DB2中查找表和列 [英] How to find table and column in DB2 with tbspaceid tableid specified in error message

查看:347
本文介绍了如何使用错误消息中指定的tbspaceid tableid在DB2中查找表和列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在数据库中插入对象时收到以下错误消息:

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?

推荐答案

显然在包级别,DB2仅使用ID,而不使用名称.

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

这篇关于如何使用错误消息中指定的tbspaceid tableid在DB2中查找表和列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆