Oracle 表结构、索引以及分区信息查询
Oracle 表结构、索引以及分区信息查询
/* 获取表:*/
select table_name from user_tables; --当前用户的表
select table_name from all_tables; --所有用户的表
select table_name from dba_tables; --包括系统表
--表字段信息
select * from all_tab_columns a where a.TABLE_NAME='T_X27_USER';
--表注释信息
select * from user_tab_comments a where a.table_name='T_X27_USER';
--表字段注释信息
select * from user_col_comments a where a.table_name='T_X27_USER';
--表分区信息
--1,分区表信息
-- (1)显示数据库所有分区表的信息
select * from DBA_PART_TABLES a where a.owner=upper('') and a.table_name=upper('');
-- (2)显示当前用户可访问的所有分区表信息
select * from ALL_PART_TABLES a where a.owner=upper('') and a.table_name=upper('');
-- (3)显示当前用户所有分区表的信息
select * from USER_PART_TABLES a where a.table_name=upper('');
--2,分区表的分区列信息
-- (1)显示当前用户所有分区表的分区列信息
select * from USER_PART_KEY_COLUMNS a where a.name=upper('') and a.object_type='TABLE';
-- (2)显示当前用户可访问的所有分区表的分区列信息
select * from ALL_PART_KEY_COLUMNS a where a.owner=upper('etl') and a.name=upper('') and a.object_type='TABLE';
--(3)显示分区列 显示数据库所有分区表的分区列信息
select * from DBA_PART_KEY_COLUMNS a where a.owner=upper('etl') and a.name=upper('') and a.object_type='TABLE';
-- 3,分区表的名字、归属表空间以及表的详细分区情况
select * from user_tab_partitions a where a.table_name=upper('');
-- 4,查看组合表的子分区信息以及子分区列信息情况
-- (1)显示当前用户所有组合分区表的子分区信息
select * from USER_TAB_SUBPARTITIONS;
-- (2)显示当前用户可访问的所有组合分区表的子分区信息
select * from ALL_TAB_SUBPARTITIONS;
-- (3)显示当前用户可访问的所有组合分区表的子分区信息
select * from ALL_TAB_SUBPARTITIONS ;
-- (4)显示当前用户所有分区表的子分区列信息
select * from USER_SUBPART_KEY_COLUMNS;
-- (5)显示当前用户可访问的所有分区表的子分区列信息
select * from ALL_SUBPART_KEY_COLUMNS;
-- (6)显示子分区列 显示数据库所有分区表的子分区列信息
select * from DBA_SUBPART_KEY_COLUMNS;
--表包含的索引
select * from user_indexes where table_name=upper('T_X27_USER');
--索引的具体信息:根据索引名查看索引包含的字段
select * from user_ind_columns where index_name = 'UK_T_X27_USER_USERID';
--表的唯一约束条件
select * from user_constraints where constraint_type='U' and owner='ETL' and table_name='T_X27_USER';
--表外键
select * from user_constraints where constraint_type='R' and owner='ETL' and table_name='T_X27_USER';
--表外键以及约束条件字段组成信息
select * from user_cons_columns where owner='ETL' and table_name='T_X27_USER';
示例(oracle查看表结构信息):
select a.owner 所属用户,
a.table_name 表名,
a.column_name 字段名,
a.data_type 字段类型,
a.字段长度,
a.字段精度,
a.是否为空,
a.创建日期,
a.最后修改日期,
case when a.owner=d.owner and a.table_name=d.table_name and a.column_name=d.column_name then '主键' else '' end 是否主键
from
(select a.owner,a.table_name,b.column_name,b.data_type,case when b.data_precision is null then b.data_length else data_precision end 字段长度,data_scale 字段精度,
decode(nullable,'Y','√','N','×') 是否为空,c.created 创建日期,c.last_ddl_time 最后修改日期
from all_tables a,all_tab_columns b,all_objects c
where a.table_name=b.table_name and a.owner=b.owner
and a.owner=c.owner
and a.table_name=c.object_name
and a.owner='SCOTT' --这个是查某个用户,你到时候把用户名换一下就好,一定大写
and c.object_type='TABLE') a
left join
(select a.owner,a.table_name,a.column_name,a.constraint_name from user_cons_columns a, user_constraints b
where a.constraint_name = b.constraint_name and b.constraint_type = 'P') d
on a.owner=d.owner and a.table_name=d.table_name and a.column_name=d.column_name
order by a.owner,a.table_name;
Oracle 表结构、索引以及分区信息查询的更多相关文章
- ORACLE表、索引和分区详解
ORACLE表.索引和分区 一.数据库表 每种类型的表都有不同的特性,分别应用与不同的领域 堆组织表 聚簇表(共三种) 索引组织表 嵌套表 临时表 外部表和对象表 1.行迁移 建表过程中可以指定以下两 ...
- oracle表结构和表内容差异比对
oracle表结构和表内容差异比对 oracle中有三种集合操作,他们会把左边和右边的select 结果集进行集合操作. union 并集 intersect 交集 minus 差集 假设有如下两张表 ...
- Sybase数据库收集表及其索引的统计信息
更新表及其索引的统计信息: update table statistics 表名 go update index statistics 表名 go 建议此操作在闲时操作.
- Oracle表与索引的分析及索引重建
1.分析表与索引(analyze 不会重建索引) analyze table tablename compute statistics 等同于 analyze table tablename co ...
- oracle表结构和表内容差异比对【原】
oracle表结构和表内容差异比对 oracle中有三种集合操作,他们会把左边和右边的select 结果集进行集合操作. union 并集 intersect 交集 minus 差集 假设有如下两张表 ...
- Oracle同义词、索引、分区
同义词:是现有对象的一个别名 简化SQL语句 隐藏对象的名称和所有者 提供对对象的公共访问 同义词共有两种类型 私有同义词只能在其模式内访问,且不能与当前模式的对象同名 公有同义词可被所有的数据库用户 ...
- mysql数据库性能优化(包括SQL,表结构,索引,缓存)
优化目标减少 IO 次数IO永远是数据库最容易瓶颈的地方,这是由数据库的职责所决定的,大部分数据库操作中超过90%的时间都是 IO 操作所占用的,减少 IO 次数是 SQL 优化中需要第一优先考虑,当 ...
- oracle表结构
表管理 新建表 语法 create table 表名 ( 列名1 类型(长度), 列名2 类型(长度), 列名3 类型(长度) ); create table:关键字,建表 后跟新建表的表名,表名长度 ...
- SOME:收缩数据库日志文件,查看表数据量和空间占用,查看表结构索引修改时间
---收缩数据库日志文件 USE [master]ALTER DATABASE yourdatabasename SET RECOVERY SIMPLE WITH NO_WAITALTER DATAB ...
随机推荐
- [ipsec][strongswan] strongswan源码分析--(一)SA整体分析
strongswan SA分析(一) 1 概念 下面主要介绍两个本文将要阐述的核心概念.他们是SA和SP.注意,这不是一篇不需要背景知识的文章.作者认为你适合阅读接下来内容的的前提是,你已经具备了一下 ...
- IAR为STM32创建工程模板(基于STM32f103zet6)
今天给小伙伴分享一篇给stm32新建工程模版 1.首先打开IAR,就是这个样子 2.再建一个目录文件夹 3.建立一个工作空间,以及建好工作空间如右图所示 4.接下来建立工程,Project------ ...
- (Linux基础学习)第七章:echo命令
第1节:简单说明功能:显示字符语法:echo [-neE][字符串]说明:echo会将输入的字符串送往标准输出.输出的字符串之间以空白字符隔开,并在最后加上换行号选项:-E(默认)不支持\解释功能-n ...
- destoon7.0后台栏目分类一键获取所有栏目拼音目录
近期研究DT,从DT4.0一直研究到DT7.0,总算也有些心得.最近重新开发设计了一个信息资讯站点:http://www.xuetong365.com/ 废话不多说,上教程 用于DESTOON7.0系 ...
- LeetCode 321. Create Maximum Number
原题链接在这里:https://leetcode.com/problems/create-maximum-number/description/ 题目: Given two arrays of len ...
- c# 异步方法中HttpContext.Current为空
调用异步方法前 HttpContext context = System.Web.HttpContext.Current; HttpRuntime.Cache.Insert("context ...
- The Last Goodbye 电影《霍比特人3:五军之战》插曲
https://music.163.com/#/song?id=29755223 I saw the light fade from the sky我看到天空褪去色彩On the wind I hea ...
- 【JS】基础知识
引言 在互联网的演化过程中,网页制作是Web1.0时代的产物,那时网站的主要内容都是静态的,用户使用网站的行为也以浏览为主. 2005年以后,互联网进入了Web2.0时代,各类似桌面软件的Web应用大 ...
- mysql bigint与bigint unsigned
-------------------------------以下是个人根据网上翻阅加个人理解总结结果------------------------------- mysql 表中数据类型和存储过程 ...
- [luogu 4719][模板]动态dp
传送门 Solution \(f_{i,0}\) 表示以i节点为根的子树内,不选i号节点的最大独立集 \(f_{i,1}\)表示以i节点为根的子树内,选i号节点的最大独立集 \(g_{i,0}\) 表 ...