Informix数据表结构分析资料整理之约束查询代码
2011-03-23 15:58
645 查看
本文主要整理了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');
提示一: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');
相关文章推荐
- Informix数据表结构分析资料整理之约束查询代码
- Informix数据表结构分析资料整理之约束查询代码
- Informix数据表结构分析资料整理之约束查询代码
- 【转】Informix数据表结构分析资料整理之约束查询代码
- Informix数据表结构分析资料整理之约束查询代码
- Informix数据表结构分析资料整理之字段类型说明和查询SQL语句
- Informix数据表结构分析资料整理之字段类型说明和查询SQL语句
- Informix数据表结构分析资料整理之字段类型说明和查询SQL语句
- Informix数据表结构分析资料整理之字段类型说明和查询SQL语句
- Informix数据表结构分析资料整理之字段类型说明和查询SQL语句
- netlink监听网络变化代码(转载)+流程分析(原创+转载)+数据结构以及相关宏的解析(原创)
- 数据分析,数据挖掘相关资料整理(不断整理,追加中)
- 数据分析中非常实用的自编函数和代码模块整理
- 基于数据字典的通用查询系统(二)数据库组成结构的分析
- 【代码】PHP 分析查询MySQL大量数据的内存占用情况
- ElasticSearch 使用不同表结构存储时间序列数据的查询效率分析
- 按照网上的资料进行的百万级循环插入的效率分析循环插入数据库90万条数据的代码
- sql脚本查询数据库表,数据,结构,约束等操作的方法
- 恶意代码--样本分析学习资料整理网络地址