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. ...
随机推荐
- javascript数组去重算法-----2
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 在自定义的js验证规则中调用magento的VarienForm方法验证表单
js部分<script type="text/javascript"> //<![CDATA[ var loginForm = new VarienForm('l ...
- Curious Robin Hood(树状数组+线段树)
1112 - Curious Robin Hood PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 64 ...
- 【Struts2学习笔记(1)】Struts2中Action名称的搜索顺序和多个Action共享一个视图--全局result配置
一.Action名称的搜索顺序 1.获得请求路径的URI,比如url是:http://server/struts2/path1/path2/path3/test.action 2.首先寻找namesp ...
- 【转】HtmlAgilityPack 之 HtmlNode类
[转]HtmlAgilityPack 之 HtmlNode类 HtmlAgilityPack中的HtmlNode类与XmlNode类差不多,提供的功能也大同小异.下面来看看该类提供功能. 一.静态属性 ...
- PHP自学2——将用户提交表单存储到外部普通文件中
在上一节中我们已经实现了将用户的订单信息提交到服务器端,然后服务器端将提交信息返回并显示到页面上.这一节将把上一节用户的订单信息保存到外部的普通文件中(即.txt文本文件中). 本节代码将用户提交的订 ...
- bootstrap-js(3)滚动监听
导航条实例 ScrollSpy插件根据滚动的位置自动更新导航条中相应的导航项. 拖动下面区域的滚动条,使其低于导航条的位置,注意观察active类的变化.下拉菜单中的子项也会跟着变为高亮状态. 1.调 ...
- 大表建立索引引发enq: TX - row lock contention等待
今天要给一张日志表(6000w数据)建立索引,导致生产系统行锁部分功能卡住 create index idx_tb_cid on tb_login_log(user_id); 开始执行后大概花费了20 ...
- poj2121--暴力解法
#include<iostream> #include<string> using namespace std; ]={"negative","z ...
- centos安装中文支持(转)
安装中文支持包. yum install fonts-chineseyum install fonts-ISO8859-2 -------- 一.安装中文支持方法1.在安装光盘中找到一下包进行安装.r ...