GBase 8s
适配迁移
问答

获取表的主键约束信息,查询索引列

发表于2024-12-02 14:19:33186次浏览2个评论

【GBase版本】:GBase8sV8.8_TL_3.5.1_3X2_x86_64

【问题描述】*:
问题1:如何获取表的主键约束信息     问题2:如何查询索引列
有对应文档可参考吗

评论

登录后才可以发表评论
hugolin发表于 1年前
约束:
SELECT t.tabname, c.constrtype, c.constrname
FROM sysconstraints c, systables t
WHERE c.tabid = t.tabid;
P主键,U唯一,C检查,N非空,R外键
索引列:
select unique
t.tabname
, i.idxname
, i.idxtype
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part1)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part2)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part3)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part4)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part5)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part6)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part7)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part8)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part9)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part10)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part11)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part12)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part13)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part14)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part15)
, (select c.colname from syscolumns c where c.tabid = i.tabid and c.colno = i.part16)
from sysindexes i , systables t
where i.tabid = t.tabid;
最佳回答
用户头像
levvel发表于 9个月前
我看好你哟!