我目前有 2 个查询(我从互联网上的各个页面获取)执行以下操作:
- 检索给定表的所有列
- 检索给定表的 PK 和 FK 约束
这些查询分别是
select
c.colname,
c.coltype,
c.collength
from
syscolumns c,
systables t
where
t.tabname = 'user' and
c.tabid = t.tabid
和
select
c.colname,
c.colno,
o.constrtype
from
systables t,
sysconstraints o,
sysindexes i,
syscolumns c
where
t.tabname = 'user' and
c.tabid = t.tabid and
o.tabid = t.tabid and
i.tabid = t.tabid and
o.constrtype in ('R', 'P') and
o.idxname = i.idxname and
( colno = part1 or
colno = part2 or
colno = part3 or
colno = part4 or
colno = part5 or
colno = part6 or
colno = part7 or
colno = part8 or
colno = part10 or
colno = part9 or
colno = part11 or
colno = part12 or
colno = part13 or
colno = part14 or
colno = part15 or
colno = part16 );
我想将这些查询连接在一起,以便结果包含类似
colname
, colno
, collength
, 的内容constrtype
。我相信 LEFT OUTER JOIN 是我需要的,但我不太确定如何形成它,所以任何帮助将不胜感激。