本文主要整理了Informix數據庫相關係統表數據,已分析整個Informix數據表結構,同時方便代碼自動生成.
提示一:systables 存放Informix數據庫中所有數據表相關數據
提示二:sysconstraints 存放Informix數據庫中所有約束相關數據
--獲取所有用戶表的主鍵約束名稱
select a.tabname,b.constrname,b.* from systables a join sysconstraints b on a.tabid=b.tabid where a.tabid >99 and a.tabtype='T' and b.constrtype ='P' order by a.tabname
--獲取所有未設置主鍵的用戶數據表OK
Select * from systables a where tabid >99 and tabtype='T' and not exists (Select 1 from sysconstraints b where a.tabid=b.tabid and b.constrtype ='P');
--獲取所有用戶表的外鍵約束名稱
select a.tabname,b.constrname from systables a join sysconstraints b on a.tabid=b.tabid where a.tabid >99 and a.tabtype='T' and b.constrtype ='R' order by a.tabname
--獲取所有未設置外鍵約束的用戶數據表OK
Select * from systables a where tabid >99 and tabtype='T' and not exists (Select 1 from sysconstraints b where a.tabid=b.tabid and b.constrtype ='R');
--獲取所有用戶表的檢查約束名稱
select a.tabname,b.constrname from systables a join sysconstraints b on a.tabid=b.tabid where a.tabid >99 and a.tabtype='T' and b.constrtype ='C' order by a.tabname
--獲取所有未設置檢查約束的用戶數據表OK
Select * from systables a where tabid >99 and tabtype='T' and not exists (Select 1 from sysconstraints b where a.tabid=b.tabid and b.constrtype ='C');
--獲取所有用戶表的唯一約束名稱
select a.tabname,b.constrname from systables a join sysconstraints b on a.tabid=b.tabid where a.tabid >99 and a.tabtype='T' and b.constrtype ='U' order by a.tabname
--獲取所有未設置唯一約束的用戶數據表OK
Select * from systables a where tabid >99 and tabtype='T' and not exists (Select 1 from sysconstraints b where a.tabid=b.tabid and b.constrtype ='U');
--獲取所有用戶表的非空約束名稱
select a.tabname,b.constrname from systables a join sysconstraints b on a.tabid=b.tabid where a.tabid >99 and a.tabtype='T' and b.constrtype ='N' order by a.tabname
--獲取所有未設置非空約束的用戶數據表OK
Select * from systables a where tabid >99 and tabtype='T' and not exists (Select 1 from sysconstraints b where a.tabid=b.tabid and b.constrtype ='N');