Oracle11g温习-第五章:数据字典
1、数据字典(Data dictionary)的功能 |
||
1) central of oracle database 每个oracle数据库的核心 2) describes the databases and its objects 描述 数据库和 它所有的对象 3) contains read_only table and views 包括只读的表和视图 4) owner :sys sys独有 5) oracle server 维护,ddl操作会更新数据字典 6) 通过select 访问 7) 记录数据库的物理、逻辑结构和所有对象的定义的信息 8) 存放在system tablesapce |
||
2、数据字典的组成 |
||
基表-------------------------------视图--------------同义词-------User access (x$) (全局用于集群) dba_XXX (_$) all_XXX user_XXX ---可以通过trace 查看所使用的基表 |
||
3、数据字典的内容 |
||
1) 数据库的逻辑和物理的架构 2) 用户及对象的定义和存储信息 3) 权限、角色、审计等 4) database的状态 |
||
4、数据字典分类 |
||
静态(static) 和动态(dynami)---------------------(通过dict查看所有的数据字典的视图) static :在数据库open状态下访问,可以通过静态视图了解database的架构(记录database的架构,object的数据定义和存储等信息)
DYNAMIC: 反映数据库当前的状态,从控制文件和内存中读出(v$视图),可以通过v$fixed_table 这个视图查到所有的动态视图的名称; 用于调优和数据库监控 v$多用于单机,GV$全局的,多用于集群环境 V$CONTROLFILE V$DATABASE V$DATAFILE SYS @ prod >desc v$fixed_table; Name Null? Type ----------------------------------------- -------- ---------------------------- NAME VARCHAR2(30) OBJECT_ID NUMBER TYPE VARCHAR2(5) TABLE_NUM NUMBER SYS @ prod >select name,object_id,type from v$fixed_table where rownum<6; NAME OBJECT_ID TYPE ------------------------------ ---------- ----- X$KQFTA 4294950912 TABLE X$KQFVI 4294950913 TABLE X$KQFVT 4294951149 TABLE X$KQFDT 4294950914 TABLE X$KQFCO 4294951036 TABLE SYS @ prod >select name from v$datafile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/prod/system01.dbf /u01/app/oracle/oradata/prod/undotbs01.dbf /u01/app/oracle/oradata/prod/sysaux01.dbf /u01/app/oracle/oradata/prod/users01.dbf /u01/app/oracle/oradata/prod/test01.dbf /u01/app/oracle/oradata/prod/test02.dbf /u01/app/oracle/oradata/prod/test04.dbf V$INSTANCE V$PARAMETER V$SESSION V$SGA V$SPPARAMETER V$TABLESPACE V$THREAD V$VERSION V$TRANSACTION V$SQLTEXT(查看SQL语句的详细内容) SQL> select USERNAME,SID,serial# from v$session where username is not null; ——查看当前会话信息 USERNAME SID SERIAL# --------------- ---------- ---------- SYS 39 1 SCOTT 37 3 SQL> conn scott/tiger SCOTT @ prod >update emp set sal=sal/1 ;【用其他会话进行事物处理】 SQL> SELECT A.USERNAME,B.STATUS FROM V$SESSION A,V$TRANSACTION B WHERE A.SADDR =B.SES_ADDR; ——联合V$SESSION、V$TRANSACTION查看事务处理状态 USERNAME STATUS --------------- ------------------------------------------------ SCOTT ACTIVE SQL> SELECT A.USERNAME,B.STATUS,c.sql_text FROM V$SESSION A,V$TRANSACTION B,v$sqltext c where a.saddr=b.ses_addr and a.prev_sql_id=c.sql_id and a.username='SCOTT'; ——联合三个视图来查询 USERNAME STATUS SQL_TEXT ------------------------------ ---------------- -------------------------------------------------- SCOTT ACTIVE update emp set sal=sal/1 |
SYS@ prod> Desc dict 查看数据字典 SYS@ prod>select table_name from dict where table_name like '%INDEX%'; TABLE_NAME ------------------------------ USER_INDEXES ALL_INDEXES DBA_INDEXES DBA_INDEXTYPES USER_INDEXTYPES ALL_INDEXTYPES DBA_INDEXTYPE_COMMENTS USER_INDEXTYPE_COMMENTS ALL_INDEXTYPE_COMMENTS DBA_INDEXTYPE_ARRAYTYPES USER_INDEXTYPE_ARRAYTYPES ALL_INDEXTYPE_ARRAYTYPES DBA_INDEXTYPE_OPERATORS USER_INDEXTYPE_OPERATORS ALL_INDEXTYPE_OPERATORS USER_PART_INDEXES ALL_PART_INDEXES DBA_PART_INDEXES DBA_XML_INDEXES ALL_XML_INDEXES USER_XML_INDEXES INDEX_HISTOGRAM INDEX_STATS V$INDEXED_FIXED_COLUMN GV$INDEXED_FIXED_COLUMN |
查找列的注释 数据字典dict_columns SYS@ prod>desc dict_columns; Name Type Null? ------------------------------------------------------------------------------------------------------------- TABLE_NAME VARCHAR2(30) COLUMN_NAME VARCHAR2(30) COMMENTS VARCHAR2(4000) SYS@ prod>select column_name,comments from dict_columns where table_name='DBA_TABLES'; COLUMN_NAME COMMENTS ------------------------------ -------------------------------------------------- BUFFER_POOL The default buffer pool to be used for table blocks ROW_MOVEMENT Whether partitioned row movement is enabled or disabled GLOBAL_STATS Are the statistics calculated without merging underlying partitions? USER_STATS Were the statistics entered directly by the user? DURATION If temporary table, then duration is sys$session or sys$transaction else NULL SKIP_CORRUPT Whether skip corrupt blocks is enabled or disabled MONITORING Should we keep track of the amount of modification? CLUSTER_OWNER Owner of the cluster, if any, to which the table belongs DEPENDENCIES Should we keep track of row level dependencies? COMPRESSION Whether table compression is enabled or not DROPPED Whether table is dropped and is in Recycle Bin OWNER Owner of the table TABLE_NAME Name of the table TABLESPACE_NAME Name of the tablespace containing the table CLUSTER_NAME Name of the cluster, if any, to which the table belongs IOT_NAME Name of the index-only table, if any, to which the overflow or mapping table entry belongs STATUS Status of the table will be UNUSABLE if a previous DROP TABLE operation failed, VALID otherwise PCT_FREE Minimum percentage of free space in a block PCT_USED Minimum percentage of used space in a block INI_TRANS Initial number of transactions MAX_TRANS Maximum number of transactions INITIAL_EXTENT Size of the initial extent in bytes NEXT_EXTENT Size of secondary extents in bytes MIN_EXTENTS Minimum number of extents allowed in the segment MAX_EXTENTS Maximum number of extents allowed in the segment PCT_INCREASE Percentage increase in extent size FREELISTS Number of process freelists allocated in this segment FREELIST_GROUPS Number of freelist groups allocated in this segment LOGGING Logging attribute BACKED_UP Has table been backed up since last modification? NUM_ROWS The number of rows in the table BLOCKS The number of used blocks in the table EMPTY_BLOCKS The number of empty (never used) blocks in the table AVG_SPACE The average available free space in the table CHAIN_CNT The number of chained rows in the table AVG_ROW_LEN The average row length, including row overhead AVG_SPACE_FREELIST_BLOCKS The average freespace of all blocks on a freelist NUM_FREELIST_BLOCKS The number of blocks on the freelist DEGREE The number of threads per instance for scanning the table INSTANCES The number of instances across which the table isto be scanned CACHE Whether the table is to be cached in the buffer cache TABLE_LOCK Whether table locking is enabled or disabled SAMPLE_SIZE The sample size used in analyzing this table LAST_ANALYZED The date of the most recent time this table was analyzed PARTITIONED Is this table partitioned? YES or NO IOT_TYPE If index-only table, then IOT_TYPE is IOT or IOT_OVERFLOW or IOT_MAPPING else NULL TEMPORARY Can the current session only see data that it place in this object itself? SECONDARY Is this table object created as part of icreate for domain indexes? NESTED Is the table a nested table? |
ORACLE 存放数据都是以段的形式存放的
SYS@ prod>desc dba_segments; Name Null? Type ----------------------------------------------------------------------------------------------------------------- -------- ---------------------------------------------------------------------------- OWNER VARCHAR2(30) SEGMENT_NAME VARCHAR2(81) PARTITION_NAME VARCHAR2(30) SEGMENT_TYPE VARCHAR2(18) TABLESPACE_NAME VARCHAR2(30) HEADER_FILE NUMBER HEADER_BLOCK NUMBER BYTES NUMBER BLOCKS NUMBER EXTENTS NUMBER INITIAL_EXTENT NUMBER NEXT_EXTENT NUMBER MIN_EXTENTS NUMBER MAX_EXTENTS NUMBER PCT_INCREASE NUMBER FREELISTS NUMBER FREELIST_GROUPS NUMBER RELATIVE_FNO NUMBER BUFFER_POOL VARCHAR2(7) SYS@ prod>select bytes,blocks,extents,header_file,header_block,tablespace_name from dba_segments where owner='SCOTT' and segment_name='EMP'; BYTES BLOCKS EXTENTS HEADER_FILE HEADER_BLOCK TABLESPACE_NAME ---------- ---------- ---------- ----------- ------------ ------------------------------ 65536 8 1 4 27 USERS 查看 表的大小 系统为 emp 这张表 分配了64K的存储空间 1个区 8个块 段头在第4个文件 第27个数据块 |
SYS@ prod>desc dba_extents;
Name Null? Type
----------------------------------------------------------------------------------------------------------------- -------- ----------------------------------------------------------------------------
OWNER VARCHAR2(30)
SEGMENT_NAME VARCHAR2(81)
PARTITION_NAME VARCHAR2(30)
SEGMENT_TYPE VARCHAR2(18)
TABLESPACE_NAME VARCHAR2(30)
EXTENT_ID NUMBER
FILE_ID NUMBER
BLOCK_ID NUMBER
BYTES NUMBER
BLOCKS NUMBER
RELATIVE_FNO NUMBER
SYS@ prod>select file_id,block_id ,blocks from dba_extents where owner='SCOTT' and segment_name='EMP';
FILE_ID BLOCK_ID BLOCKS
---------- ---------- ----------
4 25 8
SCOTT@ prod>select rowid from emp;
ROWID
------------------
AAAMfMAAEAAAAAgAAA
AAAMfMAAEAAAAAgAAB
AAAMfMAAEAAAAAgAAC
AAAMfMAAEAAAAAgAAD
AAAMfMAAEAAAAAgAAE
AAAMfMAAEAAAAAgAAF
AAAMfMAAEAAAAAgAAG
AAAMfMAAEAAAAAgAAH
AAAMfMAAEAAAAAgAAI
AAAMfMAAEAAAAAgAAJ
AAAMfMAAEAAAAAgAAK
AAAMfMAAEAAAAAgAAL
AAAMfMAAEAAAAAgAAM
AAAMfMAAEAAAAAgAAN
SYS@ prod>desc dba_tablespaces;
Name Null? Type
----------------------------------------------------------------- -------- --------------------------------------------
TABLESPACE_NAME NOT NULL VARCHAR2(30)
BLOCK_SIZE NOT NULL NUMBER
INITIAL_EXTENT NUMBER
NEXT_EXTENT NUMBER
MIN_EXTENTS NOT NULL NUMBER
MAX_EXTENTS NUMBER
PCT_INCREASE NUMBER
MIN_EXTLEN NUMBER
STATUS VARCHAR2(9)
CONTENTS VARCHAR2(9)
LOGGING VARCHAR2(9)
FORCE_LOGGING VARCHAR2(3)
EXTENT_MANAGEMENT VARCHAR2(10)
ALLOCATION_TYPE VARCHAR2(9)
PLUGGED_IN VARCHAR2(3)
SEGMENT_SPACE_MANAGEMENT VARCHAR2(6)
DEF_TAB_COMPRESSION VARCHAR2(8)
RETENTION VARCHAR2(11)
BIGFILE VARCHAR2(3)
SYS@ prod>select tablespace_name,block_size,status ,logging from dba_tablespaces;
TABLESPACE_NAME BLOCK_SIZE STATUS LOGGING 修改数据 是否会产生日志
------------------------------ ---------- --------- ---------
SYSTEM 8192 ONLINE LOGGING
UNDOTBS1 8192 ONLINE LOGGING
SYSAUX 8192 ONLINE LOGGING
TEMP 8192 ONLINE NOLOGGING
USERS 8192 ONLINE LOGGING
EXAMPLE 8192 ONLINE NOLOGGING
动态性能视图
虚拟的表 记录当前数据库的统计信息 操作 当数据库被修改的时候 记录操作信息 从控制文件和内存收集信息 Sys 用户独有 v$开头的同义词 v$_ gv$_ 开头的都是视图 |
SYS@ prod>desc v_$log; 此乃 基表
Name Null? Type
----------------------------------------------------------------- -------- --------------------------------------------
GROUP# NUMBER
THREAD# NUMBER
SEQUENCE# NUMBER
BYTES NUMBER
MEMBERS NUMBER
ARCHIVED VARCHAR2(3)
STATUS VARCHAR2(16)
FIRST_CHANGE# NUMBER
FIRST_TIME DATE
SYS@ prod>desc v$log; 此乃对应的 视图
Name Null? Type
----------------------------------------------------------------- -------- --------------------------------------------
GROUP# NUMBER
THREAD# NUMBER
SEQUENCE# NUMBER
BYTES NUMBER
MEMBERS NUMBER
ARCHIVED VARCHAR2(3)
STATUS VARCHAR2(16)
FIRST_CHANGE# NUMBER
FIRST_TIME DATE
以下视图同上
V$controlfile
V$datafile
V$database
V$instance
V$parameter
V$session
V$sga
SYS@ prod>Show parameter cache;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_16k_cache_size big integer 0
db_2k_cache_size big integer 0
db_32k_cache_size big integer 0
db_4k_cache_size big integer 0
db_8k_cache_size big integer 0
db_cache_advice string ON
db_cache_size big integer 0
db_keep_cache_size big integer 0
db_recycle_cache_size big integer 0
object_cache_max_size_percent integer 10
object_cache_optimal_size integer 102400
session_cached_cursors integer 20
SYS@ prod>desc v$parameter;
Name Null? Type
----------------------------------------------------------------- -------- --------------------------------------------
NUM NUMBER
NAME VARCHAR2(80)
TYPE NUMBER
VALUE VARCHAR2(512)
DISPLAY_VALUE VARCHAR2(512)
ISDEFAULT VARCHAR2(9)
ISSES_MODIFIABLE VARCHAR2(5)
ISSYS_MODIFIABLE VARCHAR2(9)
ISINSTANCE_MODIFIABLE VARCHAR2(5)
ISMODIFIED VARCHAR2(10)
ISADJUSTED VARCHAR2(5)
ISDEPRECATED VARCHAR2(5)
DESCRIPTION VARCHAR2(255)
UPDATE_COMMENT VARCHAR2(255)
HASH NUMBER
SYS @ prod >desc v$session;
Name Null? Type
----------------------------------------------------------------- -------- --------------------------------------------
SADDR RAW(4)
SID NUMBER
SERIAL# NUMBER
AUDSID NUMBER
PADDR RAW(4)
USER# NUMBER
USERNAME VARCHAR2(30)
COMMAND NUMBER
OWNERID NUMBER
TADDR VARCHAR2(8)
LOCKWAIT VARCHAR2(8)
STATUS VARCHAR2(8)
SERVER VARCHAR2(9)
SCHEMA# NUMBER
SCHEMANAME VARCHAR2(30)
OSUSER VARCHAR2(30)
PROCESS VARCHAR2(12)
MACHINE VARCHAR2(64)
TERMINAL VARCHAR2(30)
PROGRAM VARCHAR2(48)
TYPE VARCHAR2(10)
SQL_ADDRESS RAW(4)
SQL_HASH_VALUE NUMBER
SQL_ID VARCHAR2(13)
SQL_CHILD_NUMBER NUMBER
PREV_SQL_ADDR RAW(4)
PREV_HASH_VALUE NUMBER
PREV_SQL_ID VARCHAR2(13)
PREV_CHILD_NUMBER NUMBER
MODULE VARCHAR2(48)
MODULE_HASH NUMBER
ACTION VARCHAR2(32)
ACTION_HASH NUMBER
CLIENT_INFO VARCHAR2(64)
FIXED_TABLE_SEQUENCE NUMBER
ROW_WAIT_OBJ# NUMBER
ROW_WAIT_FILE# NUMBER
ROW_WAIT_BLOCK# NUMBER
ROW_WAIT_ROW# NUMBER
LOGON_TIME DATE
LAST_CALL_ET NUMBER
PDML_ENABLED VARCHAR2(3)
FAILOVER_TYPE VARCHAR2(13)
FAILOVER_METHOD VARCHAR2(10)
FAILED_OVER VARCHAR2(3)
RESOURCE_CONSUMER_GROUP VARCHAR2(32)
PDML_STATUS VARCHAR2(8)
PDDL_STATUS VARCHAR2(8)
PQ_STATUS VARCHAR2(8)
CURRENT_QUEUE_DURATION NUMBER
CLIENT_IDENTIFIER VARCHAR2(64)
BLOCKING_SESSION_STATUS VARCHAR2(11)
BLOCKING_INSTANCE NUMBER
BLOCKING_SESSION NUMBER
SEQ# NUMBER
EVENT# NUMBER
EVENT VARCHAR2(64)
P1TEXT VARCHAR2(64)
P1 NUMBER
P1RAW RAW(4)
P2TEXT VARCHAR2(64)
P2 NUMBER
P2RAW RAW(4)
P3TEXT VARCHAR2(64)
P3 NUMBER
P3RAW RAW(4)
WAIT_CLASS_ID NUMBER
WAIT_CLASS# NUMBER
WAIT_CLASS VARCHAR2(64)
WAIT_TIME NUMBER
SECONDS_IN_WAIT NUMBER
STATE VARCHAR2(19)
SERVICE_NAME VARCHAR2(64)
SQL_TRACE VARCHAR2(8)
SQL_TRACE_WAITS VARCHAR2(5)
SQL_TRACE_BINDS VARCHAR2(5)
Oracle11g温习-第五章:数据字典的更多相关文章
- Oracle11g温习-第十七章:权限管理
2013年4月27日 星期六 10:50 1.权限(privilege): [system privilege(系统权限):针对于database 的相关权限 object p ...
- Oracle11g温习-第七章:redo日志
2013年4月27日 星期六 10:33 1.redo (重做) log 的功能: 用于数据恢复 2.redo log 特征: [特征]: 1) 记录数据块的变化(DML.D ...
- Oracle11g温习-第四章:手工建库
1.create database plan 1.库类型: OLTP : 在线事务处理系统 OLAP : 在线应用处理系统 DSS : 数据决策系统 2.数据库名字及字符集 3. ...
- Oracle11g温习-第十三章:索引
2013年4月27日 星期六 10:46 1.索引(Index)的功能:对记录进行排序,加快表的查询速度 2.索引的分类 1)B-tree 索引(默认) a.在一个大表上 b.建立在重复值比较少的 ...
- Oracle11g温习-第十一章:管理undo
2013年4月27日 星期六 10:40 1.undo tablespace 功能 undo tablespace 功能:用来存放从datafiles 读出的数据块旧的镜像 [ ...
- Oracle11g温习-第六章:控制文件
2013年4月27日 星期六 10:33 .控制文件的功能和特点 1) [定义数据库当前物理状态] 2) [维护数据的一致性] 如果控制文件中的检查点与数据文件中的一致,则说明数据一致,可以启动到 ...
- Oracle11g温习-第三章:instance实例管理
2013年4月27日 星期六 10:30 1.instance 功能: 用于管理和访问database. 2.init parameter files :管理实例相关启动参数.位置:$ORACLE ...
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Entity Framework 6 Recipes》中文翻译系列 (22) -----第五章 加载实体和导航属性之延迟加载
翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 第五章 加载实体和导航属性 实体框架提供了非常棒的建模环境,它允许开发人员可视化地使 ...
随机推荐
- MySQL Crash Course #10# Chapter 19. Inserting Data
INDEX BAD EXAMPLE Improving Overall Performance Inserting Multiple Rows INSTEAD OF Inserting a Singl ...
- MySQL Crash Course #09# Chapter 17. Combining Queries: UNION
INDEX UNION Rules WHERE VS. UNION UNION VS. UNION ALL Sorting Combined Query Results UNION Rules As ...
- P3456 [POI2007]GRZ-Ridges and Valleys(bfs)
P3456 [POI2007]GRZ-Ridges and Valleys 八个方向都跑一遍bfs,顺便判断一下是山峰还是山谷,或者是山坡(俩都不是) (实在不知道要说啥了qwq) #include& ...
- Navicat连不上mysql8
今天使用navicat连接mysql8,发现错误连连 错误1:1130-Host '192.168.50.2' is not allowed to connect to this MySQL serv ...
- 微信小程序——1、文件的认识
主体文件的构成 微信小程序的主体由三个部分组成,需放在主目录中,名称也是固定的 app.js:微信小程序的主逻辑文件,主要用来注册小程序 app.json:微信小程序的主配置文件,对微信小程序进行全局 ...
- 2018-2019-1 20189218《Linux内核原理与分析》第四周作业
构造简单的Linux内核 显然用实验楼配好的环境做这个实验太简单了,按照没有困难制造困难也要上的原则,在自己的64位虚拟机上做这个实验. 按照课本(视频)上的步骤一直做下去,到编译生成init时出现了 ...
- C++for的几种方式
#include <algorithm> #include <vector> ////////////////////////////////////////////// , ...
- SPI、CAN、I2C
SPI是串行外设接口(Serial Peripheral Interface)的缩写.SPI,是一种高速的,全双工,同步的通信总线,并且在芯片的管脚上只占用四根线,节约了芯片的管脚,同时为PCB的布局 ...
- Spring Boot条件注解
一.为什么SpringBoot产生于Spring4? Spring4中增加了@Condition annotation, 使用该Annotation之后,在做依赖注入的时候,会检测是否满足某个条件来决 ...
- 入门dp总结
写这篇博文主要是为了归纳总结一下dp的有关问题(不定期更新,暑假应该会更的快一些) 会大概讲一下思路,不会事无巨细地讲 另一篇是平时做过的一些dp题,这篇博客里面提到的题都有题解放在那边:https: ...