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 ...
随机推荐
- Python如何打印文字对应的索引
用python编写一个简单的小程序:将文字对应的索引打印出来. test=input('>>>') print(test) l=len(test) print(l) r=range( ...
- sklearn 翻译笔记:KNeighborsClassifier
今天做机器学习knn的实现想使用sklearn这个模块,但是里面的函数不懂,无奈只能查文档,但是一大片英文看见我就烦,也不是说不能看 但是以我低下的英语水平实在是太费劲了.幸好找到一篇前人翻译的比较 ...
- Mongodb Sharding 集群配置
mongodb的sharding集群由以下3个服务组成: Shards Server: 每个shard由一个或多个mongod进程组成,用于存储数据 Config Server: 用于存储集群的M ...
- centos7安装nginx 并启动
原文连接 https://www.cnblogs.com/jerrypro/p/7062101.html 一.安装准备 首先由于nginx的一些模块依赖一些lib库,所以在安装nginx之前,必须先 ...
- python3 tkinter模块
一.tkinter 1.tkinter--tool kit interface工具包接口,用于GUI(Graphical User Interface)用户图形界面, 2.python3.x把Tkin ...
- Python3和Python2中 int 和 long的区别?
int(符号整数):通常被称为是整数或整数,没有小数点的正或负整数: long(长整数):无限大小的整数,这样写整数和一个大写或小写的L.
- LightOJ - 1259 - Goldbach`s Conjecture(整数分解定理)
链接: https://vjudge.net/problem/LightOJ-1259 题意: Goldbach's conjecture is one of the oldest unsolved ...
- 语法速学,返回数组 repeated修饰符
重新编写proto文件 syntax = "proto3"; package services; import "google/api/annotations.proto ...
- C# 避免程序重复启动
using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using ...
- [学习笔记]约数&欧拉函数
约数 一.概念 约数,又称因数.整数a除以整数b(b≠0) 除得的商正好是整数而没有余数,我们就说a能被b整除,或b能整除a.a称为b的倍数,b称为a的约数. 二.性质 1.整数唯一分解 1)定义 对 ...