【转】Informix数据表结构分析资料整理之约束查询代码
2016-04-15 18:00
691 查看
原文地址:http://blog.csdn.net/xqf222/article/details/6271219
本文主要整理了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');
本文主要整理了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');
相关文章推荐
- 基于Activiti5工作流实战企业协同OA办公系统(spring-data-jpa、uur前台组件)
- C#时间格式化(Datetime)用法详解
- java持久层框架mybatis如何防止sql注入
- oj--C++结构体之统计最高最低分
- HM编码器代码阅读(17)——帧间预测之一merge模式
- cuda并行编程之求解ConjugateGradient(共轭梯度迭代)丢失dll解决方式
- PHP - 抓取电视剧资源
- java 调用Quartz 不同版本使用分析 1.6x 、1.7x、1.8x
- Java第五次作业
- Python开源框架对比
- php伪装客户IP采集
- golang优秀实用开源项目收集
- yii执行流程
- jasperreport position type 详解
- Java核心技术点之动态代理
- C#调用webService的几种方法
- C++和C语言的区别
- java持久层框架mybatis如何防止sql注入
- Python正则表达式指南
- qt3d中基于opengles编写shader