获取Gbase8s表或字段信息的一些建议

1.获取数据库表备注信息(后面的条件"a.tabauth = 'su-idx---' ''用来筛选出非系统表,但是不确定是否一定正确):

select t.tabname,c.comments from [数据库名].systables t inner join [数据库名].systabauth a on a.tabid = t.tabid left join [数据库名].syscomms c on c.tabid = t.tabid where a.tabauth = 'su-idx---'

2.获取表字段信息:

   a.先可以看库里面的视图,视图里面有部分sql语句提供了字段的一些信息:

获取Gbase8s表或字段信息的一些建议_第1张图片

  b.去系统表里面一张 一张的看:

  获取Gbase8s表或字段信息的一些建议_第2张图片

   c.我找到的一些表和信息:

select * from syscolumns

select * from syscolcomms

select * from syscoldepend

select * from sysconstraints
 
select * from sysxtdtypes
 
select * from sysseclabels
 
 
 select 
  c.colname as columnName,
  get_colname(c.coltype ,c.collength ,c.extended_id ,1 ) as dataType,
  cs.constrtype  as columnKey,
  c.collength as characterLength,
  '' as characterOctetLength,
  cc.comments as columnComment,
  c.colno as sortNo
 from 
 systables t
 left join syscolumns c on c.tabid = t.tabid
 left join syscolcomms cc on (t.tabid = cc.tabid and c.colno = cc.colno)
 left join sysdefaults d on (t.tabid = d.tabid and c.colno = d.colno)
 left join syscoldepend cd on (c.tabid = cd.tabid and c.colno = cd.colno)
 left join sysxtdtypes xt on c.extended_id = xt.extended_id
 left join sysseclabels e on c.seclabelid = e.seclabelid
 left join sysconstraints cs on (cd.tabid = cs.tabid and cd.constrid = cs.constrid  and cs.constrtype = 'P')
 where
  t.tabname = 'newtable_2'
  

你可能感兴趣的:(数据库,解决方案,sql,数据库)