gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 02:55:43 27 4
gpt4 key购买 nike

我正在使用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';

关于sql - DB2:如何查找表或表列表中是否存在列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8743810/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com