我希望能够在Informix DB中搜索列。在主表中有一个cust_nbr列,然后在未知数量的表中引用该列。
在Informix中,有没有一种方法可以查询数据库并获得所有使用cust_nbr的表?
发布于 2012-07-30 16:18:52
SELECT tabname, colno, colname
FROM systables a, syscolumns b
WHERE a.tabid = b.tabid
and colname = "cust_nbr"
ORDER BY colno;
我在相同的位置找到了这段代码,并添加了额外的restriant,名称为colname = cust_nbr。
这似乎对我很有效。我会核实的,但所有迹象看起来都起作用了。
我在另一篇文章提到的Using the Informix Catalogs中发现了这一点
发布于 2012-07-30 13:18:43
您应该能够从system catalog tables,特别是sysreferences
获得这种类型的东西。摘自Using the Informix System Catalog
SELECT a.tabname, constrname, d.tabname
FROM systables a, sysconstraints b, sysreferences c,
systables d
WHERE b.constrtype = 'R'
AND a.tabid = b.tabid
AND b.constrid = c.constrid
AND c.ptabid = d.tabid
AND a.tabname = ?;
https://stackoverflow.com/questions/11722329
复制