Oracle系统视图归纳总结及常用对象查询语句

文章目录

  • 一、Oracle系统视图归纳总结
    • [1.1 常用系统视图](#1.1 常用系统视图)
  • 二、常用查询语句
    • [2.1 查询表、表字段、视图、序列、存储过程、索引等数据库对象信息](#2.1 查询表、表字段、视图、序列、存储过程、索引等数据库对象信息)
    • [2.2 查询会话、动态性能视图](#2.2 查询会话、动态性能视图)

一、Oracle系统视图归纳总结

Oracle 19C有2067个系统视图,但只有部分常用视图在运维或查问题中会使用到,我们可以将注意力放在常用系统视图上。(实际上我们在接触任何数据库时,都需要学习常用系统视图)

Oracle系统视图主要分为4类:

1. DBA_ * 表示DBA拥有的或可访问的所有对象
2. ALL_ * 表示某用户拥有的或可访问的所有对象
3. USER_ * 表示某用户拥有的所有对象
4. V$* 动态性能视图

1.1 常用系统视图

序号 视图
1 *_TAB_COLUMNS
2 *_TAB_COLS
3 *_TAB_PARTITIONS
4 *_PART_TABLES
5 *_TAB_SUBPARYITIONS
6 *_TABLES
7 *_INDEXS
8 *_IND_PARTITIONS
9 *_IND_EXPRESSIONS
10 *_IND_COLUMNS
11 *_SOURCE
12 *_CONSTRAINTS
13 *_CONS_COLUMNS
14 *_COL_COMMENTS
15 *_TAB_COMMENTS
16 *_OBJECTS
17 *_DIRECTORIES
18 *_TABLESPACES
19 *_SCHEDULER_JOBS
20 *_PROCEDURES
21 *_SEQUENCES
22 *_JOBS
23 *_TYPE_ATTRS
24 *_USERS
25 *_TRIGGERS
26 *_IND_SUBPARTITIONS
27 *_SYNONYMS
28 *_ARGUMENTS
29 *_PART_INDEXS
30 *_VIEWS
31 *_LOBS
32 *_SEGMENTS
33 VINSTANCE/GVINSTANCE
34 V$SESSION
35 V$DATABASE
36 V$MYSTAT

二、常用查询语句

2.1 查询表、表字段、视图、序列、存储过程、索引等数据库对象信息

sql 复制代码
select table_name from user_tables;
select * from user_sequences;
select * from user_synonyms;
select * from user_triggers;
select * from user_source;
查询数据库对象
select * from user_objects;
select object_name,procedure_name,object_type from user_procedures where object_type= 'PACKAGE' order by 1,2;
select object_name,procedure_name,object_type from user_procedures where object_type= 'PROCEDURE' order by 1,2;
select object_name,procedure_name,object_type from user_procedures where object_type= 'FUNCTION' order by 1,2;
select view_name from user_views;
查询索引信息
select table_owner,table_name,index_name,uniqueness,partitined,status from user_index where index_type <> 'LOB' order by table_name;
查询表字段信息
select table_name,column_name,data_type from user_tab_cols order by table_name,column_id;
查询视图字段信息
select table_name,column_name,data_type,data_length from user_tab_columns order by table_name,column_id;
查询分区表
select table_name,partition_name,high_value from user_tab_partitions order by table_name;

2.2 查询会话、动态性能视图

sql 复制代码
查询当前实例状态
select INSTANCE_NUMBER,INSTANCE_NAME,HOST_NAME,VERSION,STARTUP_TIME.STATUS FROM v$instance;
查询当前每个会话的会话信息
select $ADDR,SID,SERIAL#,AUDSID,USERNAME,OSUSER,MACHINE,PROHRAM,PREV_SQL_ADDR,PREV_HASH_VALUE from v$session where user='XXX';
查询当前会话的统计信息
select sid from V$MYSTAT where ROWNUM=1;
相关推荐
RestCloud1 天前
SQL Server到Hive:批处理ETL性能提升30%的实战经验
数据库·api
RestCloud1 天前
为什么说零代码 ETL 是未来趋势?
数据库·api
ClouGence1 天前
CloudCanal + Paimon + SelectDB 从 0 到 1 构建实时湖仓
数据库
DemonAvenger1 天前
NoSQL与MySQL混合架构设计:从入门到实战的最佳实践
数据库·mysql·性能优化
AAA修煤气灶刘哥2 天前
后端人速藏!数据库PD建模避坑指南
数据库·后端·mysql
RestCloud2 天前
揭秘 CDC 技术:让数据库同步快人一步
数据库·api
得物技术2 天前
MySQL单表为何别超2000万行?揭秘B+树与16KB页的生死博弈|得物技术
数据库·后端·mysql
可涵不会debug2 天前
【IoTDB】时序数据库选型指南:工业大数据场景下的技术突围
数据库·时序数据库
ByteBlossom2 天前
MySQL 面试场景题之如何处理 BLOB 和CLOB 数据类型?
数据库·mysql·面试
麦兜*2 天前
MongoDB Atlas 云数据库实战:从零搭建全球多节点集群
java·数据库·spring boot·mongodb·spring·spring cloud