0

我想做一个选择语句,向我显示所选列的所有用户表、列、数据类型和数据长度。

我已经在 ASE 中完成了,但是 IQ 中的系统表不同,我无法加入必要的表来获得我的选择。在 ASE 中,代码如下所示:

select so.name as 'table name', sc.name as 'column name', st.name as 'data type', sc.length as 'data  length'    
from sysobjects so
inner join syscolumns sc on so.id = sc.id
inner join systypes st on sc.usertype = st.usertype
where so.type = 'U' 

我使用usertype作为加入键来获得我想要的东西,但是在 IQ 中syscolumnsystypes不能像那样加入,有人知道我怎样才能完成它吗?

4

1 回答 1

1
select
  t.table_name,
  c.column_name,
  d.domain_name,
  c.width,
  c.scale
FROM SYS.SYSTAB t
JOIN SYS.SYSCOLUMN c
  ON t.table_id = c.table_id
join SYS.SYSDOMAIN d
  on d.domain_id = c.domain_id
where t.creator <> 0 --sysobjects type 'S'
and not exists (select * from sys.systab tv 
                where tv.creator in (2, 22) 
                and tv.table_id = t.table_id) --2/22 sysobjects type 'V'
于 2014-10-08T17:33:28.913 回答