25
1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

Embed Size (px)

Citation preview

Page 1: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

1

All Powder Board and Ski

Oracle 9i WorkbookChapter 9: Database AdministrationJerry PostCopyright © 2003

Page 2: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

2

Oracle System Tables (Synonyms): Metadata

Prefixes Synonym Description

ALL_DBA_USER_

CONSTRAINTSIND_COLSMVIEWSSEQUENCESSYNONYMSTAB_COLUMNSTABLESTRIGGER_COLSTRIGGERSTYPESUSERSVIEWS

Table constraints and keysIndexed columnsMaterialized viewsSequencesSynonymsTable columnsTablesTrigger columnsTriggersUser-defined data typesUsersViews (saved queries)

SELECT Table_Name, Pct_Free FROM USER_TABLES

Page 3: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

3

Disk Drive

Oracle Data Storage

Data Files Data Files

Disk Drive

Data Files Data Files

Tablespace

Table Data

Tablespace

Rollback segments

Redo logs

RAID drives automatically spread files across multiple drives.

Even without RAID you can manually assign table data and rollback segments to different drives.

Goal: Substantially improved performance and recovery in case of hardware failure.

Page 4: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

4

Gather Statistics

Statistics about the data within each table tell Oracle how to optimize queries. The tuning system also uses the statistics to make recommendations about indexes to improve performance.

The older command is: Analyze Table Customer compute statistics;

Oracle now recommends that you use the DBMS_STATS package instead to analyze the entire database (or schema) at one time.

Exec DBMS_STATS.Gather_Database_Stats

Or

Exec DBMS_STATS.Gather_Schema_Stats(‘powder’)

Or

Exec DBMS_STATS.Gather_Table_Stats (‘powder’, ‘Customer’)

But, you might first have to run the catproc.sql script

Page 5: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

5

Enterprise Manager Console

Diagnostics Pack

Tuning Pack

Lock ManagerPerformance TunerPerformance OverviewTop SessionsTop SQLTrace Data Viewer

Oracle ExpertOutline ManagerSQL AnalyzeTablespace Map

Page 6: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

6

Performance Overview (Monitor)

Page 7: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

7

Drill Down to Find Causes

Page 8: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

8

Oracle Expert: Tuning Session

Select all items

Comprehensive

Page 9: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

9

Tuning: Collect Statistics

You might skip the Instance checks for now

Use the schema options to select your schema

Page 10: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

10

Select Schemas

Be sure to include your schema that holds the All Powder tables

Click the button to see a list of schemas

Page 11: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

11

Expert Recommendations

Specific table index recommendations

Details on storage locations

Page 12: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

12

SQL Analyze

SELECT Lastname, Firstname, Customer.CustomerID

FROM Customer, Sale

WHERE Customer.CustomerID = Sale.CustomerID

AND Customer.CustomerID NOT IN

(SELECT CustomerID FROM Rental)

ORDER BY Lastname, Firstname;

List customers who bought items but never rented anything.

Note that the query analyzer does not support the newer INNER JOIN syntax

Page 13: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

13

Index RecommendationsGet index recommendations Virtual Index Wizard

Page 14: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

14

SQL Tuning Wizard

Page 15: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

15

Tuning Wizard Recommendation

Page 16: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

16

Original Query Costs

Page 17: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

17

Revised Query Costs

Note the correlated subquery

Note the two hash joins instead of one

Substantially lower total costs

Page 18: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

18

Backup and Recovery

You could shut down the database and copy the data files and the control file

Make sure the Oracle Management Server is installed and running. You might have to install it from the main install wizard Make sure the OracleOraHome92ManagementServer service is

running (it is set to Manual start) Use the Enterprise Manager Console to log in. The initial

username/password is: sysman/oem_temp You need Archive Log mode set to handle a running backup

Select the database/Instance/Configuration in the tree view Under the Recovery tab, check the Archive Log mode This option will generate lots of data files since all changes to the

database will be saved in these archive files Run or schedule the backup

Tools/Database Tools/Backup Management/Backup

Page 19: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

19

Backup and Recovery Manager

Channels are disk or tape locations to hold the backup copies

Page 20: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

20

Schedule Backup

Page 21: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

21

User-Level Security

Database Application

Form1 Form 2 Form 3 Form 4

User 1 User 2

Workgroup databaseUsernames and passwords

Database Administrator

login

Assign permissions

credentials

Page 22: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

22

User Groups

Sales clerksSales Managers

Sales table

Customer table

Item table

Sales clerks S,U,I S,U,I S

Sales Managers S,U,I,D S,U,I S

Rental Managers S,U,I S

Individual users

Assign permissions to groups or roles based on tasks, and assign users to groups. Permissions only have to be set once. Employee changes are handled by moving individuals into or out of groups.

Page 23: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

23

Create New Users

Internal or external authentication

For many accounts at once, use SQL

Page 24: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

24

Create New Roles

Select table object

Grant permissions

Page 25: 1 All Powder Board and Ski Oracle 9i Workbook Chapter 9: Database Administration Jerry Post Copyright © 2003

25

Assign Roles to Users