2012-10-02 80 views
4

我用下面的查詢來獲取用戶定義的數據類型的列表(尿分流旱廁):如何獲取Sybase ASE上的用戶定義數據類型列表?

SELECT USER_NAME(S.uid) as owner, S.name as Name, T.name as datatypename, 
     OBJECT_NAME(S.domain), OBJECT_NAME(S.tdefault) 
FROM systypes S,systypes T 
WHERE S.type=T.type AND T.usertype<100 AND T.usertype NOT IN(18,24,25,80) AND S.usertype>100 
ORDER BY 1, 2 

基於Sybase 12.5,它用於返回每UDDT返回一行。現在與Sybase的15.x,則返回2行:

owner Name datatypename 
'dbo' 'auid' 'varchar' 
'dbo' 'auid' 'longsysname' 

的UDDT的數據類型實際上是varchar。我不確定longsysname是從哪裏來的。 返回可在12.5.x和15.x ASE數據庫中工作的UDDT列表的正確方法是什麼?

回答

6

試試此代碼:

select s1.name, 
     (select name 
     from systypes s2 
     where s2.usertype=(
          select min(s3.usertype) 
          from systypes s3 
          where s3.hierarchy=s1.hierarchy) 
     ) base_type, USER_NAME(s1.uid) as owner 
    from systypes s1 
    WHERE s1.usertype>100