您的位置:首页 > 数据库 > Oracle

我的Oracle 9i学习日志(9)--数据字典与动态性能视图及练习

2010-03-15 22:31 821 查看
一、数据字典

不仅是每个Oracle数据库的核心组件之一,也是所有数据库用户重要的信息资源;描述数据与对象的数据;包含只读的表和视图;存储在系统表空间;所有者为sys;由Oracle server维护;通过select语句访问。
[align=left]执行数据定义语言(definition language,DDL)语句或有些数据操纵语言 (data manipulation language ,DML) 语句时会更新数据字典。[/align]
[align=left]包括两部分:[/align]
[align=left]1、 基表(base tables),在create database执行时(执行sql.bsq脚本)创建;用户不能直接访问因为它们是被加密的,无法用DML语句直接更新这些表,有一个例外,AUD$。基表举例:IND$,包含数据的索引信息。[/align]
[align=left]2、数据字典视图,在执行$ORACLE_HOME/rdbms/admin/catalog.sql,catproc.sql脚本时创建。[/align]
[align=left]数据字典的内容:审计、用户被赋予的特权和角色、用户名字、完整性约束、资源的分配情况、逻辑和物理结构。[/align]
[align=left]数据字典视图种类:[/align]
[align=left] [/align]




[align=left]数据字典举例:[/align]
[align=left]概览: DICTIONARY, DICT_COLUMNS[/align]
[align=left]Schema objects: DBA_TABLES, DBA_INDEXES,DBA_TAB_COLUMNS, DBA_CONSTRAINTS[/align]
[align=left]空间分配: DBA_SEGMENTS, DBA_EXTENTS[/align]
[align=left]数据库结构: DBA_TABLESPACES,DBA_DATA_FILES[/align]
[align=left]Data dictionary views are static views that answer questions such as:[/align]
[align=left]• Was the object ever created?[/align]
[align=left]• What is the object a part of?[/align]
[align=left]• Who owns the object?[/align]
[align=left]• What privileges do users have?[/align]
[align=left]• What restrictions are on the object?[/align]
[align=left]二、动态性能视图[/align]
[align=left]虚表;记录当前数据库活动及活动状态;在数据库运行期间持续更新;可通过访问内存和控制文件获得的信息;用于数据库的监视和性能调优;所有者为sys;synonymous以v$开头;在V$FIXED_TABLE里列出所有这些表的名字。[/align]
[align=left]DBA可以在这些视图上再创建视图。[/align]
[align=left]The dynamic performance tables answer questions such as:[/align]
[align=left]• Is the object online and available?[/align]
[align=left]• Is the object open?[/align]
[align=left]• What locks are being held?[/align]
[align=left]• Is the session active?[/align]
举例:
•V$CONTROLFILE: Lists the names of the control files
[align=left]•V$DATABASE: Contains database information from the control file.[/align]
[align=left]•V$DATAFILE: Contains data file information from the control file[/align]
[align=left]•V$INSTANCE: Displays the state of the current instance[/align]
[align=left]•V$PARAMETER: Lists parameters and values currently in effect for the session[/align]
[align=left]•V$SESSION: Lists session information for each current session[/align]
[align=left]•V$SGA: Contains summary information on the system global area (SGA)[/align]
[align=left]•V$SPPARAMETER: Lists the contents of the SPFILE[/align]
[align=left]•V$TABLESPACE: Displays tablespace information from the control file[/align]
[align=left]•V$THREAD: Contains thread information from the control file[/align]
[align=left]•V$VERSION: Version numbers of core library components in the Oracle server[/align]
三、管理脚本命名规则




[align=left]Practice 5: Using Data Dictionary and Dynamic Performance Views[/align]
[align=left]1 Which of the following statements are true about the data dictionary?[/align]
[align=left]a The data dictionary describes the database and its objects.[/align]
[align=left]b The data dictionary includes two types of objects: base tables and data dictionary[/align]
[align=left]views.[/align]
[align=left]c The data dictionary is a set of tables.[/align]
[align=left]d The data dictionary records and verifies information about its associated database.[/align]
[align=left]答案:a,b,c,d。[/align]
[align=left]2 Base tables are created using the catalog.sql script.[/align]
[align=left]a True[/align]
[align=left]b False[/align]
[align=left]答案:b。[/align]
[align=left]解析:是在create database时创建,catalog.sql是创建视图。[/align]
[align=left]3 Which three of the following statements are true about how the data dictionary is used?[/align]
[align=left]a The Oracle server modifies it when a DML statement is executed.[/align]
[align=left]b It is used to find information about users, schema objects, and storage structures.[/align]
[align=left]c It is used by users and DBAs as a reference.[/align]
[align=left]d The data dictionary is a necessary ingredient for the database to function.[/align]
[align=left]答案:b,c,d。[/align]
[align=left]4 Data dictionary views are static views.[/align]
[align=left]a True[/align]
[align=left]b False[/align]
[align=left]答案:a。[/align]
[align=left]5 The information for a dynamic performance view is gathered from the control file.[/align]
[align=left]a True[/align]
[align=left]b False[/align]
[align=left]答案:b。[/align]
[align=left]6 Which of the following questions might a dynamic performance view answer?[/align]
[align=left]a Is the object online and available?[/align]
[align=left]b What locks are being held?[/align]
[align=left]c Who owns the object?[/align]
[align=left]d What privileges do users have?[/align]
e Is the session active?
答案:a,b,d,e。

7 Connect as SYSTEM/MANAGER and find a list of the data dictionary views.

8 Identify the database name, instance name, and size of the database blocks.

Hint: Query the V$DATABASE, V$THREAD, and V$PARAMETER dynamic

performance views.

9 List the name of the data files.

Hint: Query the V$DATAFILE dynamic performance view.

10 Identify the data file that makes up the SYSTEM tablespace.

Hint: Query the DBA_DATA_FILES data dictionary view to identify the SYSTEM

tablespace data file.

11 How much free space is available in the database and how much is already used?

Hints

- Query the DBA_FREE_SPACE data dictionary view to show how much free

space is available in the database.

- Query the DBA_SEGMENTS data dictionary view to display how much space is

already used.

12 List the name and creation date of the database users.

Hint: Query the DBA_USERS data dictionary view to list the name and the creation

of the database users.
本文出自 “冰冷的太阳” 博客,请务必保留此出处http://luotaoyang.blog.51cto.com/545649/284100
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: