Oracle中查询表字段基本信息、主键、外键
来源:互联网 发布:matlab给二维数组赋值 编辑:程序博客网 时间:2024/05/29 06:30
因为项目某些模块的数据结构设计没有严格按照某规范设计,所以只能从数据库中查询数据结构,需要查询的信息如下:字段名称、数据类型、是否为空、默认值、主键、外键等等。
在网上搜索了查询上述信息的方法,总结如下:
一,查询表基本信息
select
utc.column_name,utc.data_type,utc.data_length,utc.data_precision,
utc.data_Scale,utc.nullable,utc.data_default,ucc.comments
from
user_tab_columns utc,user_col_comments ucc
where
utc.table_name = ucc.table_name
and utc.column_name = ucc.column_name
and utc.table_name = 'ONLINEXLS'
order by
column_id
注意:order by column_id的意义是使得结果按照设计数据结构时的顺序显示。
二,查询表主键
select
col.column_name
from
user_constraints con,user_cons_columns col
where
con.constraint_name=col.constraint_name and con.constraint_type='P'
and col.table_name='ONLINEXLS'
三,查询表外键
select
distinct(ucc.column_name) column_name,rela.table_name,rela.column_name column_name1
from
user_constraints uc,user_cons_columns ucc,
(select t2.table_name,t2.column_name,t1.r_constraint_name from user_constraints t1,user_cons_columns t2 where t1.r_constraint_name=t2.constraint_name and t1.table_name='ONLINEXLS') rela
where
uc.constraint_name=ucc.constraint_name
and uc.r_constraint_name=rela.r_constraint_name
and uc.table_name='ONLINEXLS'
有了上述几个SQL语句,再结合程序(如:java+jxl),就可以输出如下图所示的Excel报表了。
- Oracle中查询表字段基本信息、主键、外键
- Oracle中查询表字段基本信息、主键、外键(整理)
- Oracle中查询主键、外键、sequence、表基本信息
- Oracle中查询主键、外键、sequence、表基本信息等
- Oracle中查询主键、外键、sequence、表基本信息等
- 查询表字段信息 查询表主键
- 查询oracle表字段信息
- oracle数据库查询表字段
- oracle查询表字段个数
- ORACLE 中查询表字段信息的方法
- ORACLE 中查询表字段信息的方法
- ORACLE 中查询表字段信息的方法
- Oracle 查询表字段属性的方法
- oracle查询表字段以及所有表
- oracle查询表字段信息(包含注释)
- oracle根据表明查询表字段结构
- Oracle查询表字段和类型
- MSSQL,查询用户表字段(主键及标识)
- JPEG转为DICOM文件
- 取Oracle_表名_字段名_注释等实用语句
- 关于outline的一点测试和总结
- [Android]Android Sqlite3 常用命令
- 公式化描述
- Oracle中查询表字段基本信息、主键、外键
- ++i在C、C++中是不是左值?
- 获取ORACLE 表字段,表名,以及主键之类等等的信息
- oracle 查询表字段明细、字段注释、表注释
- 程序员常犯的5个非技术性错误
- 循环双向链表类
- 如何在windows下运用dd来下修复坏块?
- 11gR2 新特性之(一)Adaptive Cursor Sharing(ACS)
- 让Ogre支持中文路径与中文文件名