Data Dictionary Structure Base Tables and Data Dictionary Views Data dictionary views: - Views simplify the base table information - Created with the catalog.sql script Base tables: - Normalized - Created with the sql.bsq script 5-4 Copyright © Oracle Corporation, 1998 All rights reserved The data dictionary, located in the SYSTEM tablespace and owned by the user SYS, contains two parts: • Base tables • Data dictionary views Base Tables The foundation of the data dictionary is a set of base or underlying tables The Oracle server writes and reads these tables Database users rarely access them directly because they are normalized and the information is encoded For example, you would query the IND$ table to get information about the indexes that are defined in the database, or select from the OBJ$ table to display the objects defined in the database Never use DML commands such as INSERT, UPDATE, and DELETE to update the base data dictionary tables directly, with the exception of the AUD$ table (see the lesson “Auditing”) Oracle8: Database Administration 5-5 Lesson 5: Creating Data Dictionary Views and Standard Packages Data Dictionary Views The data dictionary views are created by running the catalog.sql script These views decode and summarize the information in the base data dictionary tables Public synonyms are created on the data dictionary views so that users can access them easily Most users examine the data dictionary by selecting from the views rather than the base tables 5-6 Oracle8: Database Administration Data Dictionary Structure Data Dictionary Views DBA_xxx objects of the entire database ALL_xxx objects can be accessed by the user USER_xxx objects owned by the user 5-5 Copyright © Oracle Corporation, 1998 All rights reserved Data Dictionary View Categories The data dictionary views are split into three categories In many cases the views contain similar information and can be distinguished from each other by their prefixes The Prefix USER These views are accessible by any user and generally refer to objects owned by a user—for example, USER_TABLES contains information on all tables owned by the user These views return a subset of the information in the ALL_ views The Prefix ALL Views with the prefix ALL are accessible by any user and usually include the column OWNER These views return information about objects to which the user has access via public or explicit grants of privileges and roles, including the objects that the user owns The Prefix DBA Views with the prefix DBA give information on all the objects in the database and usually include the column OWNER These views are queried by the database administrator or any user granted the system privilege SELECT ANY TABLE (see the lesson “Managing Privileges”) Synonyms are created for these views so that every user with the SELECT ANY TABLE privilege can query them Oracle8: Database Administration 5-7 Lesson 5: Creating Data Dictionary Views and Standard Packages Data Dictionary: Views Examples and Categories Views Description dictionary dict_columns General overview dba_tables dba_objects dba_lobs dba_tab_columns dba_constraints Information related to the user objects such as tables, constraints, large objects and columns dba_users dba_sys_privs dba_roles Information about user privileges and roles Copyright © Oracle Corporation, 1998 All rights reserved 5-6 Data Dictionary Views: Examples and Categories Views Description dba_extents dba_free_space dba_segments Space allocation for database objects dba_rollback_segs dba_data_files dba_tablespaces General database structures dba_audit_trail dba_audit_objects dba_audit_obj_opts 5-7 Auditing information Copyright © Oracle Corporation, 1998 All rights reserved 5-8 Oracle8: Database Administration Data Dictionary Structure To get an overview of the data dictionary views, their columns, and the dynamic performance views, you can query the DICTIONARY or DICT_COLUMNS view SVRMGR>SELECT * 2> FROM dictionary 3> WHERE table_name TABLE_NAME -ALL_ALL_TABLES ALL_NESTED_TABLES ALL_OBJECT_TABLES ALL_PART_TABLES ALL_TABLES ALL_UPDATABLE_COLUMNS DBA_ALL_TABLES DBA_NESTED_TABLES DBA_OBJECT_TABLES LIKE ’%TABLE%’; COMMENTS -Description of all object and relational tables accessible to the user Description of nested tables in tables accessible to the user Description of all object tables accessible to the user Description of relational tables accessible to the user Descriptionofallupdatablecolumns Description of all object and relational tables in the database Description of nested tables contained in all tables Description of all object tables in the database Oracle8: Database Administration 5-9 Lesson 5: Creating Data Dictionary Views and Standard Packages Note There is a synonym DICT for the data dictionary view DICTIONARY SVRMGR>SELECT column_name, comments 2> FROM dict_columns 3> WHERE table_name=’DBA_TABLES’; COLUMN_NAME OWNER TABLE_NAME TABLESPACE_NAME CLUSTER_NAME IOT_NAME COMMENTS Owner of the table Name of the table Nameofthetablespacecontainingthetable Name of the cluster, if any, to which the table belongs Name of the index-only table, if any, to which the overflow entry belongs Note For a detailed description of the views and their columns, see the Oracle8 Server reference manual 5-10 Oracle8: Database Administration Constructing the Data Dictionary Constructing the Data Dictionary Creating Data Dictionary Views Script Purpose catalog.sql Creates commonly used data dictionary views catproc.sql Runs all scripts required for PL/SQL on the server 5-8 Copyright © Oracle Corporation, 1998 All rights reserved After database creation, the catalog.sql and catproc.sql scripts must be run as the user SYS They are located in the $ORACLE_HOME/rdbms/admin directory on UNIX and in the %ORACLE_HOME%\rdbms80\admin directory on NT The catalog.sql Script The catalog.sql script creates the views on the base tables, views on the dynamic performance views and their synonyms It starts scripts, such as those to create views and objects for the Server Manager utility, for auditing, for the Export and Import utility, and for the partitioning and object options It runs the standard.sql script, which creates the basic PL/SQL environment The standard.sql script declares types, exceptions, and subprograms, which are automatically available to every PL/SQL program For example, it declares the built-in function named BITAND, which returns the result of the bit operation and of its arguments: function BITAND (LEFT binary_integer, RIGHT binary_integer) return binary_integer; Oracle8: Database Administration 5-11 Lesson 5: Creating Data Dictionary Views and Standard Packages The catproc.sql Script The catproc.sql script establishes the usage of the PL/SQL functionality In addition, it creates several PL/SQL packages that are used to extend the RDBMS functionality The catproc.sql script also creates additional views for the advanced queuing option, tablespace point-in-time recovery, and the use of LOBs Note You may use additional scripts to support other extended Oracle functionality, as discussed in the next section 5-12 Oracle8: Database Administration Using Administrative Scripts Using Administrative Scripts Administrative Scripts The following naming conventions exist for the sql scripts: Convention Description cat*.sql Catalog and data dictionary information dbms*.sql Database package specifications prvt*.plb Wrapped database package code utl*.sql Views and tables for database utilities 5-9 Copyright © Oracle Corporation, 1998 All rights reserved The $ORACLE_HOME/rdbms/admin directory on UNIX (or %ORACLE_HOME%\rdbms80\admin on NT ) contains administrative scripts, which can be separated into four categories of files: • utl*.sql • cat*.sql • dbms*.sql • prvt*.plb The utl*.sql Scripts The utl*.sql scripts must be run when the database needs additional views and tables For example, the script utlsampl.sql creates and populates the sample tables EMP, DEPT, SALGRADE, and BONUS under the user SCOTT Oracle8: Database Administration 5-13 Lesson 5: Creating Data Dictionary Views and Standard Packages The cat*.sql Scripts The cat*.sql scripts create data dictionary views In addition to the catalog.sql and catproc.sql scripts, there are scripts that create information for Oracle utilities For example, the catrman.sql script creates recovery catalog tables and views for the Recovery Manager The catnormn.sql script drops these tables and views The dbms*.sql and prvt*.plb Scripts The dbms*.sql and prvt*.plb scripts contain information about predefined Oracle packages (see the next section), which extend the Oracle functionality by providing stored database procedures and functions These programs simplify the task of administering the database Most SQL scripts are run during the execution of the catproc.sql script A few additional scripts must be executed by the database administrator An example is the dbmspool.sql script enables you to display the sizes of objects in the shared pool and mark them for keeping or unkeeping in order to reduce shared pool fragmentation Note Most of these scripts must be executed under the user SYS The database administrator should examine the scripts to find out which user account must be used to run the scripts Instructor Note Point out that there are also useful sample and demo scripts in the following directories on NT: • %ORACLE_HOME%\RDBMS80\AQ • %ORACLE_HOME%\RDBMS80\LOADER • %ORACLE_HOME%\RDBMS80\RMAN These explain the advanced queuing, Loader, and Recovery Manager functionality On UNIX, these scripts are located in the $ORACLE_HOME/rdbms/demo directory 5-14 Oracle8: Database Administration Lesson 6: Maintaining the Control File Instructor Note Topic Lecture Timing 20 minutes Practice 40 minutes Total 60 minutes 6-2 Oracle8: Database Administration Objectives Objectives Objectives • Explaining the uses of the control file • Examining the contents of the control file • Obtaining the control file information • Multiplexing the control file 6-2 Copyright © Oracle Corporation, 1998 All rights reserved Oracle8: Database Administration 6-3 Lesson 6: Maintaining the Control File Using the Control File Using the Control File Control files Data files Redo log files Database 6-3 Copyright © Oracle Corporation, 1998 All rights reserved The control file is a binary file that is necessary for the database to start and operate successfully Every time an instance mounts an Oracle database, it reads the control file to locate the data files and online redo log files The control file is updated continuously during database use and must be available whenever the database is mounted or opened The control file provides information about database consistency used during recovery If any of the control files currently being used by the database becomes unavailable, then the database cannot function properly 6-4 Oracle8: Database Administration The Contents of the Control File The Contents of the Control File The Contents of the Control File Database name Data file location Redo log file location Tablespace names Current log sequence number Checkpoint information Log history Backup information 6-4 Copyright © Oracle Corporation, 1998 All rights reserved A control file includes the following information: • The database name and identification • The names and the locations of the data files and redo log files • The names of the tablespaces • The time stamp of the database creation • The current log sequence number • Checkpoint information • Log history • Backup information of the Recovery Manager utility The control file consists of two types of sections: • Reusable • Not reusable Reusable sections like a backup data file or a backup redo log file are used in a circular manner and only reused by the Recovery Manager Note This is covered in more detail in the course Oracle8: Backup and Recovery Workshop Oracle8: Database Administration 6-5 Lesson 6: Maintaining the Control File Parameters Affecting the Size of the Control File The size of the control file is influenced by the following parameters: • MAXLOGFILES • MAXLOGMEMBERS • MAXLOGHISTORY • MAXDATAFILES • MAXINSTANCES 6-5 Copyright © Oracle Corporation, 1998 All rights reserved The control files defined by the following initialization parameter at the time of creation of the database are automatically created by the Oracle server: CONTROL_FILES = (/DISK1/control01.con,/DISK2/control02.con) The filenames specified in this parameter should include the full path Filename specification is operating system specific The parameters which are specified during the creation of the database, affect the size of the control file This is particularly significant when the parameters have large values The database administrator might need to re-create the control file to change one or more of the database limit parameters, which could increase or decrease the size of the control file The creation of a new control file is required to change the size of the control file The control file holds information used by Recovery Manager Therefore, when using Recovery Manager the reusable section of the control file can expand based on the number of entries Note This is covered in more detail in the course Oracle8: Backup and Recovery Workshop 6-6 Oracle8: Database Administration Obtaining Information About the Control File Obtaining Information About the Control File Obtaining Information • V$CONTROLFILE - NAME • V$PARAMETER - NAME ( control_file) - VALUE • V$CONTROLFILE_RECORD_SECTION - TYPE - RECORDS_SIZE - RECORDS_TOTAL - RECORDS_USED 6-6 Copyright © Oracle Corporation, 1998 All rights reserved To obtain the location and names of the control files, use either the dynamic performance view V$PARAMETER or the dynamic performance view V$CONTROLFILE SVRMGR> SELECT name 2>FROM v$controlfile; NAME /DISK1/control01.con /DISK2/control02.con rows selected SVRMGR> SELECT value 2>FROM v$parameter WHERE name =’control_files’; VALUE -/DISK1/control01.con /DISK2/control02.con rows selected Oracle8: Database Administration 6-7 Lesson 6: Maintaining the Control File To obtain information about the different sections of the control files, query the dynamic performance view V$CONTROLFILE_RECORD_SECTION SVRMGR>SELECT type, record_size, records_total, records_used 2> FROM v$controlfile_record_section 3> WHERE type=’DATAFILE’; TYPE RECORD_SIZ -DATAFILE 180 row selected RECORDS_TO -30 RECORDS_US -4 The column RECORDS_TO specifies the number of records allocated for a special section For example, you can view the maximum number of data files, in our example 30, which is determined by the MAXDATAFILES parameter in the CREATE DATABASE command 6-8 Oracle8: Database Administration Multiplexing the Control File Multiplexing the Control File Multiplexing the Control File control_files=(/DISK1/control01.con,/DISK2/control02.con) Disk control01.con 6-7 Disk control02.con Copyright © Oracle Corporation, 1998 All rights reserved You can create the database with multiple control files by specifying up to eight fully qualified control file names using the initialization parameter CONTROL_FILES The Oracle server creates and maintains all files listed when the database is created Oracle recommends at least two, identical control files stored on different disks If a control file is lost, use the copy to restart the instance Multiplexing the Control File To add a new control file or change the number or location of the control file, use the following steps: Shut down the database Make a copy of the existing control file to a different device using operating system commands Edit or add the CONTROL_FILES parameter and specify names for all the control files Start up the database Oracle8: Database Administration 6-9 Lesson 6: Maintaining the Control File Summary Summary Multiplexing the control file helps to avoid a single point of database failure 6-8 Copyright © Oracle Corporation, 1998 All rights reserved Quick Reference Context Initialization parameters Dynamic performance views Reference CONTROL_FILES V$PARAMETER V$CONTROLFILE Data dictionary views Commands Packaged procedures and functions V$CONTROLFILE_RECORD_SECTION None None None 6-10 Oracle8: Database Administration Maintaining Redo Log Files Lesson 7: Maintaining Redo Log Files Instructor Note Topic Lecture Timing 40 minutes Practice 30 minutes Total 70 minutes 7-2 Oracle8: Database Administration Objectives Objectives Objectives • Explaining the use of online redo log files • Obtaining log and archive information • Controlling log switches and checkpoints • Multiplexing and maintaining online redo log files • Planning online redo log files • Troubleshooting common redo log file problems 7-2 Copyright © Oracle Corporation, 1998 All rights reserved Oracle8: Database Administration 7-3 Lesson 7: Maintaining Redo Log Files Overview Using Redo Log Files Control files Data files Redo log files Database 7-3 Copyright © Oracle Corporation, 1998 All rights reserved The Oracle server maintains online redo log files to minimize the loss of data in the database The redo log files record all changes made to data in the database buffer cache with some exceptions; for example, in the case of direct writes Redo log files are used in a situation such as an instance failure to recover committed data that has not been written to the data files The redo log files are only used for recovery 7-4 Oracle8: Database Administration Using Online Redo Files Using Online Redo Files Redo Log Groups and Members Group Group Group Member Member Member 7-4 Member Member Member Disk Disk Copyright © Oracle Corporation, 1998 All rights reserved The database administrator can set up the Oracle database to maintain copies of online redo log files to avoid losing database information due to a single point of failure Online Redo Log Groups • A set of identical copies of online redo log files is called an online redo log group • The background process LGWR concurrently writes the same information to all online redo log files in a group • The Oracle server needs a minimum of two online redo log file groups for the normal operation of a database Oracle8: Database Administration 7-5 Lesson 7: Maintaining Redo Log Files Online Redo Log Members • Each online redo log file in a group is called a member • Each member in a group has identical log sequence numbers and the same size The log sequence number is assigned each time the Oracle server starts writing to a log group to identify each redo log file uniquely The current log sequence number is stored in the control file and in the header of all data files Creating Initial Redo Log Files The initial set of online redo log groups and members are created during the database creation The following parameters limit the number of online redo log files: • The MAXLOGFILES parameter in the CREATE DATABASE command specifies the absolute maximum of online redo log groups The limit for MAXLOGFILES is 255 • The MAXLOGMEMBERS parameter used in the CREATE DATABASE command determines the maximum number of members per group • The initialization parameter LOG_FILES sets the current maximum number of the log groups that can be opened at run time for the database and cannot exceed MAXLOGFILES*MAXLOGMEMBERS 7-6 Oracle8: Database Administration ... Oracle8 : Database Administration 5- 27 Lesson 5: Creating Data Dictionary Views and Standard Packages 5- 28 Oracle8 : Database Administration. .. wrapped abcd abcd abcd abcd Copyright © Oracle Corporation, 19 98 All rights reserved Oracle8 : Database Administration 5 -19 Lesson 5: Creating Data Dictionary Views and Standard... the Oracle supplied packages are explained in detail in Oracle- supplied Oracle8 Server Application Developer’s Guide and in Oracle8 PL/SQL User’s Guide and Reference 5- 22 Oracle8 :