加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 数据库 > MsSql > 正文

sql – DB2:如何查找表或表列表中是否存在列?

发布时间:2020-05-23 14:01:00 所属栏目:MsSql 来源:互联网
导读:我正在使用DB2数据库.什么是合适的SQL查询来查明表或表列表中是否存在列? 例如 if column_name is found in table name or [list of table names]return true or the name of tables that have that column. 非常感谢. 使用 SYSCAT.COLUMNS catalog v

我正在使用DB2数据库.什么是合适的SQL查询来查明表或表列表中是否存在列?

例如

if "column_name" is found in "table name" or [list of table names]

return true or the name of tables that have that column.

非常感谢.

解决方法

使用 SYSCAT.COLUMNS catalog view:
SELECT TABNAME
FROM SYSCAT.COLUMNS
WHERE 
    TABNAME IN ('table name 1','table name 2') AND 
    COLNAME = 'column_name';

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读