CHAPTER 10 Data Dictionary Basics. Data Dictionary Information regarding objects and events within the database. Super critical that as a DBA or developer.

Slides:



Advertisements
Similar presentations
13 Copyright © Oracle Corporation, All rights reserved. Controlling User Access.
Advertisements

5 Copyright © Oracle Corporation, All rights reserved. Using Data Dictionary and Dynamic Performance Views Cui Zhou Oracle Certified Professional.
IT Database Administration Section 04. The Oracle 9i Data Dictionary  A set of tables and views owned by SYS and accessible using SQL  Can be.
5 Copyright © Oracle Corporation, All rights reserved. 使用数据库字典和动态性能视图.
5 Copyright © Oracle Corporation, All rights reserved. Using Data Dictionary and Dynamic Performance Views.
SQL1-ch11 使用資料說明視觀表 (Data Dictionary) 管理物件. 題號  80 題: 6 、 64  140 題: 105.
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Installation – Lecture 2 Copyright System Managers LLC 2007 all rights reserved.
Harvard University Oracle Database Administration Session 9 Managing the Environment.
System Administration Accounts privileges, users and roles
Database objects User schema DCL Oracle dictionary.
Oracle Database Architecture An Oracle server: –Is a database management system that provides an open, comprehensive, integrated approach to information.
A Guide to MySQL 7. 2 Objectives Understand, define, and drop views Recognize the benefits of using views Use a view to update data Grant and revoke users’
Oracle Database Architecture An Oracle server: –Is a database management system that provides an open, comprehensive, integrated approach to information.
Oracle Data Dictionary. What Is Data Dictionary The oracle data dictionary is one of the most important components of the oracle DBMS It contains all.
A Guide to SQL, Seventh Edition. Objectives Understand, create, and drop views Recognize the benefits of using views Grant and revoke user’s database.
INTEGRITY Enforcing integrity in Oracle. Oracle Tables mrobbert owner granted access.
Lecture 3 The Relational DB Model. Learning Objectives That the relational database model takes a logical view of data That the relational model’s basic.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Oracle Database Architecture An Oracle server: –Is a database management system that provides an open, comprehensive, integrated approach to information.
Chapter 6 Additional Database Objects
CHAPTER 6 Users and Basic Security. Progression of Steps for Creating a Database Environment 1. Install Oracle database binaries (Chapter 1) 2. Create.
Database Programming Sections 13–Creating, revoking objects privileges.
14 Copyright © 2004, Oracle. All rights reserved. Performance Monitoring.
Oracle9i Performance Tuning Chapter 1 Performance Tuning Overview.
The protection of the DB against intentional or unintentional threats using computer-based or non- computer-based controls. Database Security – Part 2.
Chapter 6 Additional Database Objects Oracle 10g: SQL.
Controlling User Access. Objectives After completing this lesson, you should be able to do the following: Create users Create roles to ease setup and.
1 Database Administration. 2 Objectives  Understand, create, and drop views  Grant and revoke users’ privileges  Understand and obtain information.
Chapter 6 Database Administration
1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003.
Metadata, Security, and the DBA Chapter 8.1 V3.0 Napier University Dr Gordon Russell.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
Roles & privileges privilege A user privilege is a right to execute a particular type of SQL statement, or a right to access another user's object. The.
Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
CHAPTER 9 Views, Synonyms, and Sequences. Views are used extensively in reporting applications and also to present subsets of data to applications. Synonyms.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
Oracle 11g: SQL Chapter 4 Constraints.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Managing Constraints. 2 home back first prev next last What Will I Learn? Four different functions that the ALTER statement can perform on constraints.
Controlling User Access. 2 home back first prev next last What Will I Learn? Compare the difference between object privileges and system privileges Construct.
1 DBS201: More on SQL Lecture 3. 2 Agenda How to use SQL to update table definitions How to update data in a table How to join tables together.
Copyright © 2004, Oracle. All rights reserved. CONTROLLING USER ACCESS Oracle Lecture 8.
55 Creating Data Dictionary Views and Standard Packages.
Chapter 4 Indexes. Indexes Logically represents subsets of data from one or more tables View Generates numeric valuesSequence Basic unit of storage; composed.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
13 Copyright © Oracle Corporation, All rights reserved. Controlling User Access.
Introduction to Teradata Client Tools. 2 Introduction to Teradata SQL  OBJECTIVES :  Teradata Product Components.  Accessing Teradata – Database /
Chapter 12Introduction to Oracle9i: SQL1 Chapter 12 Additional Database Objects.
1 Copyright © 2006, Oracle. All rights reserved. Controlling User Access ( 사용자 접근 제어 )
1 Chapters 21, 22, 23, 37  Ch. 21: SQL*Loader  Ch. 22: Database Links, Oracle Net  Ch. 23: Materialized Views (aka Snapshots)  Ch. 37: Data Dictionary.
1 Copyright © 2009, Oracle. All rights reserved. Controlling User Access.
19 Managing Privileges Objectives Identifying system and object privileges Granting and revoking privileges Controlling operating system or password.
Chapter 15 Materialized Views.
Physical Layer of a Repository. March 6, 2009 Agenda – What is a Repository? –What is meant by Physical Layer? –Data Source, Connection Pool, Tables and.
8 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
Database Systems Slide 1 Database Systems Lecture 4 Database Security - Concept Manual : Chapter 20 - Database Security Manual : Chapters 5,10 - SQL Reference.
2 Copyright © 2009, Oracle. All rights reserved. Managing Schema Objects.
Creating Indexes Database Systems Objectives Distinguish between the indexes that are created automatically and those that are created manually.
Controlling User Access
Controlling User Access
Using Data Dictionary and Dynamic Performance Views
Managing Objects with Data Dictionary Views
Chapter 4 Indexes.
CH 4 Indexes.
Managing Objects with Data Dictionary Views
A Guide to SQL, Eighth Edition
CH 4 Indexes.
Create New User in Database. First Connect the System.
Introduction of Week 13 Assignment Discussion
Presentation transcript:

CHAPTER 10 Data Dictionary Basics

Data Dictionary Information regarding objects and events within the database. Super critical that as a DBA or developer you know how to leverage the information within the data dictionary. The data dictionary is always a good place to look when troubleshooting or determining facts about your database. This chapter gives you a foundation for understanding and querying the data dictionary.

Data Dictionary Contents Data dictionary objects owned by SYS Static views Dynamic views

Static Views There are three types or levels of static views: USER ALL DBA USER/ALL/DBA views contain metadata (information) describing the physical makeup of the database. Use these views to view the structure of the database and information about users and corresponding objects. Examples: DBA_USERS, DBA_TABLES, DBA_INDEXES, DBA_CONSTRAINTS, DBA_TABLESPACES, DBA_SEGMENTS, DBA_EXTENTS, and so on.

Creating Static Views

Dynamic Views Dynamic performance data-dictionary views are often referred to as the V$ and GV$ views. Continuously updated by Oracle and reflect the current condition of the instance and database. Dynamic views are critical for diagnosing real-time performance issues.

Creating Dynamic Views

Viewing View Creation Details Query v$fixed_view_definition select view_definition from v$fixed_view_definition where view_name='V$CONTROLFILE';

Derivable Database Documentation DBA_OBJECTS DICTIONARY DICT_COLUMNS

Logical and Physical Database Structures

Relationships of Common Data Dictionary Views

Database Space-Management Views V$DATABASE DBA/ALL/USER_USERS DBA/USER_TABLESPACES DBA_DATA_FILES DBA/USER_FREE_SPACE V$DATAFILE V$DATAFILE_HEADER DBA/ALL/USER_TABLES DBA/ALL/USER_INDEXES Many, many, more...

Displaying User Information Currently connected users Current SQL being executed by users User accounts in the database

Currently Connected User Info SQL> show user; SQL> select * from user_users; SQL> select name from v$database; SQL> select instance_name, host_name from v$instance; select sys_context('USERENV','CURRENT_USER') usr,sys_context('USERENV','AUTHENTICATION_METHOD') auth_mth,sys_context('USERENV','HOST') host,sys_context('USERENV','INSTANCE_NAME') inst from dual;

Users Currently Logged In select count(*),username from v$session group by username;

Currently Executing SQL Example 1: select a.sid,a.username,b.sql_text from v$session a,v$sqltext_with_newlines b where a.sql_id = b.sql_id order by a.username,a.sid,b.piece;

Currently Executing SQL Example 2: select s.username,s.sid,s.serial#,s.last_call_et/60 mins_running,q.sql_text from v$session s join v$sqltext_with_newlines q on s.sql_address = q.address where status='ACTIVE' and type <>'BACKGROUND' and last_call_et> 60 order by sid,serial#,q.piece;

User Accounts set lines 132 col username form a15 col default_tablespace form a18 col temporary_tablespace form a20 col account_status form a16 -- select username,default_tablespace,temporary_tablespace,account_status,created,lock_date from dba_users order by 1;

Viewing Table Information select a.table_name,b.created,b.last_ddl_time,a.last_analyzed from user_tables a, user_objects b where a.table_name = b.object_name;

Displaying Object Disk-Space Usage UNDEFINE owner COL summer FORM 999, SET LINES 132 TRIMSPOOL ON PAGES 100 SPO space.txt SELECT segment_name,partition_name,tablespace_name,segment_type,SUM(bytes)/1024/1024 summer FROM dba_extents WHERE owner = UPPER('&&owner') GROUP BY segment_name,partition_name,tablespace_name,segment_type ORDER BY segment_name,partition_name; SPO OFF;

Displaying Table Row Counts UNDEFINE user SPOOL tabcount_&&user..sql SET LINESIZE 132 PAGESIZE 0 TRIMSPO OFF VERIFY OFF FEED OFF TERM OFF SELECT 'SELECT RPAD(' || '''' || table_name || '''' ||',30)' || ',' || ' COUNT(*) FROM &&user..' || table_name || ';' FROM dba_tables WHERE owner = UPPER('&&user') ORDER BY 1; SPO OFF; SET TERM ON SET VERIFY ON FEED ON

Manually Generating Statistics SQL> exec dbms_stats.gather_table_stats(ownname=>'INV',- tabname=>'F_SALES',- cascade=>true,estimate_percent=>20,degree=>4); SQL> exec dbms_stats.gather_schema_stats(ownname => 'INV',- estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE,- degree => DBMS_STATS.AUTO_DEGREE,- cascade => true);

Displaying Indexes for a Table Troubleshooting performance issues. What indexes exist and on what columns? select a.index_name,a.column_name,b.status,b.index_type,a.column_position from user_ind_columns a,user_indexes b where a.table_name = upper('&table_name') and a.index_name = b.index_name order by a.index_name, a.column_position;

Displaying Table Constraints Troubleshooting or determining what types of constraints are in place. select table_name,(case constraint_type when 'P' then 'Primary Key' when 'R' then 'Foreign Key' when 'C' then 'Check' when 'U' then 'Unique' when 'O' then 'Read Only View' when 'V' then 'Check view' when 'H' then 'Hash expression' when 'F' then 'REF column' when 'S' then 'Supplemental logging' end) cons_type,constraint_name cons_name,search_condition check_cons,status from dba_constraints where owner like upper('&owner') and table_name like upper('&table_name') order by cons_type;

Showing Primary-Key and Foreign-Key Relationships Sometimes need to determine for child table FKs what are associated PKs and visa versa. select a.constraint_type cons_type,a.table_name child_table,a.constraint_name child_cons,b.table_name parent_table,b.constraint_name parent_cons,b.constraint_type cons_type from dba_constraints a,dba_constraints b where a.owner = upper('&owner') and a.table_name = upper('&table_name') and a.constraint_type = 'R' and a.r_owner = b.owner and a.r_constraint_name = b.constraint_name;

Displaying Granted Roles select username,granted_role from user_role_privs; select grantee,granted_role from dba_role_privs where grantee = upper('&grantee') order by grantee;

Displaying System Privileges Query these dba_sys_privs when troubleshooting privilege issues. select grantee,privilege,admin_option from dba_sys_privs where grantee = UPPER('&grantee') order by privilege;

Displaying Object Privileges Query data dictionary when diagnosing object access issues. select owner,table_name,grantor,privilege from user_tab_privs_recd;

Displaying Object Dependencies Before dropping an object, it’s useful to determine which objects might have dependencies on the object to be dropped. select '+' || lpad(' ',level+2) || type || ' ' || owner || '.' || name dep_tree from dba_dependencies connect by prior owner = referenced_owner and prior name = referenced_name and prior type = referenced_type start with referenced_owner = upper('&object_owner') and referenced_name = upper('&object_name') and owner is not null;

V$ and GV$ Views The V$ and GV$ views are used for performance tuning and database troubleshooting. These are covered more in Chapter 22 Database Troubleshooting.

Summary DBAs and developers must understand the data dictionary architecture and how to leverage the information to troubleshoot and maintain database environments. Main focus of this chapter was the static data dictionary views. Dynamic views covered more later in the book in the database troubleshooting chapter.