Download Data Dictionary Views

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
5
Creating Data Dictionary Views
and Standard Packages
Objectives
• Constructing the data dictionary views
• Using the data dictionary
• Preparing the PL/SQL environment
using the administrative scripts
• Administering stored procedures
and packages
5-2
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
5-3
Base Tables and Data
Dictionary Views
Data dictionary views:
- Views simplify the base table information
- Created, as user SYS, with the catalog.sql script
Base tables:
- Normalized
- Created, as user SYS, with the sql.bsq script
5-4
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
Data Dictionary: Views
Examples and Categories
Views
Dictionary, dba_views
dict_columns
5-6
Description
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
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
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
Remember: run the scripts as user SYS
5-8
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
Stored Procedures
and Packages
Instance
Database applications
Shared pool
DBMS_SESSION
begin
...
dbms_session.set_role(..)
...
end;
SET_ROLE
begin...
end;
PLUS>execute dbms_session.set_role(..)
SVRMGR>execute dbms_session.set_role(..)
5-10
SGA
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
5-11
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
5-12
Package
Package
specification
Package
body
Procedure A
declaration
Procedure B
definition
Procedure A
definition
Local
variable
5-13
Example
Package
specification
from
dbmsutil.sql
Package
body from
prvtutil.plb
5-14
create or replace package
dbms_session is
procedure set_role
(role_cmd varchar2);
create or replace package body
dbms_session wrapped
0
abcd
abcd
abcd
abcd ...
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_ROWID—Provides ROWID information
DBMS_SPACE—Provides segment space
availability information
DBMS_SHARED_POOL—Keeps and unkeeps
information in the shared pool
5-15
Obtaining Information About
Stored Objects
• Data dictionary view DBA_OBJECTS:
– OWNER
– OBJECT_NAME
– OBJECT_TYPE
– STATUS (VALID, INVALID)
• DESCRIBE command:
describe dbms_session.set_role
5-16
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
5-17
Summary
• Creating and using the data dictionary
views
• Using the administrative scripts
• Obtaining information about stored
procedures and packages
5-18
Related documents