Presentation is loading. Please wait.

Presentation is loading. Please wait.

55 Creating Data Dictionary Views and Standard Packages.

Similar presentations


Presentation on theme: "55 Creating Data Dictionary Views and Standard Packages."— Presentation transcript:

1 55 Creating Data Dictionary Views and Standard Packages

2 5-2 Objectives Constructing the data dictionary views Using the data dictionary Preparing the PL/SQL environment using the administrative scripts Administering stored procedures and packages Constructing the data dictionary views Using the data dictionary Preparing the PL/SQL environment using the administrative scripts Administering stored procedures and packages

3 5-3 Using the Data Dictionary The data dictionary provides information about: Logical and physical database structure Names, definitions, and space allocation of schema objects Integrity constraints Database users and privileges Auditing The data dictionary provides information about: Logical and physical database structure Names, definitions, and space allocation of schema objects Integrity constraints Database users and privileges Auditing

4 5-4 Base Tables and Data Dictionary Views Base tables: - Normalized - Created, as user SYS, with the sql.bsq script Data dictionary views: - Views simplify the base table information - Created, as user SYS, with the catalog.sql script

5 5-5 Data Dictionary Views USER_xxx ALL_xxx DBA_xxx objects owned by the user objects can be accessed by the user objects of the entire database

6 5-6 Data Dictionary: Views Examples and Categories Views Description dba_users dba_sys_privs dba_roles dba_tables dba_objects dba_lobs dba_tab_columns dba_constraints General overview Information about user privileges and roles Information related to the user objects such as tables, constraints, large objects and columns Dictionary, dba_views dict_columns

7 5-7 Data Dictionary Views: Examples and Categories dba_extents dba_free_space dba_segments Views Description Space allocation for database objects dba_rollback_segs dba_data_files dba_tablespaces General database structures Auditing information dba_audit_trail dba_audit_objects dba_audit_obj_opts

8 5-8 Script catalog.sql catproc.sql Purpose Creates commonly used data dictionary views Runs all scripts required for PL/SQL on the server Creating Data Dictionary Views Remember: run the scripts as user SYS

9 5-9 Administrative Scripts cat*.sql dbms*.sql prvt*.plb utl*.sql Catalog and data dictionary information Database package specifications Views and tables for database utilities Wrapped database package code The following naming conventions exist for the sql scripts: Convention Description

10 5-10 Stored Procedures and Packages Instance PLUS>execute dbms_session.set_role(..) SVRMGR>execute dbms_session.set_role(..) begin... dbms_session.set_role(..)... end; begin... dbms_session.set_role(..)... end; Database applications Shared pool DBMS_SESSION SET_ROLE begin... end; SGA

11 5-11 What Are Stored Procedures? Are procedures or functions Are stored in the data dictionary Can be used by many users Can accept and return parameters Can be used in SQL functions Are procedures or functions Are stored in the data dictionary Can be used by many users Can accept and return parameters Can be used in SQL functions

12 5-12 What Are Packages? Group logically related PL/SQL types, items, and subprograms Have two parts: – A specification – A body Allow Oracle to read multiple objects into memory at once Group logically related PL/SQL types, items, and subprograms Have two parts: – A specification – A body Allow Oracle to read multiple objects into memory at once

13 5-13 Procedure A declaration Procedure B definition Packagespecification Packagebody Procedure A definition Local variable Package

14 5-14 Package specification from dbmsutil.sql Package body from prvtutil.plb Example procedure set_role (role_cmd varchar2); create or replace package dbms_session is procedure set_role (role_cmd varchar2); abcd abcd abcd abcd... create or replace package body dbms_session wrapped 0 abcd abcd abcd abcd...

15 5-15 Oracle-Supplied Packages DBMS_LOB—Provides routines for operations on BLOB and CLOB datatypes DBMS_SESSION—Generates SQL commands like ALTER SESSION or SET ROLE DBMS_UTILITY—Provides various utility routines DBMS_SPACE—Provides segment space availability information DBMS_ROWID—Provides ROWID information DBMS_SHARED_POOL—Keeps and unkeeps information in the shared pool DBMS_LOB—Provides routines for operations on BLOB and CLOB datatypes DBMS_SESSION—Generates SQL commands like ALTER SESSION or SET ROLE DBMS_UTILITY—Provides various utility routines DBMS_SPACE—Provides segment space availability information DBMS_ROWID—Provides ROWID information DBMS_SHARED_POOL—Keeps and unkeeps information in the shared pool

16 5-16 Obtaining Information About Stored Objects Data dictionary view DBA_OBJECTS: – OWNER – OBJECT_NAME – OBJECT_TYPE – STATUS (VALID, INVALID) DESCRIBE command: Data dictionary view DBA_OBJECTS: – OWNER – OBJECT_NAME – OBJECT_TYPE – STATUS (VALID, INVALID) DESCRIBE command: describe dbms_session.set_role

17 5-17 Troubleshooting The status of dependent objects may be INVALID: If DDL commands are executed on referenced objects After creating the objects using the IMPORT utility The status of dependent objects may be INVALID: If DDL commands are executed on referenced objects After creating the objects using the IMPORT utility

18 5-18 Summary Creating and using the data dictionary views Using the administrative scripts Obtaining information about stored procedures and packages Creating and using the data dictionary views Using the administrative scripts Obtaining information about stored procedures and packages


Download ppt "55 Creating Data Dictionary Views and Standard Packages."

Similar presentations


Ads by Google