Oracle查询表结构的常用语句
1. 查询表结构基本信息
|
select * from user_tables t,user_tab_comments c where c.table_name = t.table_name and t.table_name = '表名' |
2. 查询表的所有列及其属性
|
select t.COLUMN_NAME, t.DATA_TYPE, t.DATA_LENGTH, t.DATA_PRECISION, t.NULLABLE, t.COLUMN_ID, c.COMMENTS from user_tab_columns t, user_col_comments c where t.table_name = c.table_name and t.column_name = c.column_name and t.table_name = '表名' order by t.COLUMN_ID ; |
3 . 查找表的主键(包括名称,构成列)
|
select cu.*,c.DATA_TYPE from user_cons_columns cu, user_constraints au,user_tab_columns c where cu.constraint_name = au.constraint_name and c.COLUMN_NAME = cu.column_name and c.TABLE_NAME = cu.table_name and au.constraint_type = 'P' and au.table_name = '表名' |
4 . 查找表的所有索引(包括索引名,类型,构成列)
|
select t.*, i.index_type from user_ind_columns t, user_indexes i where t.index_name = i.index_name and t.table_name = i.table_name and t.table_name = '表名' |
5.查找表的唯一性约束(包括名称,构成列)
|
select column_name from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and au.constraint_type = 'U' and au.table_name = '表名' |
6. 查找表的外键(包括名称,引用表的表名和对应的键名,下面是分成多步查询)
|
select * from user_constraints c where c.constraint_type = 'R' and c.table_name = '表名' |
7. 查询外键约束的列名
|
select * from user_cons_columns cl where cl.constraint_name = '外键名称' |
8.查询引用表的键的列名
|
select * from user_cons_columns cl where cl.constraint_name = '外键引用表的键名' |
Oracle查询表结构的常用语句的更多相关文章
- <经验杂谈>查询表结构的SQL语句
在我们使用SQL数据库的过程中,经常会遇到查询表结构的情况,以下就是sql语句的写法: --查询非系统数据库 SELECT name FROM Master..SysDatabases 查询数据库下所 ...
- oracle查询表结构语句
select o.table_name, tmp.comments, o.COLUMN_NAME, t.comments, o.DATA_TYPE || CASE TRIM(o.DATA_TYPE) ...
- Oracle 11g的一些常用语句记录
一.表空间 1.创建临时表空间: create temporary tablespace project_temp tempfile 'D:\Oracle\dataspace\project_temp ...
- oracle 11g调优常用语句
1.查询表的基数及选择性 select a.column_name, b.num_rows, a.num_distinct cardinality, round( ...
- oracle 查询表结构
SELECT t1.Table_Name AS "表名称", t3.comments AS "表说明", t1.Column_Name AS "字段名 ...
- 记工作中用到的抓取oracle表结构的sql语句
以下是SQL,生成的结果中是否为主键和是否可为空,是不准确的 ,没有关联相关的系统表: select '' as 业务源系统, t2.TABLE_NAME 表名称, nvl(t3.comments,' ...
- MySQL查询表结构的SQL语句
desc 数据库.表名; eg: desc mysql.user;
- 导出ORACLE表结构到SQL语句(含CLOB)
转自:http://blog.itpub.net/84738/viewspace-442854/ 先用exp导出空表 exp username/password rows=n file=expor ...
- Oracle使用——PLSQL查询表结构并导出EXCEL
背景 有一次需要查询Oracle数据库中的所有表接口并且导出excel,方法记录如下 使用 使用PLSQL工具查询表结构,SQL语句如下 SELECT B.TABLE_NAME AS '表名', C. ...
随机推荐
- ubuntu下perl SVG老是make失败
解决方法是用libgd-svg-perl软件包代替.
- 关于用exec来执行存储过程中,参数带有引号的解决方法
比如:exec 存储过程名 要带有引号的参数 这样写的时候是传不进引号的,可以选定一种字符来表示引号,在存储过程中再进行转换: @test=replace(replace(@test,char(39) ...
- jQuery源码笔记——四
each()实现 var jQuery = function( selector, context ) { return new jQuery.fn.init( selector, context ) ...
- thinkphp 查询
一.普通查询方式 a.字符串 $arr=$m->where("sex=0 and username='gege'")->find(); b.数组 $data['sex' ...
- 在什么情况下使用exist和in
http://www.itpub.net/thread-406784-4-1.htmlYou Asked (Jump to Tom's latest followup) Tom: can you gi ...
- Android 支付宝接入时常见的问题
1.概述 首先说明下,Android支付宝接入用的是快捷支付,下载地址是https://b.alipay.com/order/techService.htm 支付宝移动接入地址https://b ...
- 关于智能指针auto_ptr
智能指针auto_ptr和shared_ptr也是面试中经常被问到的一个 感觉看auto_ptr的源码反而更加容易理解一些,因为源码的代码量并不大,而且比较容易理解. 本篇主要介绍auto_ptr 其 ...
- 解压tomcat后一闪而过的问题
解压tomcat压缩包后,直接点击startup会出现一闪而过. 免安装的tomcat双击startup.bat后,启动窗口一闪而过,而且tomcat服务未启动. 原因是:在启动tomcat是,需要读 ...
- java.util.Random 类的 nextInt(int num )
随机产生3个67~295的整数并找出数值居中的数 并输出中间的数例如:100,225和200,输出200 要随机产生某个范围内的整数,用 java.util.Random 类的 nextInt(int ...
- UIKit之浅析UIButton
UIButton * button =[[UIButton alloc]init]; button.backgroundColor=[UIColor redColor]; [button setTit ...