Oracle 11g 2 Day DBA Hands-On

342
1 Oracle Database 11g 2-DAY DBA Hands- On

description

This is a 2-Day Oracle 11g Database Administrator's (DBA) Step-by-Step Guide

Transcript of Oracle 11g 2 Day DBA Hands-On

Page 1: Oracle 11g 2 Day DBA Hands-On

1

Oracle Database 11g 2-DAY DBA Hands-

On

Page 2: Oracle 11g 2 Day DBA Hands-On

2

Chapter 2: Installing Oracle Software and Building the Database

Purpose

This chapter shows you how to use the Oracle Universal Installer (OUI) to install your Oracle

database software and create a starter database. You will also learn how you can use the

Database Configuration Assistant (DBCA) to create additional databases.

Time to Complete

Approximately 2 hours

Topics

This tutorial covers the following topics:

Prerequisites

Installing the Software Using the Oracle Universal Installer (OUI)

Using the Database Configuration Assistant (DBCA) to Create a Database

Summary

Prerequisites

Before you perform this tutorial, you should:

1. General computer knowledge.

2. Familiarity with basic product installs.

Installing the Software Using the Oracle Universal Installer (OUI)

You can use the Oracle Universal Installer (OUI) to install your Oracle software . The OUI is a

GUI tool that enables you to view the Oracle software that is installed on your machine, install

new Oracle software, and delete Oracle software that you no longer intend to use. There are two

methods that you can use to install the Oracle software: basic and advanced. Choose the basic

installation method to quickly the install the software with minimal user input. The advanced

installation method enables you to perform a custom installation.

A Basic Installation

B. Advanced Installation

Basic Installation

Follow the steps below to install the Oracle software and create a database using the basic

installation method.

Page 3: Oracle 11g 2 Day DBA Hands-On

3

(Note: The Sample Schemas are not installed by default using the Basic Installation option):

1. Log onto you computer as a member of the administrative group that is authorized to install Oracle

software and create and run the database.

2. Insert the distribution CD for the database into your CD drive. The Autorun window will appear

automatically. Select Install/Deinstall Products.

Note: If you are downloading from Oracle’s download site, follow the instructions given on the Web

site.

3. The Select a Product to Install window appears. Select the Oracle Database 11g option. Click Next.

4. The Select Installation Method window appears. Select Basic Installation. Specify the Oracle Base

Location, Oracle Home location, Installation Type, and Unix DBA Group appropriate for your

environment. Select Create Starter Database and accept the default Global Database Name of orcl

Page 4: Oracle 11g 2 Day DBA Hands-On

4

or supply another database name appropriate for your environment.

Supply the database password of oracle or a password of your choice. Click Next.

5. On UNIX and Linux installations, the Specify Inventory directory and credentials window appears.

Enter the full path of the directory in which to install the Oracle software or accept the default. Enter

the name of an operating system group that has write permission to the directory. Click Next.

Page 5: Oracle 11g 2 Day DBA Hands-On

5

6. The Product-Specific Prerequisites Checks window appears. After all checks are completed, click

Next.

Page 6: Oracle 11g 2 Day DBA Hands-On

6

7. The Oracle Configuration Manager Registration window appears. This is used to associate your

configuration information with your Metalink account. For this exercise, bypass this option and click

Next.

Page 7: Oracle 11g 2 Day DBA Hands-On

7

8. The Summary window appears containing a list of the products to be installed. Click Install to begin

the installation.

Page 8: Oracle 11g 2 Day DBA Hands-On

8

The Install progress window is displayed.

Page 9: Oracle 11g 2 Day DBA Hands-On

9

9. The Configuration Assistants window appears. Allow the assistants to execute. They configure your

network, start an Oracle Net Services listener process for connecting to the database, create the

database and configure management tools.

Page 10: Oracle 11g 2 Day DBA Hands-On

10

10. The Database Configuration Assistant window showing a progress bar for database creation appears.

Page 11: Oracle 11g 2 Day DBA Hands-On

11

11. When the database creation is finished, a window containing information about your database

appears. Review this list. You may click Password Management if you want to unlock or change

passwords for database accounts. Otherwise click OK.

Page 12: Oracle 11g 2 Day DBA Hands-On

12

12. The Configuration Assistants window appears again, followed immediately by the Execute

Configuration scripts dialog box.

Page 13: Oracle 11g 2 Day DBA Hands-On

13

Before continuing with the installation, two separate scripts must be run as the root user. Open a new

terminal window, log in as root, and execute the orainstRoot.sh script found under the

/u01/app/oracle/oraInventory directory (as described in the dialog page).

Navigate to the /u01/app/oracle/product/11.1.0/db_1 directory and execute the root.sh script.

Page 14: Oracle 11g 2 Day DBA Hands-On

14

When the scripts finish, return to the Execute Configuration scripts page and click OK.

13. The End of Installation page appears with important information about the Web application. Click

Exit.

Page 15: Oracle 11g 2 Day DBA Hands-On

15

Click Yes. You have now completed the installation of Oracle software and database creation.

Advanced Installation

Follow the steps below to install the Oracle software and create a database using the advanced

installation method.

Note: If you performed the Basic Installation steps, you do not need to complete this section.

Page 16: Oracle 11g 2 Day DBA Hands-On

16

1. Log onto you computer as a member of the administrative group that is authorized to install Oracle

software and create and run the database.

2. Insert the distribution CD for the database into your CD drive. The Autorun window will appear

automatically. Select Install/Deinstall Products.

Note: If you are downloading from Oracle’s download site, follow the instructions given on the Web

site.

3. The Select a Product to Install window appears. Select the Oracle Database 11g option. Click Next.

4. The Select Installation Method window appears. Select Advanced Installation and click Next to

begin the installation of your software.

Page 17: Oracle 11g 2 Day DBA Hands-On

17

5. On UNIX and Linux installations, the Specify Inventory directory and credentials window appears.

Enter the full path of the directory in which to install the Oracle software or accept the default. Enter

the name of an operating system group that has write permission to the directory. Click Next.

Page 18: Oracle 11g 2 Day DBA Hands-On

18

6. The Select Installation Type window appears. Select Enterprise Edition or Standard Edition as

appropriate for your environment. Click Next.

Page 19: Oracle 11g 2 Day DBA Hands-On

19

7. The Install Location window appears. Enter the Oracle Base directory path in which to install the

Oracle software or accept the default. Under the Software Location region of the window, enter the

name and path for the base location for storing Oracle software files, or, accept the default values.

Click Next.

Page 20: Oracle 11g 2 Day DBA Hands-On

20

8. The Oracle Universal Installer will now verify that your system meets all the minimum requirements

for installing and configuring the chosen products. Correct any reported issues before continuing.

Click Next.

Page 21: Oracle 11g 2 Day DBA Hands-On

21

9. The Select Configuration Option window appears. Select Create a Database and click Next.

Page 22: Oracle 11g 2 Day DBA Hands-On

22

10. The Select Database Configuration window appears. Select the starter database type of General

Purpose/Transaction Processing, Data Warehouse , or Advanced. Click Next.

Page 23: Oracle 11g 2 Day DBA Hands-On

23

11. The Specify Database Configuration Options window appears. Enter the Global Database Name and

SID in the appropriate fields. Click Next.

Page 24: Oracle 11g 2 Day DBA Hands-On

24

12. The Specify Database Config Details window appears. From here, you can configure memory,

character sets, security, and sample schema information. For the Memory, Character Sets, and

Security tabs, accept the default values. Navigate to the Sample Schemas tab. Select Create

database with sample schemas. Click Next.

Page 25: Oracle 11g 2 Day DBA Hands-On

25

13. The Select Database Management Option window appears. Select Use Database Control for

Database Management. Click Next.

Page 26: Oracle 11g 2 Day DBA Hands-On

26

14. The Specify Database Storage Option window appears. Select File System or Automatic Storage

Management as appropriate to your environment. Click Next.

Page 27: Oracle 11g 2 Day DBA Hands-On

27

15. The Specify Backup and Recovery Options window appears. Select Do not enable Automated

backups to configure your own backup schedule. Click Next.

Page 28: Oracle 11g 2 Day DBA Hands-On

28

16. The Specify Database Schema Passwords window appears. You can choose the option, Use different

passwords for these accounts, and enter passwords for the administrative users, or select Use the

same password for all the accounts and enter one password. Click Next.

Page 29: Oracle 11g 2 Day DBA Hands-On

29

17. The Privileged Operating System Groups window appears. Modify the different groups if necessary

and click Next.

Page 30: Oracle 11g 2 Day DBA Hands-On

30

18. The Oracle Configuration Manager Registration window appears. This is used to associate your

configuration information with your Metalink account. For this exercise, bypass this option and click

Next.

Page 31: Oracle 11g 2 Day DBA Hands-On

31

19. The Summary window appears containing a list of the products to be installed. Click Install to begin

the installation.

Page 32: Oracle 11g 2 Day DBA Hands-On

32

The Install progress window is displayed.

Page 33: Oracle 11g 2 Day DBA Hands-On

33

20. The Configuration Assistants window appears. Allow the assistants to execute. They configure your

network, start an Oracle Net Services listener process for connecting to the database, create the

database and configure management tools.

Page 34: Oracle 11g 2 Day DBA Hands-On

34

The Database Configuration Assistant window showing a progress bar for database creation appears.

Page 35: Oracle 11g 2 Day DBA Hands-On

35

21. When the database creation is finished, a window containing information about your database

appears. Review this list. You may click Password Management if you want to unlock or change

passwords for database accounts. Otherwise click OK.

Page 36: Oracle 11g 2 Day DBA Hands-On

36

The Configuration Assistants window appears again, followed immediately by the Execute

Configuration scripts dialog box.

Page 37: Oracle 11g 2 Day DBA Hands-On

37

22. Before continuing with the installation, two separate scripts must be run as the root user. Open a new

terminal window, log in as root, and execute the orainstRoot.sh script found under the

/u01/app/oracle/oraInventory directory (as described in the dialog page).

Navigate to the /u01/app/oracle/product/11.1.0/db_1 directory and execute the root.sh script.

Page 38: Oracle 11g 2 Day DBA Hands-On

38

When the scripts finish, return to the Execute Configuration scripts page and click OK.

23. The End of Installation page appears with important information about the Web application. Click

Exit.

Page 39: Oracle 11g 2 Day DBA Hands-On

39

Click Yes. You have now completed the installation of Oracle software and database creation.

Using the Database Configuration Assistant (DBCA) to Create a Database

If you choose to install software only and later create a database, or if you want to create

additional databases using the software that you just installed, you can do so by using the

Database Configuration Assistant (DBCA).

Page 40: Oracle 11g 2 Day DBA Hands-On

40

Note: If you created a database as part of the Basic Installation or Advanced Installation, you do

not need to complete this section.

Follow the steps below to create a new database or a second database if you created a database as

part of the software installation:

1. Log onto your computer as a member of the administrative group that is authorized to install Oracle

software and create and manage the database.

2. Launch the DBCA on a Linux or UNIX operating system by entering the following at a command

prompt:

dbca

3. The Welcome window appears. Click Next.

Page 41: Oracle 11g 2 Day DBA Hands-On

41

4. Select Create a Database in the Operations window to begin a process that enables you to

configure and create a database. Click Next.

5. On the Database Templates window, select the type of database template to be used in creating the

database. You can click Show Details to see the configuration for each type of database. Choose the

template suited to the type of workload your database will support. If you are not sure, select the

default General Purpose or Transaction Processing template. Click Next.

Page 42: Oracle 11g 2 Day DBA Hands-On

42

6. On the Database Identification window, enter a Global Database Name and SID. Click Next.

Note: If you created a database as part of your installation of the Oracle software and you are

creating a second database with DBCA (as in this example), you must choose a different global

database name and SID for your second database.

Page 43: Oracle 11g 2 Day DBA Hands-On

43

7. The Management Options window appears. To use Enterprise Manager, select Configure Enterprise

Manager. Select Configure Database Control for local management to manage your database

locally as appropriate to your configuration. Click Next.

Page 44: Oracle 11g 2 Day DBA Hands-On

44

8. On the Database Credentials window, you can choose to use different administrative passwords or

use the same password for all accounts. Select one of the options and enter your password data. Click

Next.

Page 45: Oracle 11g 2 Day DBA Hands-On

45

9. For storage options, select File System, Automatic Storage Management, or Raw Devices as

appropriate to your environment. Click Next.

Page 46: Oracle 11g 2 Day DBA Hands-On

46

10. Specify the location for the creation of the datafiles. Choose one of the following:Use Database File

Locations from Template, Use Common Location for All Database Files, or Use Oracle-

Managed Files. Click Next.

Page 47: Oracle 11g 2 Day DBA Hands-On

47

11. Select Specify Flash Recovery Area and enter a directory location and size. Select Enable

Archiving to place your database in ARCHIVELOG mode. Click Next.

Page 48: Oracle 11g 2 Day DBA Hands-On

48

12. Click the Sample Schemas tab. Select Sample Schemas if you want to include the Sample Schemas

(EXAMPLE) tablespace in your database. Click Next.

Page 49: Oracle 11g 2 Day DBA Hands-On

49

13. The Memory window appears. Select Typical and enter a Memory Size (SGA and PGA). Click the

Sizing tab.

Page 50: Oracle 11g 2 Day DBA Hands-On

50

14. The Sizing window appears. Specify the smallest block size and the maximum number of operating

system user processes that can simultaneously connect to the database.

Note: You cannot specify the block size if you are using a template.

Click the Character Sets tab.

Page 51: Oracle 11g 2 Day DBA Hands-On

51

15. The Character Sets window appears. Select the character set for your database. Click the Connection

Mode tab.

Page 52: Oracle 11g 2 Day DBA Hands-On

52

16. The Connection Mode window appears. Select Dedicated Server Mode or Shared Server Mode as

appropriate for your environment. Click Next.

Page 53: Oracle 11g 2 Day DBA Hands-On

53

17. The Security Settings window appears. Accept the default value and click Next.

Page 54: Oracle 11g 2 Day DBA Hands-On

54

18. The Automatic Maintenance Tasks window appears. On this window you can configure the database

to automatically manage maintenance tasks. Select the Enable automatic maintenance tasks option.

Click Next.

Page 55: Oracle 11g 2 Day DBA Hands-On

55

19. On the Database Storage window, you can specify storage parameters for the database creation.

Accept the default values. Click Next.

Page 56: Oracle 11g 2 Day DBA Hands-On

56

20. On the Creation Options window, select Create Database to create your database. You can also

select Save as a Database Template to save your configuration. Click Finish.

Page 57: Oracle 11g 2 Day DBA Hands-On

57

21. At the Confirmation window, confirm the options that will be installed and click OK.

Page 58: Oracle 11g 2 Day DBA Hands-On

58

22. Your database is now being created.

Page 59: Oracle 11g 2 Day DBA Hands-On

59

After the database is created, you can change or unlock your passwords or click Exit.

Page 60: Oracle 11g 2 Day DBA Hands-On

60

Summary

In this tutorial, you learned how to:

Install the basic version of the database.

Install the advanced version of the database including running the Database

Configuration Assistant.

Create a database using the Database Configuration Assistant.

Page 61: Oracle 11g 2 Day DBA Hands-On

61

Chapter 3: Getting Started with Oracle Enterprise Manager

Purpose

This chapter introduces you to Oracle Enterprise Manager Database Control. The Oracle

Universal Installer installs Oracle Enterprise Manager Database Control when you install the

Oracle software. Enterprise Manager Database Control provides a Web-based interface that you

can use to manage your Oracle instance and database.

Time to Complete

Approximately 1 hour

Topics

This tutorial covers the following topics:

Prerequisites

Starting the Enterprise Manager dbconsole Process

Accessing Enterprise Manager Database Control

Granting EM Administrative Privileges to Other Users

Defining Blackout Periods

Setting Preferred Credentials

Summary

Prerequisites

Before you perform this tutorial, you should:

1. Complete Chapter 2: Installing Oracle Software and Building the Database OBE

Starting the Enterprise Manager dbconsole Process

The dbconsole process must be started for you to access Oracle Enterprise Manager Database

Control from a client browser. The dbconsole process is automatically started after installation. If

the process is not started, you can manually start it at the command line.

1. Log on to the operating system as the oracle user. Issue the following command to view the

status of the dbconsole process:

emctl status dbconsole

Page 62: Oracle 11g 2 Day DBA Hands-On

62

2. Issue the following command to start the dbconsole process:

emctl start dbconsole

Accessing Enterprise Manager (EM) Database Control

You can access the Oracle Enterprise Manager Database Control as follows:

1. Open your Web browser and enter the following URL:

https://<hostname>:1158/em

2. The Database Control Login page is displayed if the instance is started. Enter a username and

password for a user that is authorized to access the Oracle Enterprise Manager Database Control.

Click Login.

Page 63: Oracle 11g 2 Day DBA Hands-On

63

Note: If this is the first time you have accessed Enterprise Manager Database Control, you may see a

page concerning licensing. Review the information and respond appropriately to your situation.

Refer to Chapter 4 for detailed instructions on starting the instance and opening the database.

3. The Database Home page is displayed. You can access the Performance, Availability, Server,

Schema, Database Movement, and Software and Support property pages from the Database

Home page.

Page 64: Oracle 11g 2 Day DBA Hands-On

64

Granting EM Administrative Privileges to Other Users

In this section you will learn how to grant management privileges to other database users.

Administrators are database users defined in the Management Repository who can log in to

Enterprise Manager to perform management tasks. The breadth of management tasks available in

Enterprise Manager depends on the privileges and roles assigned to the administrators.

Perform the steps listed below to grant management privileges to other database users:

1. Click Setup in the right-hand corner at the top of the Database Home page.

2. Click on the Administrator tab in the left menu. The Administrators list is displayed.

Page 65: Oracle 11g 2 Day DBA Hands-On

65

3. Click Create to create a new Enterprise Manager user by assigning the management privileges to an

existing database user. The Create Administrator: Properties page is displayed.

4. In this step you will grant administrative privileges to the HR user. Enter the following values:

Name: HR

Password: HR

Note: You can click the flashlight icon next to the Name field to select an existing database user

Page 66: Oracle 11g 2 Day DBA Hands-On

66

from the pop-up window.

Click Review.

5. The Create Administrator: Review page appears. Click Finish.

6. The Administrators page appears again and your new administrator is included in the administrator

list.

Page 67: Oracle 11g 2 Day DBA Hands-On

67

Click the Database tab to return to the Availability page.

Defining Blackout Periods

When you plan to bring your database down for maintenance, you can indicate that you do not

want alert notifications to be sent to you by defining a blackout period. Blackouts also allow you

to suspend monitoring in order to perform other maintenance operations. You can define a

blackout time period in Enterprise Manager Database Control by performing the following steps:

1. If already in the Setup page, click Blackouts in the left hand pane.

Page 68: Oracle 11g 2 Day DBA Hands-On

68

2. The Blackouts page appears. Click Create to start the Create Blackout wizard.

Page 69: Oracle 11g 2 Day DBA Hands-On

69

3. Enter a name for your blackout in the Name field. You can also add comments in the Comments

field although it is not a required a field. Select Enter a new reason and enter a reason for your

blackout. Select Database Instance in the type drop-down menu in the Available Targets region.

Select your database and click Move to add it to the Selected Targets list. (Note: The DB target name

may differ, depending on your installation). Click Next.

Page 70: Oracle 11g 2 Day DBA Hands-On

70

4. The Create Blackout: Schedule page appears. Enter the start time of your planned blackout, or choose

immediately if you are shutting down the database now. Select the duration of the blackout, either as

indefinite, as a length or time, or until a time in the future. Accept the default of "Do Not Repeat" or

select a repeat frequency in the Repeat pull down menu. Click Next.

Page 71: Oracle 11g 2 Day DBA Hands-On

71

5. The Create Blackout: Review page appears. Review what you have entered and click Finish. You

can click Back if you need to change a setting.

Page 72: Oracle 11g 2 Day DBA Hands-On

72

6. You receive a confirmation message that your blackout has been defined.

Page 73: Oracle 11g 2 Day DBA Hands-On

73

Setting Preferred Credentials

You can set Preferred Credentials so that Enterprise Manager will automatically supply host and

database login credentials for you when you schedule jobs and tasks to perform administrative

operations like backup and recovery. For security, Oracle stores preferred credentials in

encrypted mode. You can set preferred credentials in Enterprise Manager Database Control by

performing the following steps:

1. Click Preferences at the top of the Database Home page.

2. The Preferences page appears. Click Preferred Credentials in the left hand pane.

Page 74: Oracle 11g 2 Day DBA Hands-On

74

3. The Preferred Credentials page appears. Click the icon under Set Credentials for the Database

Instance Target Type.

Page 75: Oracle 11g 2 Day DBA Hands-On

75

4. The Database Preferred Credentials page appears. Enter the credentials in the form of username and

password for normal, SYSDBA and host connections. Click Test.

5. You receive a confirmation message that your credentials have been verified. Click Apply to save

Page 76: Oracle 11g 2 Day DBA Hands-On

76

your preferred credentials.

Summary

In this tutorial, you learned how to:

Start and verify the status of the dbconsole process.

Log into Enterprise Manager (EM) Database Control.

Granting administrator privileges to other users.

Define a blackout period for you database instance.

Set preferred credential information in EM to be used later for administrative tasks.

Page 77: Oracle 11g 2 Day DBA Hands-On

77

Chapter 4: Configuring the Network Environment

Purpose

This chapter helps you to configure and manage your network environment so that users can

access your database.

Time to Complete

Approximately 1 hour

Topics

This tutorial covers the following topics:

Prerequisites

Using the Enterprise Manager Net Services Administration Page

Starting and Stopping the Listener Using the Listener Control Utility

Configuring Local Naming for Connecting to Other Databases

Summary

Prerequisites

Before you perform this tutorial, you should:

1. Complete Chapter 2: Installing Oracle and Building the Database OBE

2. Complete Chapter 3: Getting Started with Oracle Enterprise Manager OBE

Using the Enterprise Manager Net Services Administration Page

The Net Services Administration page can be used to manage Oracle Net services.

Follow the steps below to access the Net Services Administration page:

1. Log in to Enterprise Manager Database Console by opening your browser and specifying the SYS

username and password.

Click Login.

Page 78: Oracle 11g 2 Day DBA Hands-On

78

2. Click the Listener link in the General section of the Database Home page.

Page 79: Oracle 11g 2 Day DBA Hands-On

79

3. The Listener Home page is displayed. Click Net Services Administration in the Related Links

section at the bottom of the page.

4. The Net Services Administration page is displayed. This page provides a means of administering

listeners, directory naming, local naming, and specifying the file location.

Page 80: Oracle 11g 2 Day DBA Hands-On

80

Starting and Stopping the Listener Using the Listener Control Utility

In this section you learn how to start and stop the listener using the listener control utility. These

steps are applicable when you cannot access Enterprise Manager Database Control to start or

stop your listener.

Perform the steps listed below to check the status of the listener, to stop the listener, and to start

the listener using the listener control utility:

1. Log on to the operating system as the oracle user. You can check the status of the listener by

issuing the following command, where listener is the name of your listener:

lsnrctl status listener

Page 81: Oracle 11g 2 Day DBA Hands-On

81

2. If your listener is started, issue the following command to stop the listener:

lsnrctl stop listener

Page 82: Oracle 11g 2 Day DBA Hands-On

82

If your listener is already stopped, proceed to step 3.

3. Issue the following command to start the listener:

lsnrctl start listener

Page 83: Oracle 11g 2 Day DBA Hands-On

83

Configuring Local Naming for Connecting to Other Databases

In this section you configure local naming to connect to another database. You can configure

local naming using Net Manager on a client PC or using Enterprise Manager as described in the

following sections:

A Configuring Local Naming Using Net

Manager

B. Configuring Local Naming Using Enterprise

Manager

Configuring Local Naming Using Net Manager

You must configure a client machine so it can connect to an Oracle database. You must first

install Oracle Database client software, which includes Oracle Net software. Once you have

installed Oracle Net, you can use Oracle Net Manager to configure a net service name using the

local naming method as follows:

1. On UNIX or Linux, invoke Oracle Net Manager by entering netmgr at the command line.

The Welcome window appears.

Page 84: Oracle 11g 2 Day DBA Hands-On

84

2. Expand Local and select Service Naming. Click the (plus) + on the left hand side of the page.

Page 85: Oracle 11g 2 Day DBA Hands-On

85

3. Click Edit > Create.

Page 86: Oracle 11g 2 Day DBA Hands-On

86

4. The Net Service Welcome window appears. Enter a net service name. Click Next.

Page 87: Oracle 11g 2 Day DBA Hands-On

87

5. Select the protocol to use to connect to your database. You can accept the default TCP/IP (Internet

Protocol). The database listener must be configured to use the same network protocol. Click Next.

Page 88: Oracle 11g 2 Day DBA Hands-On

88

6. Enter the host name of the database machine. Click Next.

7. Enter the database service name. In addition, select a Connection Type, either Shared or Dedicated.

If you are unsure or would like to use the default database connection type, select Database Default.

Click Next.

Page 89: Oracle 11g 2 Day DBA Hands-On

89

8. The last window of the wizard enables you to test the connection using the information you entered.

Click Test.

Page 90: Oracle 11g 2 Day DBA Hands-On

90

9. By default, the user named SCOTT is used for the test. If this account is locked as shown in the

example, you can change the default login by clicking Change Login and entering a different

username and password. Click Change Login.

10. Enter a username and password to test the connection. You can use system with the password of

oracle. Click OK.

Page 91: Oracle 11g 2 Day DBA Hands-On

91

11. Click Test.

12. The wizard tells you if the connection test succeed or not. Click Close.

Page 92: Oracle 11g 2 Day DBA Hands-On

92

13. Click Finish.

Page 93: Oracle 11g 2 Day DBA Hands-On

93

14. The new service appears under the Service Naming folder. You can view or modify the configuration

for the highlighted service under Service Identification and Address Configuration.

Page 94: Oracle 11g 2 Day DBA Hands-On

94

15. Save your changes and exit out of Oracle Net Manager window by clicking File -> Save Network

Configuration and then File -> Exit.

Page 95: Oracle 11g 2 Day DBA Hands-On

95

Configuring Local Naming Using Enterprise Manager

Perform the steps listed below to configure a net service name using Enterprise Manager as

follows:

1. Click the Listener link in the General section of the Database Home page.

Page 96: Oracle 11g 2 Day DBA Hands-On

96

2. The Listener Home page is displayed. Scroll down to the bottom of the page. Click Net Services

Administration in the Related Links section.

3. The Net Services Administration page is displayed. Select the appropriate Configuration File

Location. Select Local Naming from the Administer list. Click Go.

Page 97: Oracle 11g 2 Day DBA Hands-On

97

4. Enter your host username and password, select Save as Preferred Credential, and click Login.

5. The Local Naming page is displayed. Click the Create button or select an existing Net Service Name

and click Create Like.

Page 98: Oracle 11g 2 Day DBA Hands-On

98

6. The Create Net Service Name General page is displayed. Enter a name in the Net Service Name

field. In the Database Information section, configure service support by entering a destination service

and selecting a database connection type. If the destination service is an Oracle8i or later release

database, then select Use Service Name, and enter a service name in the Service Name field. If the

destination service is an Oracle release 8.0 database, then select Use SID, and enter an Oracle System

Identifier for an instance in the SID field. Then scroll down to the bottom of the page. In the

Addresses section, configure protocol support. Click Add.

Note: If you are performing this task on the same machine that you configured local naming using

Net Manager, be sure to enter a different name in the Net Service Name field.

Page 99: Oracle 11g 2 Day DBA Hands-On

99

7. The Add Address page is displayed. From the Protocol list, select the protocol upon which the

listener is configured to listen. Enter the Port and Host fields. These must match the listening

address. Click OK.

Page 100: Oracle 11g 2 Day DBA Hands-On

100

8. The Create Net Service Name page is displayed again. Click OK. A successful creation message is

displayed on the Local Naming page.

9. Select the net service name you just created. Click Test Connection.

Page 101: Oracle 11g 2 Day DBA Hands-On

101

10. Enter the password, dbsnmp, for the user dbsnmp. Click Test.

11. The Test Result page is displayed. Click OK.

Page 102: Oracle 11g 2 Day DBA Hands-On

102

Summary

In this tutorial, you learned how to:

Log into the Net Services Administration application.

Start and stop the listener using the lsnrctl command.

Configure a client machine to connect to an Oracle database using Oracle Net

Manager.

Create a Local Naming entry using Enterprise Manager.

Page 103: Oracle 11g 2 Day DBA Hands-On

103

Chapter 5: Managing the Oracle Instance

Purpose

This chapter focuses on the tasks involved in managing your instance. In this chapter, you will

learn how to use the property pages in the Instance region of the Administration page of

Enterprise Manager.

Time to Complete

Approximately 1 hour

Topics

This tutorial covers the following topics:

Prerequisites

Using Enterprise Manager to Start Up and Shut Down the Oracle Instance

Viewing Initialization Parameters

Managing Memory Parameters

Summary

Prerequisites

Before you perform this tutorial, you should:

1. Complete Chapter 2: Installing Oracle Software and Building the Database OBE

2. Complete Chapter 3: Getting Started with Oracle Enterprise Manager OBE

3. Complete Chapter 4: Configuring the Network Environment OBE

Using Enterprise Manager to Start Up and Shut Down the Instance

The instance is idle until it is started. When the instance is started, an initialization parameter file

is read and the instance is configured accordingly. After the instance is started and the database

is opened, users can access the database. In this section, you will examine the following tasks:

A Starting the Instance

B. Shutting Down the Instance

Starting the Instance

You can use Enterprise Manager to start the instance and open the database by performing the

following steps:

Page 104: Oracle 11g 2 Day DBA Hands-On

104

1. Invoke Enterprise Manager from your browser. The Database page is displayed indicating that the

instance is down. Click Startup to start the instance.

2. The Startup/Shutdown:Specify Host and Target Database Credentials page is displayed. Enter the

host credentials and database credentials. Select Save as Preferred Credentials. Click OK.

Page 105: Oracle 11g 2 Day DBA Hands-On

105

3. The Startup/Shutdown:Confirmation page is displayed. Click Yes to start the instance and open the

database.

4. The Startup/Shutdown:Activity page is displayed.

Page 106: Oracle 11g 2 Day DBA Hands-On

106

5. After the instance is started and the database is open, the Login page is displayed. Enter the username

and password to log in to Enterprise Manager Database Control. Click Login.

6. The Database home page is displayed.

Page 107: Oracle 11g 2 Day DBA Hands-On

107

Shutting Down the Instance

You can use Enterprise Manager to shut down the instance and close the database by performing

the following steps:

1. Log in to Enterprise Manager Database Console by opening your browser and specifying the SYS

username and password.

Click Login.

2. Click Shutdown on the Database Home page.

Page 108: Oracle 11g 2 Day DBA Hands-On

108

3. The Startup/Shutdown:Specify Host and Target Database Credentials page appears. Enter the host

credentials and database credentials. Click OK.

4. The Startup/Shutdown:Confirmation page appears. Click Yes to perform the shutdown operation.

Page 109: Oracle 11g 2 Day DBA Hands-On

109

5. The Startup/Shutdown:Activity Information page appears. Click Refresh.

6. You can now perform maintenance or backup and recovery operations on your database. When you

have finished, you must restart the database before you can access the data.

Page 110: Oracle 11g 2 Day DBA Hands-On

110

Viewing Initialization Parameters

The initialization parameter file contains a list of configuration parameters for the instance and

database. The Oracle database server reads these parameters at database startup and monitors

them while the database is running. The values of the parameters are stored in memory and many

can be changed dynamically.

Follow the steps below to view the values of the initialization parameters for your database:

1. Click Server on the Database Home page to access the Administration property page.

2. Click Initialization Parameters in the Database Configuration section.

Page 111: Oracle 11g 2 Day DBA Hands-On

111

3. The Initialization Parameters page appears. For example, to search for a specific parameter or a group

of parameters that contain 'archive,' input archive in the Name field. Click Go.

4. All of the parameters that include the word "archive" appear in the list.

Page 112: Oracle 11g 2 Day DBA Hands-On

112

5. Scroll to the top of the page. Click Database to return to the Database Home page.

Managing Memory Parameters

In this section you learn how to view the values of the memory parameters in your database.

Memory parameters are the initialization parameters that determine the total size of the system

global area (SGA) and its sub-components, and the program global area (PGA). The values of

the memory parameters can affect the performance of your database.

If the Oracle server advises you of a performance problem relating to the size of the SGA or

PGA, you can use the memory advisor to help you determine appropriate new settings. The

memory advisor can model the effect of parameter changes. Refer to Chapter 10 for information

on using the memory advisors.

Perform the steps listed below to view the values of the memory parameters:

Page 113: Oracle 11g 2 Day DBA Hands-On

113

1. Click Server on the Database Home page to access the Administration property page.

2. Click Memory Advisors in the Database Configuration section.

3. The Memory Parameters page appears. Click Database to return to the Database Home page.

Page 114: Oracle 11g 2 Day DBA Hands-On

114

Summary

In this tutorial, you learned how to:

Startup and shutdown the Oracle instance.

Review the initialization parameters associated with the instance.

Use the Memory Advisors page to assess the memory parameters for the

instance.

Page 115: Oracle 11g 2 Day DBA Hands-On

115

Chapter 6: Managing Database Storage Structures

Purpose

In this chapter you will learn how to use Enterprise Manager to explore the structure of your

database. In addition, you will learn how to make a number of changes to your database storage

structure.

Time to Complete

Approximately 1 hour

Topics

This tutorial covers the following topics:

Prerequisites

Exploring the Storage Structure of your Database

Creating a New Tablespace

Modifying a Tablespace

Multiplexing the Redo Log

Managing Undo in your Database

Summary

Prerequisites

Before you perform this tutorial, you should:

1. Complete Chapter 2: Installing Oracle Software and Building the Database OBE

2. Complete Chapter 3: Getting Started with Oracle Enterprise Manager OBE

3. Complete Chapter 4: Configuring the Network Environment OBE

4. Complete Chapter 5: Managing the Oracle Instance OBE

Exploring the Storage Structure of your Database

You can use Enterprise Manager to manage the storage structures in your database. In this

section you'll access the pages for different storage structures to become familiar with their

contents. In later sections you'll use the pages to manage the storage structure in your database.

Follow the steps below to use Enterprise Manager to explore the storage structure of your

database:

Page 116: Oracle 11g 2 Day DBA Hands-On

116

1. Click Server on the Database Home page to access the Server property page.

2. Click Control Files in the Storage section to access the Control Files page.

The control files and their status is displayed on the Control Files General page. There are two other

property pages, in addition to the General page, for viewing control file information. Click Advanced

to view additional information about the control file.

Page 117: Oracle 11g 2 Day DBA Hands-On

117

The Advanced page details information about the database stored in the control file. Click Record

Section to view information stored in the control file.

The Record Section page displays detailed information about the control file record section. Return to

the Server page by clicking the database link at the top of the page.

Page 118: Oracle 11g 2 Day DBA Hands-On

118

3. Click Tablespaces on the Server page to access the Tablespaces property page. The Tablespaces

page provides high-level information about tablespace structure and space usage. You can see how

much space is allocated for the tablespace and what portion of it is used.

Select the Example tablespace and click View to display more information about the tablespace.

Page 119: Oracle 11g 2 Day DBA Hands-On

119

You see more information about the tablespace. Return to the Server page by clicking the database

link at the top of the page.

Page 120: Oracle 11g 2 Day DBA Hands-On

120

4. Click Datafiles on the Server page to access the Datafiles property page. The Datafiles page provides

a list of the datafiles that comprise your database.

Select the example01.dbf datafile and click View.

Page 121: Oracle 11g 2 Day DBA Hands-On

121

You see more information about the datafile. Return to the Server page by clicking the database link

at the top of the page.

5. Click Redo Log Groups on the Server page to access the Redo Log Groups property page. The Redo

Log Groups page shows the attributes of the redo log groups for your database.

Page 122: Oracle 11g 2 Day DBA Hands-On

122

Return to the Server page by clicking the database link at the top of the page.

6. Click Archive Logs on the Administration page to access the Archive Logs property page. The

Archive Logs page shows the attributes of the archived redo log files for your database.

Return to the Server page by clicking the database link at the top of the page.

Page 123: Oracle 11g 2 Day DBA Hands-On

123

Creating a New Tablespace

In this section you will learn how to create a new tablespace for your database.

Perform the steps listed below to create the FSDATA tablespace. This tablespace will be used to

store the tables of your database. Repeat these steps to create the FSINDEX tablespace which

will be used for storage of the indexes in your database.

1. Click Tablespaces on the Server page to access the Tablespaces property page.

Click Create.

Page 124: Oracle 11g 2 Day DBA Hands-On

124

2. The Create Tablespace page appears. Enter FSDATA in the Name field. Select Locally Managed

under the Extent Management heading. Select Permanent under the Type heading. Select Read

Write under the Status heading. Click Add in the Datafiles region of the page.

Page 125: Oracle 11g 2 Day DBA Hands-On

125

3. The Add Datafile page appears. Enter a file name in the File Name field on the Add Datafiles page.

Accept the defaults for the File Directory and File Size or enter new values. Select the option Reuse

Existing File. Select Automatically extend datafile when full (AUTOEXTEND) and specify an

amount in the Increment field by which you want to extend the datafile each time it fills. Click

Continue.

Page 126: Oracle 11g 2 Day DBA Hands-On

126

4. You are returned to the Create Tablespace General page. Click the Storage tab.

Page 127: Oracle 11g 2 Day DBA Hands-On

127

5. The Storage page appears. Accept all of the defaults on the Storage page. Click OK to create your

tablespace.

6. You are returned to the Tablespaces page where you receive a confirmation of the creation of the

tablespace. You can view your new tablespace in the Results region.

Page 128: Oracle 11g 2 Day DBA Hands-On

128

7. Repeat steps 2 through 6 to create the FSINDEX tablespace. This tablespace will be used to store the

indexes in your database. Return to the Server page by clicking the database link at the top of the

page.

Modifying a Tablespace

You can modify a tablespace using Enterprise Manager. You can add additional space to the

tablespace by adding datafiles or extending the existing datafiles. In addition you can enable

automatic extension so that the tablespace will automatically extend when full. There are a

number of other changes you can make including changing space thresholds and changing the

tablespace status to offline.

In this example you will change the automatic extension increment for the UNDOTBS1

tablespace and specify an upper limit for the datafile belonging to the tablespace.

Follow the steps below to modify the UNDOTBS1 tablespace:

Page 129: Oracle 11g 2 Day DBA Hands-On

129

1. Click Tablespaces on the Server page to access the Tablespaces property page. Select UNDOTBS1

and click Edit.

2. The Edit Tablespace page appears. Select the datafile associated with the tablespace and click Edit.

Page 130: Oracle 11g 2 Day DBA Hands-On

130

3. The Edit Datafile page appears. Select Automatically extend datafile when full (AUTOEXTEND).

Specify 1 MB for the increment value and 60 MB for the maximum file size. Click Continue.

Page 131: Oracle 11g 2 Day DBA Hands-On

131

4. The Edit Tablespace page appears. Click Apply.

5. An update message is displayed confirming your change. Click the database link to return to the

Server page.

Page 132: Oracle 11g 2 Day DBA Hands-On

132

Multiplexing the Redo Log

You can multiplex your redo log by adding additional members to each redo log group.

Follow the steps below to add a new member to each of your redo log groups:

1. Click Redo Log Groups in the Storage subsection on the Server page to access the Redo Log Groups

property page.

2. Select group 1 and click Edit. The Edit Redo Log Group page appears.

Page 133: Oracle 11g 2 Day DBA Hands-On

133

3. Click Add in the Redo Log Members section. The Add Redo Log Member page appears.

4. Enter redo01a.log for the Name and enter the file directory. Click Continue.

Note: You can create your new member in the same directory, but it is recommended that you store

members on separate drives. If there is a drive failure, you will still have one member for the log

writer to use.

5. You are returned back to the Edit Redo Log Group page. Verify your entry and click Apply to add

your new member.

Page 134: Oracle 11g 2 Day DBA Hands-On

134

6. You receive a confirmation of the addition of a new member to your log group.

7. Return to the Redo Log Groups property page and repeat steps 3 through 7 for each of your log

groups using the file naming convention: redo<group number>a.log.

Click the database link to return to the Server page.

Page 135: Oracle 11g 2 Day DBA Hands-On

135

Managing Undo in your Database

Undo management entails storing the changes of database transactions long enough to

accommodate rollback, read consistency, and flashback features. Auto-tuning of the undo

retention period is enabled when you create your database. In this section, you will perform the

following tasks:

A Using the Undo Management Page

B. Using the Undo Advisor

Using the Undo Management Page

You can use the Undo Management page to view undo configuration, including the auto-tuned

undo retention period, its low threshold retention period, and the name and size of the undo

tablespace. Auto-tuning of undo retention cannot be disabled.

You can access the Undo Management page as follows:

1. Click Automatic Undo Management in the Database Configuration region to access the Automatic

Undo Management page.

2. The Automatic Undo Management page is displayed. Under the General tab, you can view the

current undo settings for your instance and use the Undo Advisor to analyze the undo tablespace

requirements. Click System Activity.

Page 136: Oracle 11g 2 Day DBA Hands-On

136

3. Under System Activity tab, you can look at the system activity for a specified time period, including

longest running query, average and maximum undo generation rate, and queries failed due to low

retention.

Click the database link to return to the Server page.

Page 137: Oracle 11g 2 Day DBA Hands-On

137

Using the Undo Advisor

The undo tablespace is set to auto-extend by default when you use DBCA to configure your

database. If your undo tablespace is not auto-extensible, you may need to extend the tablespace.

You can use the undo advisor to obtain advise on the undo tablespace size.

You can access the undo advisor as follows:

1. Click Automatic Undo Management in the Database Configuration region to access the Automatic

Undo Management page.

Page 138: Oracle 11g 2 Day DBA Hands-On

138

2. The Automatic Undo Management page is displayed. Scroll down the page to the Undo Advisor

section. Click on the Analysis Time Period drop-down menu and select Last One Day. Click Run

Analysis.

3. The Analysis Results are displayed. Click Show Graph to view a graphical representation.

Page 139: Oracle 11g 2 Day DBA Hands-On

139

4. The tablespace size required to meet your specifications is displayed in the Analysis section as well

as a graphical representation of this information.

Page 140: Oracle 11g 2 Day DBA Hands-On

140

Summary

In this tutorial, you learned how to:

Review the structure of the control files, tablespaces, datafiles, and redo log files.

Create the FSDATA tablespace.

Modify the automatic extension increment for a tablespace.

Add another member to a redo log group.

Modify the undo parameters using the Automatic Undo Management page in EM or the Undo

Advisor.

Page 141: Oracle 11g 2 Day DBA Hands-On

141

Chapter 7: Administering Users and Security

Purpose

You must create user accounts and grant appropriate database access privileges to those accounts

so that users can access your database. Some user accounts are automatically included in the pre-

configured database, but for security reasons, most of these accounts are locked and expired. In

this chapter you will learn how to create and manage user accounts. You will use Enterprise

Manager to create a role and two users in your database. You will also unlock the HR user

account.

Time to Complete

Approximately 1 hour

Topics

This tutorial covers the following topics:

Prerequisites

Administering Database Users

Administering Roles

Summary

Prerequisites

Before you perform this tutorial, you should:

1. Complete Chapter 2: Installing Oracle Software and Building the Database OBE

2. Complete Chapter 3: Getting Started with Oracle Enterprise Manager OBE

3. Complete Chapter 4: Configuring the Network Environment OBE

4. Complete Chapter 5: Managing the Oracle Instance OBE

5. Complete Chapter 6: Managing Database Storage Structures OBE

Administering Database Users

Users connect to the database by using a user account that you create in the database. A user

account is identified by a username and defines the user’s attributes. In this section you will

create a new user and give the user privileges to connect to the database and create objects in the

database.

In this section, you will perform the following tasks:

A Creating New Users

Page 142: Oracle 11g 2 Day DBA Hands-On

142

B. Changing User Attributes

C. Unlocking Accounts and Resetting

Passwords

D. Granting Privileges

Creating New Users

Follow the steps below to create the FSOWNER user:

1. Log in to Enterprise Manager Database Console by opening your browser and specifying the SYS

username and password.

Click Login.

2. Navigate to the Server page. Click Users in the Security section.

3. The Users property page appears. Click Create.

Page 143: Oracle 11g 2 Day DBA Hands-On

143

4. The Create User General page appears. Enter the following values in the fields:

Username: FSOWNER

Password: FSOWNER

Default tablespace: FSDATA

Temporary tablespace: TEMP

Status: Unlocked

Click OK.

Page 144: Oracle 11g 2 Day DBA Hands-On

144

5. The Users property page is displayed with an Update message confirming the creation of your user.

You can also see the new user by scrolling down the page. Click the Database link to return to the

Server page.

Page 145: Oracle 11g 2 Day DBA Hands-On

145

Changing User Attributes

In this section you will learn how to change user attributes. The FSOWNER user will create

objects in the database and needs to have quota on the FSDATA tablespace to create objects in it.

Perform the steps listed below to enable the FSOWNER user to create objects in the FSDATA

tablespace:

1. Click Users in the Security section on the Serverpage to access the Users property page. Select

FSOWNER in the results list and click Edit.

2. The Edit User General page is displayed. Click Quotas to display the Quotas page.

Page 146: Oracle 11g 2 Day DBA Hands-On

146

3. Select Unlimited from the Quota drop-down menu for the FSDATA tablespace. Click Apply.

4. The Edit User page appears with an Update message confirming your change. Note the quota value

of -1 indicating Unlimited.

Page 147: Oracle 11g 2 Day DBA Hands-On

147

Click the Users link to return to the Users property page.

Unlocking Accounts and Resetting Passwords

If an account is locked, the user cannot log in to the database. During installation, you were

given the option to unlock and reset the Oracle supplied database user accounts. If you did not

choose to unlock those accounts at that time, you can do so by following the steps below. In this

example, you will unlock the HR user account and reset the password. The same steps can be

executed for each account you want to unlock and/or need to reset the password for.

1. On the Users page, select HR in the results list and select Unlock User in the pull-down menu in the

Actions box. Click Go.

Page 148: Oracle 11g 2 Day DBA Hands-On

148

2. Click Yes to confirm the unlock operation.

3. The Users property page is displayed with an Update message confirming the unlocking of your

user. You can see the EXPIRED status for the HR user in the Results section. Select HR in the results

list and click Edit.

Page 149: Oracle 11g 2 Day DBA Hands-On

149

4. The Edit User General page is displayed. Enter oracle for the new password and click Apply.

Click the Users link to return to the Users property page. The status in the Account Status column

Page 150: Oracle 11g 2 Day DBA Hands-On

150

now displays OPEN.

Granting Privileges

In this section you will learn how to grant privileges. The FSOWNER user will create objects in

the database and needs privileges to create those objects.

Perform the steps listed below to enable the FSOWNER user to create objects in the database:

1. On the Users page, select FSOWNER in the results list and click Edit.

Page 151: Oracle 11g 2 Day DBA Hands-On

151

2. The Edit User General page is displayed. Click System Privileges.

Page 152: Oracle 11g 2 Day DBA Hands-On

152

3. The System Privileges page appears. Click Edit List.

4. The Modify System Privileges page is displayed. Click each of the following privileges and click

Move to select it: CREATE ANY INDEX and CREATE ANY TABLE. Click OK.

5. The Edit User page is displayed with the selected system privileges. Click Apply to grant the

privileges.

Page 153: Oracle 11g 2 Day DBA Hands-On

153

6. The Edit User page is displayed with the Update message confirming the change. Note that

FSOWNER will not be able to connect to the database until the CREATE SESSION privilege has

been granted (which occurs in the following section).

Click the Users link to return to the Users page.

Administering Roles

You can use roles to group privileges and other roles to facilitate the granting of multiple

privileges and roles to users. There are a number of predefined roles. In addition, you can create

roles that are applicable for the operations and objects that exist in your database.

In this section, you will examine the following tasks:

Page 154: Oracle 11g 2 Day DBA Hands-On

154

A Creating Roles

B. Granting Roles

Creating Roles

In this section you will create a role to contain the privileges needed. In a later chapter you will

grant object privileges to the role.

Follow the steps below to create the FSCLERK role:

1. Click the database link to return to the Server page. Click Roles in the Security section.

2. The Roles property page appears. Click Create.

Page 155: Oracle 11g 2 Day DBA Hands-On

155

3. The Create Role page appears. Enter fsclerk in the Name field. Click System Privileges.

4. The System Privileges page is displayed. Click Edit List to select system privileges to grant to the

role.

Page 156: Oracle 11g 2 Day DBA Hands-On

156

5. Select CREATE SESSION from Available System Privileges and click Move. Click OK.

6. The Create Role page appears again. Click OK to create the role with the selected privileges.

Page 157: Oracle 11g 2 Day DBA Hands-On

157

7. The Roles page appears again with an update message confirming the creation of the FSCLERK role.

You can scroll down to see the role you just created.

Click the Database link to return to the Server page.

Granting Roles

In this section you will learn how to grant roles to users. The FSOWNER user needs the privileges

in the FSCLERK role.

Perform the steps listed below to provide the FSOWNER with the privileges in the FSCLERK

role:

1. Click Users in the Security section on the Server page to access the Users property page. Select

FSOWNER in the results list and click Edit.

Page 158: Oracle 11g 2 Day DBA Hands-On

158

2. The Edit User General page is displayed. Click Roles.

3. The Roles page appears. Click Edit List.

Page 159: Oracle 11g 2 Day DBA Hands-On

159

4. The Modify Roles page is displayed. Select FSCLERK from the Available Roles and click Move to

select it. Click OK.

5. The Edit User page is displayed with the selected roles. Click Apply to grant the role.

Page 160: Oracle 11g 2 Day DBA Hands-On

160

6. The Edit User page is displayed with the Update message confirming the change.

Summary

In this tutorial, you learned how to:

Create a new user.

Change the attributes associated with a user.

Unlock a user account and set a new password.

Grant system privileges to a user.

Create a role and assign the new role to an existing role.

Page 161: Oracle 11g 2 Day DBA Hands-On

161

Chapter 8: Managing Schema Objects

Purpose

A schema is a collection of database objects. A schema is owned by a database user and has the

same name as that user. Schema objects are logical structures created by users to contain, or

reference, their data. Schema objects include structures like tables, views, and indexes. You can

create and manipulate schema objects using Oracle Enterprise Manager.

Time to Complete

Approximately 1 hour

Topics

This tutorial covers the following topics:

Prerequisites

Accessing Schema Objects

Managing Tables

Managing Indexes

Managing Views

Managing Database Resident Program Units

Loading Data into Tables

Summary

associated with that step. You can hide an individual screenshot by clicking it.

Prerequisites

Before you perform this tutorial, you should:

1. Complete Chapter 2: Installing Oracle Software and Building the Database OBE

2. Complete Chapter 3: Getting Started with Oracle Enterprise Manager OBE

3. Complete Chapter 4: Configuring the Network Environment OBE

4. Complete Chapter 5: Managing the Oracle Instance OBE

5. Complete Chapter 6: Managing Database Storage Structures OBE

6. Complete Chapter 7: Administering Users and Security OBE

Accessing Schema Objects

Follow the steps below to access schema objects using Enterprise Manager:

Page 162: Oracle 11g 2 Day DBA Hands-On

162

1. Log in to Enterprise Manager Database Console by opening your browser and specifying the SYS

username and password.

Click Login.

2. Click Schema and select the Tables link in the Database Objects section.

3. Select the flashlight icon to select a particular schema.

4. Select HR and click Select.

Page 163: Oracle 11g 2 Day DBA Hands-On

163

5. Enter emp in the Object Name field and click Go.

Page 164: Oracle 11g 2 Day DBA Hands-On

164

6. The objects that match your search criteria are displayed.

Managing Tables

Tables are the basic unit of data storage in an Oracle database. They hold all user-accessible data.

Each table has columns and rows. In this section, you will perform the following tasks:

A Viewing the Attributes of a Table

B. Viewing the Contents of a Table

C. Creating a New Table

D. Modifying a Table

E. Dropping a Table

Viewing the Attributes of a Table

Follow the steps below to view the attributes of the HR.EMPLOYEES table:

Page 165: Oracle 11g 2 Day DBA Hands-On

165

1. Click on the EMPLOYEES table.

2. The View Table page appears displaying the attributes of the table including columns, constraints,

and storage options.

Page 166: Oracle 11g 2 Day DBA Hands-On

166

Click the Tables link to return to the Tables property page.

Viewing the Contents of a Table

Perform the steps listed below to view the contents of the HR.EMPLOYEES table:

1. Select the EMPLOYEES table and select View Data from the Actions list. Click Go.

Page 167: Oracle 11g 2 Day DBA Hands-On

167

2. The View Data for Table page appears showing the row data in the Result section. Click the Tables

link to return to the Tables property page.

Page 168: Oracle 11g 2 Day DBA Hands-On

168

Creating a New Table

In this section you will create three new tables for your database: EMPLOYEES, CUSTOMERS,

and ORDERS.

1. Click Create on the Tables property page.

2. The Create Table: Table Organization page appears. Select Standard, Heap Organized and click

Continue.

3. The Create Table page appears. Enter employees in the Name field. Enter fsowner in the

Schema field. Enter fsdata in the Tablespace field. Define the columns as follows and click Add 5

Page 169: Oracle 11g 2 Day DBA Hands-On

169

Table Columns.

Name: EMPLOYEE_ID, Data Type: NUMBER, Size: 6

Name: FIRST_NAME, Data Type: VARCHAR2, Size: 20

Name: LAST_NAME, Data Type: VARCHAR2, Size: 25

Name: EMAIL_ADDRESS, Data Type: VARCHAR2, Size: 25

Name: PHONE_NUMBER, Data Type: VARCHAR2, Size: 20

4. Enter the remaining columns as follows:

HIRE_DATE DATE

JOB_ID VARCHAR2(10)

SALARY NUMBER(8)

MANAGER_ID NUMBER(6)

Click Constraints.

Page 170: Oracle 11g 2 Day DBA Hands-On

170

5. The Constraints page appears. Select PRIMARY from the drop-down list and click Add.

Page 171: Oracle 11g 2 Day DBA Hands-On

171

6. The Add PRIMARY Constraint page appears. Enter emp_id_pk in the Name field. Select

EMPLOYEE_ID in the Available Columns list. Click Move to select it. Click Continue.

Page 172: Oracle 11g 2 Day DBA Hands-On

172

7. The Create Table page appears. Click OK.

8. The Tables page appears with an Update message indicating your table has been created.

9. Repeat steps 2 through 8 to create the CUSTOMERS and ORDERS tables in the FSOWNER schema as

defined below. Name the primary key for the Customers table, CUST_ID_PK, and for the Orders

table, ORD_PK_ID.

CUSTOMERS

Column Type PK?

CUSTOMER_ID NUMBER(6) Y

CUST_FIRST_NAME VARCHAR2(20)

CUST_LAST_NAME VARCHAR2(20)

STREET_ADDRESS VARCHAR2(40)

CITY VARCHAR2(30)

STATE VARCHAR2(10)

POSTAL_CODE VARCHAR2(10)

Page 173: Oracle 11g 2 Day DBA Hands-On

173

PHONE_NUMBER VARCHAR2(20)

ORDERS

Column Type PK?

ORDER_ID NUMBER(12) Y

ORDER_DATE DATE

ORDER_MODE VARCHAR2(8)

CUSTOMER_ID NUMBER(6)

DELIVERY_MODE VARCHAR2(8)

ORDER_STATUS NUMBER(2)

SALES_CLERK_ID NUMBER(6)

ORDER_TOTAL NUMBER(8,2)

Modifying a Table

You can use Enterprise Manager to modify tables, such as adding and deleting columns or

adding constraints. In this section you will add a constraint to the EMPLOYEES table you

created. You will ensure that the EMAIL_ADDRESS column contains a value by adding a NOT

NULL constraint.

Follow the steps below to add a NOT NULL constraint to your EMPLOYEES table:

1. Select the EMPLOYEES table and click Edit.

Page 174: Oracle 11g 2 Day DBA Hands-On

174

2. Check the Not NULL column for the EMAIL_ADDRESS column. Click Apply.

Page 175: Oracle 11g 2 Day DBA Hands-On

175

3. The Edit Table page is displayed with a message confirming your update.

Click the Tables link to return to the Tables page.

Dropping a Table

You can drop (delete) a table by using Enterprise Manager as follows. For the purposes of this

exercise, you will create a new table and then drop the table.

1. Click the Tables link in the Database Objects section on the Schema page to access the Tables

property page. Enter HR in the Schema Name field and JOBS in the Object Name field. Click Go.

Page 176: Oracle 11g 2 Day DBA Hands-On

176

2. Select Create Like from the Actions list. Click Go.

3. The Create Table page appears. Enter JOBS_HIST in the Name field. Deselect Not Null for the

JOB_ID and JOB_TITLE columns. Click Constraints.

Page 177: Oracle 11g 2 Day DBA Hands-On

177

4. The Constraints page appears. Delete the constraints on the table by selecting each and clicking

Delete. They are not needed for this exercise. Click General to return to the General page.

5. Click OK to create the JOBS_HIST table.

Page 178: Oracle 11g 2 Day DBA Hands-On

178

6. A message is displayed indicating that the table has been created.

7. Enter JOBS_HIST in the Object Name field and click Go.

Page 179: Oracle 11g 2 Day DBA Hands-On

179

8. The Tables page is displayed with the JOBS_HIST table in the Results section. Click Delete With

Options to the delete the JOBS_HIST table.

9. Select Delete the table definition, all its data, and dependent objects. Click Yes.

Page 180: Oracle 11g 2 Day DBA Hands-On

180

10. A message is displayed indicating the table has been deleted. Click Go to attempt to retrieve the

table.

11. No object found is displayed in the results section indicating your table has been dropped (deleted).

Click the database link to return to the Schema page.

Page 181: Oracle 11g 2 Day DBA Hands-On

181

Managing Indexes

Indexes are optional structures associated with tables and can be used to improve query

performance. An index provides a quick access path to table data. Indexes can be created on one

or more columns of a table. After an index is created, it is automatically maintained and used by

the Oracle Database server. Changes to a table’s data or structure are automatically incorporated

into all relevant indexes with complete transparency to the user.

In this section, you will perform the following tasks:

A Viewing the Attributes of an Index

B. Creating a New Index

Viewing the Attributes of an Index

Perform the steps listed below to view the attributes of an index in your FSOWNER schema:

1. Click the Indexes link in the Database Objects section on the Schema page to access the Indexes

property page.

2. The Indexes page appears. Enter FSOWNER in the Schema field and click Go.

Page 182: Oracle 11g 2 Day DBA Hands-On

182

3. The indexes created when you defined primary keys are displayed. Select the EMP_ID_PK index

defined on the EMPLOYEES table by clicking the index name link.

Page 183: Oracle 11g 2 Day DBA Hands-On

183

4. The View Index page for EMP_ID_PK index in the FSOWNER schema is displayed.

Click the Indexes link to return to the Indexes property page.

Creating a New Index

Create an index on the CUSTOMER_ID column in the ORDERS table so that you can quickly

access all orders for a specified customer. The index should be stored in the FSINDEX

tablespace.

Perform the steps listed below to create the ORD_CUSTID_IDX index:

1. Select Table from the Object Type list. The page is refreshed. Enter FSOWNER in the Schema field

and click Go.

Page 184: Oracle 11g 2 Day DBA Hands-On

184

2. The Tables page appears. Select the ORDERS table and select Create Index from the Actions list.

Click Go.

Page 185: Oracle 11g 2 Day DBA Hands-On

185

3. The Create Index page appears. Enter ORD_CUSTID_INDX in the Name field. Enter fsdata in

the Tablespace field. Select Standard - B-tree as the index type. Select the CUSTOMER_ID column

by entering 1 in the Order column. Accept ASC as the Sorting Order. Click OK to create the index.

You receive a message that the index was created. Click the database instance link to return to the

Schema page.

Page 186: Oracle 11g 2 Day DBA Hands-On

186

Managing Views

Views are customized presentations of data in one or more tables or other views. They can be

thought of as stored queries. Views do not actually contain data, but instead they derive their data

from the tables upon which they are based. These tables are referred to as the base tables of the

view. Like tables, views can be queried, updated, inserted into, and deleted from, with some

restrictions. All operations performed on a view actually affect the base tables of the view.

Views provide an additional level of security by restricting access to a predetermined set of rows

and columns of a table. They also hide data complexity and store complex queries.

In this section, you will perform the following tasks:

A Accessing Views

B. Creating a New View

Accessing Views

Perform the steps listed below to access views:

1. Select Views in the Database Objects section of the Schema page.

2. On the Views property page, enter HR in the Schema field and click Go.

Page 187: Oracle 11g 2 Day DBA Hands-On

187

3. The views defined on tables in the HR schema are displayed. Select the EMP_DETAILS_VIEW and

click View to view its definition.

4. The View page is displayed showing the definition of the view.

Page 188: Oracle 11g 2 Day DBA Hands-On

188

Click the Views link to return to the Views page.

Creating a New View

Perform the steps listed below to create a new view:

1. Click Create on the Views property page.

Page 189: Oracle 11g 2 Day DBA Hands-On

189

2. Enter the following information and click OK.

View name: CLERK10_ORDS

Schema: FSOWNER

Query text:

SELECT order_id, customer_id, order_total FROM orders WHERE

sales_clerk_id = 10

Page 190: Oracle 11g 2 Day DBA Hands-On

190

3. The Views page is displayed confirming the creation of your view.

Click the Database Instance link to return to the Schema page.

Managing Database Resident Program Units

You can use Enterprise Manager to manage database resident program units such as PL/SQL

packages, procedures, triggers, and functions and Java sources and classes. The actions include

creating and compiling the database resident program units, creating synonyms for the database

resident program units, granting privileges to use the database resident program units, and

showing dependencies for the database resident program units.

Page 191: Oracle 11g 2 Day DBA Hands-On

191

1. Click the Procedures link in the Programs section on the Schema page.

2. Enter hr in the Schema field. Click Go.

3. Select the ADD_JOB_HISTORY procedure. Select Object Privileges from the Actions list and click

Go.

Page 192: Oracle 11g 2 Day DBA Hands-On

192

4. Click Add.

5. Select EXECUTE as the privilege and FSOWNER as the user. Click OK.

Page 193: Oracle 11g 2 Day DBA Hands-On

193

6. Click Apply.

7. You receive a confirmation message. Click the Database tab to return to the Database Home page.

Page 194: Oracle 11g 2 Day DBA Hands-On

194

Loading Data Into Tables

You can use Enterprise Manager to load data into tables in batch. Batch loading is useful when

you have a lot of data. You can load data from operating system files or from other databases.

You can also export data into files. One method of loading is to use control (.ctl) and data

(.dat) files. These files are formatted as standard SQL*Loader files. SQL*Loader is a utility

that you can use to load data from external files into tables of an Oracle database.

In this section you will load customer information into your FSOWNER.CUSTOMERS table using

the load_cust.ctl file. Create a directory named $HOME/labs. Download the

load_cust.zip file and unzip the load_cust.ctl and load_cust.dat files into

$HOME/labs for use in this section.

1. Click the Load Data from User Files link in the Move Row Data section on the Data Movement

page.

Page 195: Oracle 11g 2 Day DBA Hands-On

195

2. The Load Data: Generate or Use Existing Control File page appears. Select Use Existing Control

File. Also enter the username and password for the host machine. Click Continue.

Enter the full path of your control file on the database server machine and click Next. (Note: For this

example, you will use the control file included with the load_cust.zip file).

Page 196: Oracle 11g 2 Day DBA Hands-On

196

3. The Load Data: Data File page appears. Select Provide the full path and name on the database

server machine. Input the full path of your dat file on the database server machine. (Note: For this

example, you will use the .dat file included with the load_cust.zip file).Click Next.

4. The Load Data: Load Method page appears. Accept the default of Conventional Path as the loading

method. Click Next.

Page 197: Oracle 11g 2 Day DBA Hands-On

197

5. The Load Data: Options page appears. Select Generate log file in the Optional Files region. You can

accept the default file name and path or enter a different one. Click Next.

Page 198: Oracle 11g 2 Day DBA Hands-On

198

6. The Load Data: Schedule page appears. Enter a name in the Job Name field and description in the

Description field. Select Immediately to run the job now. Click Next.

7. The Load Data: Review page appears. Review your file names and loading methods. If you want to

change something, you can click on the Back button. Otherwise, click Submit Job to start the

loading.

Page 199: Oracle 11g 2 Day DBA Hands-On

199

8. The Status page appears with a message indicating the job was created. Click the job name link to

view the job summary.

9. This summary page should indicate that the job has succeeded. If not, you can view the log file by

clicking on your job under the Logs heading or by viewing the log file directly.

Page 200: Oracle 11g 2 Day DBA Hands-On

200

10. You can confirm the data load by navigating to the Tables page, entering FSOWNER in the Schema

field, clicking Go, selecting the table, and selecting View Data from the Actions list. Click Go.

Page 201: Oracle 11g 2 Day DBA Hands-On

201

11. The rows you loaded are displayed on the View Data for Table: FSOWNER.CUSTOMERS page.

Click OK to return to the Tables property page. Click Database to return to the Database Home

page.

Page 202: Oracle 11g 2 Day DBA Hands-On

202

Click the Database tab to return to the Database Home page.

Summary

In this tutorial, you learned how to:

Query for tables in a specific schema.

Create an table and view the attributes and contents of the new table.

Create a view.

Manage database resident program units.

Load data into an existing table.

Page 203: Oracle 11g 2 Day DBA Hands-On

203

Chapter 9: Performing Backup and Recovery

Purpose

This chapter introduces you to Oracle Database backup and recovery operations as performed

through Enterprise Manager.

Time to Complete

Approximately 1 hour

Topics

This tutorial covers the following topics:

Prerequisites

Configuring the Flash Recovery Area and ARCHIVELOG mode

Configuring Backup Settings and Policies

Determining your DBID and the value of DB_UNIQUE_NAME

Performing a Whole Database Backup

Backing Up Your Database Using the Oracle-Suggested Backup Strategy

Restoring and Recovering Your Whole Database

Performing Flashback Table

Performing Flashback Drop

Managing Backups

Turn Off Archiving

Summary

Prerequisites

Before you perform this tutorial, you should:

1. Complete Chapter 2: Installing Oracle Software and Building the Database OBE

2. Complete Chapter 3: Getting Started with Oracle Enterprise Manager OBE

3. Complete Chapter 4: Configuring the Network Environment OBE

4. Complete Chapter 5: Managing the Oracle Instance OBE

5. Complete Chapter 6: Managing Database Storage Structures OBE

6. Complete Chapter 7: Administering Users and Security OBE

7. Complete Chapter 8: Managing Schema Objects OBE

Configuring the Flash Recovery Area and ARCHIVELOG Mode

The flash recovery area is a unified storage location for all recovery related files and activities in

an Oracle database. All files that are needed to completely recover a database from a media

Page 204: Oracle 11g 2 Day DBA Hands-On

204

failure are part of the flash recovery area. The recovery related files that can be created in the

flash recovery area include: archived redo log files, control files, backups created by Recovery

Manager (RMAN), flashback logs, and the change tracking file. Oracle recommends the change

tracking file be created on the same disks as the database files. In fact, if you set up OMF, and

you issue the command to enable change tracking, the file is automatically created in the

directory specified for the database files.

By allocating a storage location and unifying related recovery files within a specific area, the

Oracle database server relieves the database administrator from having to manage the disk files

created by these components.

When setting up a flash recovery area, you choose a directory, file system or Automatic Storage

Management disk group to hold the files, and set a disk quota for the maximum space to be used

for all files stored in the flash recovery area. You must choose a location large enough to

accommodate the required disk quota. When the disk space limit is approached, the Oracle server

can delete nonessential files to make room for new files, subject to the limitations of the RMAN

retention policy.

The flash recovery area should be on a separate disk from the working area, where active

database files such as datafiles, control files, online redo logs, and change tracking files used in

incremental backups are stored. Keeping the flash recovery area on the same disk as the working

area exposes you to loss of both your live database files and backups in the event of a disk

failure.

You can configure the flash recovery area and ARCHIVELOG mode when you create the

database. If you did not perform these tasks when you created the database, follow the steps

below to configure the flash recovery area and ARCHIVELOG mode:

1. At the operating system prompt, increase the size for the backup and recovery areas. Execute the

following commands:

sqlplus system/oracle

alter system set db_recovery_file_dest_size=8G scope=both;

exit

Page 205: Oracle 11g 2 Day DBA Hands-On

205

2. At the operating system prompt, create a directory for the flash recovery area. Execute the following

commands:

cd $ORACLE_BASE

mkdir flash_rec_area

Page 206: Oracle 11g 2 Day DBA Hands-On

206

3. Log in to Enterprise Manager Database Console by opening your browser and specifying the SYS

username and password as SYSDBA. Click Login.

Page 207: Oracle 11g 2 Day DBA Hands-On

207

4. Click Availability on your Oracle Database Home page.

5. Select Recovery Settings in the Backup/Recovery Settings section. You can use the Recovery

Settings page to configure the settings for the recovery utility, including the Flash Recovery Area.

6. The Recovery Settings page appears. Scroll to the Flash Recovery section. If the flash recovery area

is not enabled for your database, configure the flash recovery area by entering the following values in

the appropriate fields:

Flash Recovery Area Location: <directory you created in step 1>

Page 208: Oracle 11g 2 Day DBA Hands-On

208

Flash Recovery Area Size: 8 GB

7. Scroll up to the top of the window. Check ARCHIVELOG Mode to configure ARCHIVELOG

mode for your database. Click Apply.

8. The Verify Flash Recovery Area Location: Specify Host Credentials window appears. Enter the host

credentials to ensure appropriate access has been granted. Click Continue.

Page 209: Oracle 11g 2 Day DBA Hands-On

209

9. A message confirming your changes is displayed. To complete the configuration of ARCHIVELOG

mode, the database instance must be shut down. Click Yes to shut down the instance and restart it.

10. The Restart Database:Specify Host and Target Database Credentials page is displayed. Enter your

host credentials and database credentials. Click OK.

Page 210: Oracle 11g 2 Day DBA Hands-On

210

11. The Restart Database:Confirmation page is displayed. Click Yes to shut down the instance and restart

it.

Page 211: Oracle 11g 2 Day DBA Hands-On

211

12. The Restart Database:Activity Information page is displayed. Click Refresh to log in to Enterprise

Manager Database Control and log back into Enterprise Manager once the database has been

restarted.

Configuring Backup Settings and Policies

You can configure a number of settings and policies that determine how backups are stored,

which data is backed up, how backups perform, and how long backups are retained before being

purged from the recovery area. You can also configure features to improve backup performance.

1. Click Availability on your Oracle Database Home page.

Page 212: Oracle 11g 2 Day DBA Hands-On

212

2. Select Backup Settings in the Backup/Recovery Setup section.

3. Scroll to the Host Credentials region on the Backup Settings page. Enter the operating system

username and password. Scroll up to the Disk Settings section.

4. Accept the value of 1 in the Parallelism field. The Disk Backup Location field is set to null so that the

flash recovery area will be used for backups. Select Backup Set for Disk Backup Type. Click Test

Disk Backup.

Page 213: Oracle 11g 2 Day DBA Hands-On

213

5. A message is displayed indicating the disk settings backup test was successful. Now you will

configure backup policy settings. Click Policy to access the Policy page.

Page 214: Oracle 11g 2 Day DBA Hands-On

214

6. Select Automatically backup the control file and server parameter file (SPFILE) with every

backup and database structural change. Select Optimize the whole database backup by

skipping unchanged files such as read-only and offline datafiles that have been backed up.

Select Enable block change tracking for faster incremental backups. Enter a file name for the

Block Change Tracking file. Then scroll down to the Retention Policy section.

7. Select Retain backups that are necessary for a recovery to any time within the specified number

of days (point-in-time recovery) and accept the default of 31 days. Under the Archivelog Deletion

Policy, select Delete archivelogs after it has specified number of backups and accept the default

of 1 backup. Click OK. You are returned to the Availability page.

Page 215: Oracle 11g 2 Day DBA Hands-On

215

Determining Your DBID and the Value of DB_UNIQUE_NAME

If you lose your database control file or SPFILE, Enterprise Manager can restore them from

backup, as long as you can provide the DB_UNIQUE_NAME and DBID for your database.

Perform the steps below to determine the value of DB_UNIQUE_NAME:

1. Click the Server tab. Click Initialization Parameters in the Database Configuration region.

Page 216: Oracle 11g 2 Day DBA Hands-On

216

2. The Current property page appears. Enter db_unique_name in the Name field and click Go.

3. The resulting page displays a row with db_unique_name in the Name column, and the

db_unique_name value for your database in the Value column.

Page 217: Oracle 11g 2 Day DBA Hands-On

217

Record this value so that you will have it should you need it in the future for a recovery operation.

Click the Database Instance link to return to the Server page.

Perform the steps below to determine your DBID:

1. Click Control Files in the Storage region of the Server page.

2. The Control Files property page appears. Select the Advanced property page.

Page 218: Oracle 11g 2 Day DBA Hands-On

218

3. The Database ID field contains the DBID value. (Note: Your machine will have a different value).

Record this value so that you will have it should you need it in the future for a recovery operation.

Click the Database Instance link to return to the Server page.

Page 219: Oracle 11g 2 Day DBA Hands-On

219

Performing a Whole Database Backup

You can backing up the entire contents of your database by performing a whole database backup.

Full backups of all datafiles are created. The results may be stored as image copies or as backup

sets, but in either case the complete contents of all datafiles of the database are represented in the

backup, as well as the control file, archived redo log and server parameter file. The database can

be recovered completely with this set of files.

1. Click the Availability tab. Select Schedule Backup in the Manage region.

2. The Schedule Backup page appears. In the Customized Backup section, select Whole Database.

Enter the username and password in the Host Credentials section if required. Click Schedule

Customized Backup.

Page 220: Oracle 11g 2 Day DBA Hands-On

220

3. The Schedule Customized Backup: Options page appears. Select Full Backup in the Backup Type

section. Select Online Backup in the Backup Mode section. Select Also back up all archived logs

on disk in the Advanced section. Click Next.

Page 221: Oracle 11g 2 Day DBA Hands-On

221

4. The Schedule Backup: Settings page appears. Select Disk or Tape as appropriate. Click Next.

Page 222: Oracle 11g 2 Day DBA Hands-On

222

5. The Schedule Backup: Schedule page appears. Accept the default Job Name. Select Immediately to

execute the job immediately or enter a time to execute at a later time. Click Next.

6. The Schedule Backup: Review page appears. Click Submit Job.

Page 223: Oracle 11g 2 Day DBA Hands-On

223

7. The Backup Submit Successful message is displayed.

8. Click View Job to view the status of the backup.

Page 224: Oracle 11g 2 Day DBA Hands-On

224

9. Scroll down to the bottom of the page. In this table, you can view the status of the backup and if each

step completes successfully. Note that backing up the database may take some time to complete.

Before continuing with the next exercise, ensure that you have gone through the entire process until

all three steps of the backup (Prebackup, Backup, and Post Backup) are successful.

Click the Database Instance link to return to the Server page.

Backing Up Your Database Using the Oracle-Suggested Backup Strategy

The Oracle-suggested backup strategy is based on creating an image copy of your database

which is rolled forward using RMAN incremental backups. Oracle Enterprise Manager schedules

RMAN backups jobs. Follow the steps below to set up your backup schedule:

Page 225: Oracle 11g 2 Day DBA Hands-On

225

1. Click the Availability tab. Select Schedule Backup in the Manage region.

2. The Schedule Backup page appears. Scroll down to the Host Credentials section and enter the

username and password if required. Scroll back up and click Schedule Oracle-Suggested Backup.

3. The Schedule Oracle-Suggested Backup: Destination page appears. Select Disk for your backup

destination. Click Next.

Page 226: Oracle 11g 2 Day DBA Hands-On

226

4. The Schedule Backup: Setup page appears. Review the information and click Next.

5. The Schedule Backup: Schedule page appears. Review the information and adjust the start date and

time as appropriate (set the date for a couple day's from the current date). Click Next.

Page 227: Oracle 11g 2 Day DBA Hands-On

227

6. The Schedule Backup: Review page appears. Review the information and click Submit Job.

Page 228: Oracle 11g 2 Day DBA Hands-On

228

7. The Status page appears with a message indicating the job has been successfully submitted. You can

click View Job to access the job status page or click OK to complete the operation and return to the

Availability page.

Page 229: Oracle 11g 2 Day DBA Hands-On

229

Restoring and Recovering Your Whole Database

In this section you will recover your database by using Enterprise Manager.

1. Select Perform Recovery in the Manage region of the Availability page.

2. The Perform Recovery page appears. Under Recovery Scope, select Whole Database. Select

Recover to the current time or a previous point-in-time. Enter your operating system username

and password in the Host Credentials section. Click Recover.

Page 230: Oracle 11g 2 Day DBA Hands-On

230

3. The Confirmation page is displayed indicating that the instance will be shut down and restarted.

Click Yes to continue.

4. The Recovery Wizard page is displayed indicating that the instance will be shut down and restarted

(Note: you must wait a couple of minutes for this operation to complete). Click Refresh to continue

using the Recovery Wizard.

Page 231: Oracle 11g 2 Day DBA Hands-On

231

5. Click Home. You are returned to the Database Instance page displaying that the database is in

Mounted state. Click Perform Recovery.

6. Enter the host credentials and click Continue.

Page 232: Oracle 11g 2 Day DBA Hands-On

232

7. The Database Login window appears. Enter the appropriate credential information and click Login.

8. The Perform Recovery page appears.Under Recovery Scope, select Whole Database and click

Recover again to invoke the Recovery wizard.

Page 233: Oracle 11g 2 Day DBA Hands-On

233

9. The Perform Whole Database Recovery: Point-in-time page appears. Select Recover to the current

time. Click Next.

10. The Perform Whole Database Recovery: Rename page appears. Select No. Restore the files to the

default location if that is your choice or select Yes. Restore the files to a new, common location and

enter the location. Click Next.

Page 234: Oracle 11g 2 Day DBA Hands-On

234

11. The Perform Whole Database Recovery: Review page appears. Review the information and click

Submit.

12. The Processing: Perform Whole Database Recovery page is displayed.

Page 235: Oracle 11g 2 Day DBA Hands-On

235

13. You receive a confirmation that the operation succeeded. Click Open Database.

14. Click OK.

Page 236: Oracle 11g 2 Day DBA Hands-On

236

15. Enter the login information. Click Login. You are returned to the Availability page.

Page 237: Oracle 11g 2 Day DBA Hands-On

237

Performing Flashback Table

Complete the following tasks to perform a flashback table operation:

A Enable Row Movement

B. Simulate User Error

C. Perform Flashback Table

Enable Row Movement

You must enable row movement on a table in order to perform a flashback table operation on the

table. In this section you enable row movement on the HR.EMPLOYEES table.

1. Click the Schema tab.

2. Select Tables in the Database Objects section.

Page 238: Oracle 11g 2 Day DBA Hands-On

238

3. The Tables page appears. Enter HR in the Schema field and REGIONS in the Object Name field.

Click Go.

4. The REGIONS table is displayed in the Results section. Click Edit.

Page 239: Oracle 11g 2 Day DBA Hands-On

239

5. The Edit Table page appears. Click the Options tab.

Page 240: Oracle 11g 2 Day DBA Hands-On

240

6. Select Yes from the Enable Row Movement list. Click Apply.

Page 241: Oracle 11g 2 Day DBA Hands-On

241

7. You receive a message indicating your table has been successfully modified. Click the Tables

breadcrumb.

Page 242: Oracle 11g 2 Day DBA Hands-On

242

Simulate User Error

In this section you simulate user error by changing data in the REGIONS table. Perform the

following:

1. View data in the REGIONS table by opening a terminal window and executing the following

commands:

sqlplus hr/oracle

col region_name format a30

select * from regions;

2. Simulate user error by executing the following SQL command to change the value in the

region_name column in all rows:

update regions set region_name = 'ORACLE';

commit;

Page 243: Oracle 11g 2 Day DBA Hands-On

243

3. View your change by executing the following command again:

select * from regions;

In the Performing Flashback Table section, you will flashback the table to the point in time

before you updated the table.

Performing Flashback Table

In this section you will flashback to the HR.REGIONS table.

1. Verify that REGIONS is still selected in the list of tables on the Tables page in Enterprise Manager.

Select Flashback Table from the Actions drop-down menu. Click Go.

Page 244: Oracle 11g 2 Day DBA Hands-On

244

2. The Perform Object Level Recovery: Point-in-time page appears. Select Flashback to a timestamp

and enter a date and time of a few minutes ago. Click Next.

Page 245: Oracle 11g 2 Day DBA Hands-On

245

3. The Perform Object Level Recovery: Flashback Tables window appears. Click Next.

Page 246: Oracle 11g 2 Day DBA Hands-On

246

4. The Perform Object Level Recovery: Review page appears. Review the information on the page and

click Submit.

5. You receive a confirmation that the table has been flashed back. Click OK.

Page 247: Oracle 11g 2 Day DBA Hands-On

247

6. Return to your SQL*Plus session and execute the following command to view the results of the

flashback table operation:

select * from regions;

Performing Flashback Drop

In this section you will use the flashback drop feature to retrieve a table that has been dropped.

For the purposes of this exercise, you will create a new table, drop the table, and then recover it

using flashback drop.

Follow the steps below to create a new table and drop it:

1. Access the Tables property page. Enter HR in the Schema Name field and REGIONS or a part of the

name in the Object Name field and click Go.

Page 248: Oracle 11g 2 Day DBA Hands-On

248

2. Select Create Like from the Actions list. Click Go.

Page 249: Oracle 11g 2 Day DBA Hands-On

249

3. The Create Table page appears. Enter REG_HIST in the Name field. Deselect Not Null for the

REGION_ID column. Click Constraints.

4. The Constraints page appears. Delete the constraints on the table by selecting each and clicking

delete. They are not needed for this exercise. Click OK.

Page 250: Oracle 11g 2 Day DBA Hands-On

250

5. You receive a message indicating the table has been created.

6. Enter REG_HIST in the Object Name field and click Go.

Page 251: Oracle 11g 2 Day DBA Hands-On

251

7. The Tables page is displayed with the REG_HIST table in the Results section. Click Delete with

Options to delete the REG_HIST table.

Page 252: Oracle 11g 2 Day DBA Hands-On

252

8. Select Delete the table definition, all its data, and dependent objects (DROP). Click Yes to

confirm the deletion of the table.

9. A message is displayed indicating the table has been deleted. Click Go to attempt to retrieve the

table.

Page 253: Oracle 11g 2 Day DBA Hands-On

253

10. No object found is displayed in the results section.

Page 254: Oracle 11g 2 Day DBA Hands-On

254

To recover the table you just deleted, you will need to perform a flashback drop. Perform the

following:

1. On the Tables page, click Recycle Bin.

Page 255: Oracle 11g 2 Day DBA Hands-On

255

2. Enter HR in the Schema Name field and click Go.

Page 256: Oracle 11g 2 Day DBA Hands-On

256

3. Select REG_HIST and click Flashback Drop.

4. The Perform Object Level Recovery: Rename page appears. Click Next.

Page 257: Oracle 11g 2 Day DBA Hands-On

257

5. The Perform Recovery: Review page appears. Review the information and click Submit.

6. A confirmation message is displayed. Click OK.

Page 258: Oracle 11g 2 Day DBA Hands-On

258

7. The table is no long in the recycle bin. Click the Tables breadcrumb.

8. The REG_HIST table is now included in the tables list.

Page 259: Oracle 11g 2 Day DBA Hands-On

259

Click the Database Instance link to return to the Schema page.

Managing Backups

Indexes are optional structures associated with tables and can be used to improve query

performance. An index provides a quick access path to table data. Indexes can be created on one

or more columns of a table. After an index is created, it is automatically maintained and used by

the Oracle Database server. Changes to a table’s data or structure are automatically incorporated

into all relevant indexes with complete transparency to the user.

In this section, you will perform the following tasks:

A Using the Manage Current Backups Page

B. Crosschecking Backups

C. Deleting Expired Backups

D. Deleting Obsolete Backups

E. Cataloging Backups

Page 260: Oracle 11g 2 Day DBA Hands-On

260

Using the Manage Current Backups Page

You can use the Manage Current Backups page to view the backups that are recorded in the

RMAN repository. From this page, you can perform the backup maintenance operations

described throughout this section.

1. Access the Availability property page. Click Manage Current Backups in the Backup/Recovery -

Manage section.

2. The Manage Current Backups page appears. The Backup Sets property page displays the backup sets

that are recorded in the RMAN repository (note that your system may display different information).

Click the links in the Tag column to view detailed information about the contents of a backup set

(select one that displays "DATAFILES" in the Contents column).

Page 261: Oracle 11g 2 Day DBA Hands-On

261

3. The Contents property page is displayed. Click Manage Current Backups to return to the Manage

Current Backups property page.

Page 262: Oracle 11g 2 Day DBA Hands-On

262

4. Click Image Copies to view the Image Copies page.

Page 263: Oracle 11g 2 Day DBA Hands-On

263

5. If there are any Image Copies available, they are displayed in the Manage Current Backups page.

Note for this example, the backup was already restored and thus deleted.

Page 264: Oracle 11g 2 Day DBA Hands-On

264

Click the Database Instance link to return to the Availability page.

Crosschecking Backups

When you crosscheck a backup, RMAN verifies that the information recorded in the repository

is consistent with the physical backup status. If it is not, the repository is updated to reflect the

correct status. You can crosscheck all of your backup files as follows:

1. Click Manage Current Backups in the Backup/Recovery region on the Availability property page.

Page 265: Oracle 11g 2 Day DBA Hands-On

265

2. The Manage Current Backups page is displayed. Scroll down to the Host Credentials section and

enter the username and password if required. Click Crosscheck All at the top of the page to

crosscheck all files in the RMAN repository. (Note: Your system may display different information

for the backup sets).

Page 266: Oracle 11g 2 Day DBA Hands-On

266

3. The Crosscheck All: Specify Job Parameters page is displayed. You can accept the defaults for the

Job Name, Job Description, Start time, and Repeat specifications or enter your own values. Click

Submit Job to submit the crosscheck job.

4. A Job submission succeeded message is displayed on the Manage Current Backups page. You can

click View Job to view the status of the job. Note that this process may take a couple of minutes to

complete.

Page 267: Oracle 11g 2 Day DBA Hands-On

267

5. In the Summary region you can view the status of the job.

Click the Database tab to return to the Home page.

Page 268: Oracle 11g 2 Day DBA Hands-On

268

Deleting Expired Backups

You can delete all backups marked EXPIRED in the RMAN repository by performing the

following steps:

1. Click Manage Current Backups in the Backup/Recovery - Manage region on the Availability

property page.

2. The Manage Current Backups page is displayed. Scroll down to the Host Credentials section and

enter the username and password if required. Click Delete All Expired at the top of the page to

remove from the RMAN repository those backups which are marked EXPIRED.

Page 269: Oracle 11g 2 Day DBA Hands-On

269

3. The Delete All Expired: Specify Job Parameters page is displayed. You can accept the defaults for

the Job Name, Job Description, Start time, and Repeat specifications or enter your own values. Select

Perform the operation 'Crosscheck All' before 'Delete All Expired'. If you have not performed a

crosscheck operation. Click Submit Job.

Page 270: Oracle 11g 2 Day DBA Hands-On

270

4. A Job Submission Succeeded message is displayed on the Manage Current Backups page. You can

click View Job to view the status of the job.

5. In the Summary region you can view the status of the job.

Page 271: Oracle 11g 2 Day DBA Hands-On

271

Click the Database tab to return to the Home page.

Deleting Obsolete Backups

You can delete all obsolete backups by performing the following steps:

1. Click Manage Current Backups in the Backup/Recovery - Manage region on the Availability

property page.

Page 272: Oracle 11g 2 Day DBA Hands-On

272

2. The Manage Current Backups page is displayed. Scroll down to the Host Credentials section and

enter the username and password if required. Click Delete All Obsolete at the top of the page to

remove from the RMAN repository those backups which are obsolete. Note: You can do this from

the Backup Sets or Image Copies page.

3. The Delete All Obsolete: Specify Job Parameters page is displayed. You can accept the defaults for

the Job Name, Job Description, Start time, and Repeat specifications or enter your own values. Click

Submit Job.

Page 273: Oracle 11g 2 Day DBA Hands-On

273

4. A Job Submission Succeeded message is displayed on the Manage Current Backups page. You can

click View Job to view the status of the job.

5. In the Summary region you can view the status of the job.

Page 274: Oracle 11g 2 Day DBA Hands-On

274

Click the Database tab to return to the Home page.

6. You can return to the Image Copies and/or Backup Sets property pages to verify that the obsolete

backups have been deleted.

Cataloging Backups

You can catalog backups taken with operating system commands so that RMAN can use them in

a recovery operation. In this example, you will back up the datafile belonging to the EXAMPLE

tablespace using operating system commands. You will then catalog the backup file in the

RMAN repository using Enterprise Manager.

1. Invoke SQL*Plus and log on as a user with SYSDBA privileges. Place the EXAMPLE tablespace in

online backup mode by issuing the following command:

ALTER TABLESPACE example BEGIN BACKUP;

Page 275: Oracle 11g 2 Day DBA Hands-On

275

2. Return to the operating system prompt and make a copy of the datafile that belongs to the EXAMPLE

tablespace. In this example, the copy is being made into a directory called backup. You can use a

directory of your choice.

3. Take the EXAMPLE tablespace out of online backup mode by issuing the following command:

ALTER TABLESPACE example END BACKUP;

4. Now you are ready to catalog the backup in the RMAN repository by using Enterprise Manager

Database Control. Click Manage Current Backups in the Backup/Recovery - Manage region on the

Availability property page.

Page 276: Oracle 11g 2 Day DBA Hands-On

276

5. Scroll down to the Host Credentials section and enter the username and password if required. Click

Catalog Additional Files at the top of the Manage Current Backups page.

6. Select Catalog files in the specified disk location into the Recovery Manager repository and

enter the location and name of the backup file (without the file extension). Click OK.

Page 277: Oracle 11g 2 Day DBA Hands-On

277

7. A confirmation message is displayed indicating that the file has been cataloged. Click Image Copies

to access the Image Copies page and view your cataloged file.

8. Your newly cataloged file is listed in the Results section. Click Database to return to the Database

Home page.

Page 278: Oracle 11g 2 Day DBA Hands-On

278

Turn Off Archiving

To modify the database so it runs in NOARCHIVELOG mode, perform the following:

1. Click Availability on your Oracle Database Home page.

Page 279: Oracle 11g 2 Day DBA Hands-On

279

2. Select Recovery Settings in the Backup/Recovery - Setup section.

3. Deselect ARCHIVELOG Mode under Media Recovery. Click Apply.

4. A message confirming your changes is displayed. To complete the configuration of

NOARCHIVELOG mode, the database instance must be shut down. Click Yes to shut down the

instance and restart it.

Page 280: Oracle 11g 2 Day DBA Hands-On

280

5. The Restart Database:Specify Host and Target Database Credentials page is displayed. Enter your

host credentials and database credentials. Click OK.

6. The Restart Database:Confirmation page is displayed. Click Yes to shut down the instance and restart

it.

Page 281: Oracle 11g 2 Day DBA Hands-On

281

7. The Restart Database:Activity Information page is displayed. Click Refresh to log in to Enterprise

Manager Database Control and log back into Enterprise Manager once the database has been

restarted.

Summary

In this tutorial, you learned how to:

Configure the flash area.

Configure backup policies.

Confirm the DBID and the DB_UNIQUE_NAME values..

Perform a whole database backup.

Restore and recover the database.

Perform a Flashback table.

Manage your backups including deleting obsolete backups or using the cataloging

feature.

Page 282: Oracle 11g 2 Day DBA Hands-On

282

Chapter 10: Monitoring and Tuning the Database

Purpose

This chapter introduces you to some of the monitoring and tuning operations as performed

through Enterprise Manager.

Time to Complete

Approximately 1 hour

Topics

This tutorial covers the following topics:

Prerequisites

Proactively Monitoring your Database

Diagnosing and Resolving Performance Problems

Using the SQL Tuning Advisor

Using the SQL Access Advisor

Enabling Automatic Shared Memory Management using the Memory

Advisor

Summary

Prerequisites

Before you perform this tutorial, you should:

1. Complete Chapter 2: Installing Oracle Software and Building the Database OBE

2. Complete Chapter 3: Getting Started with Oracle Enterprise Manager OBE

3. Complete Chapter 4: Configuring the Network Environment OBE

4. Complete Chapter 5: Managing the Oracle Instance OBE

Page 283: Oracle 11g 2 Day DBA Hands-On

283

5. Complete Chapter 6: Managing Database Storage Structures OBE

6. Complete Chapter 7: Administering Users and Security OBE

7. Complete Chapter 8: Managing Schema Objects OBE

8. Complete Chapter 9: Performing Backup and Recovery OBE

Proactively Monitoring your Database

Alerts help you monitor your database proactively. Most alerts are notifications when particular

metrics thresholds are crossed. For each alert, you can set critical and warning threshold values.

These threshold values are meant to be boundary values that when crossed indicate that the

system is in an undesirable state.

In this section, you will perform the following tasks:

A Creating a Tablespace and Table with a Specified Treshold

B. Triggering a Tablespace Space Usage Alert

C. Setting up Notifications

Creating a Tablespace and Table with a Specified Threshold

First, you create a new tablespace with a 20 MB data file. This tablespace should be locally

managed, and use Automatic Segment Space Management (ASSM). You will then create a new

table in this new tablespace. This table will have the Enable Row Movement option set to yes to

allow for space reclamation in the table. Perform the following:

1. Click the Server link on the database home page.

Page 284: Oracle 11g 2 Day DBA Hands-On

284

2. Click the Tablespaces link.

3. Click the Create button.

Page 285: Oracle 11g 2 Day DBA Hands-On

285

4. Enter TBSALERT as the tablespace name and then click Add to define a datafile for the tablespace.

Page 286: Oracle 11g 2 Day DBA Hands-On

286

5. Enter tbsalert01.dbf as the datafile name and 20 MB as the filesize. Click Continue.

Page 287: Oracle 11g 2 Day DBA Hands-On

287

Click OK to create the tablespace.

6. Select your new tablespace, TBSALERT, and click Edit.

Page 288: Oracle 11g 2 Day DBA Hands-On

288

Click Thresholds to specify the space used warning and critical threshold levels.

Page 289: Oracle 11g 2 Day DBA Hands-On

289

7. Select Specify Thresholds in the Space Used (%) section. Enter 60 for the Warning%, and the

critical threshold level of 68%. Click Apply.

Page 290: Oracle 11g 2 Day DBA Hands-On

290

8. You receive an update confirmation message. Click the Database breadcrumb to go back to the

Server property page.

Page 291: Oracle 11g 2 Day DBA Hands-On

291

9. Select the Schema tab. Click the Tables link in the Database Objects section.

Page 292: Oracle 11g 2 Day DBA Hands-On

292

10. Click Create.

11. Accept the default of Standard, Heap Organized and click Continue.

12. Enter employees1 in the Name field. Specify SYSTEM as the schema and TBSALERT as the

tablespace. Click on the Define Using drop-down list and select SQL. The page is refreshed. Enter

select * from hr.employees in the CREATE TABLE AS field. Click Options.

Page 293: Oracle 11g 2 Day DBA Hands-On

293

13. Select Yes in the Enable Row Movement drop-down menu. Click OK to complete the table creation.

Page 294: Oracle 11g 2 Day DBA Hands-On

294

14. Your table has been created. Click the Database breadcrumb.

Triggering a Tablespace Space Usage Alert

You will now update the table to trigger a space utilization alert. Perform the following:

1. Open a SQL*Plus session and connect as the SYSTEM user as follows:

sqlplus system/oracle

2. Copy and paste the following SQL commands into your SQL*Plus session to simulate user activity

on the EMPLOYEES1 table:

begin

for i in 1..1000 loop

insert into employees1

select * from hr.employees;

commit;

end loop;

end;

/

Page 295: Oracle 11g 2 Day DBA Hands-On

295

3. Return to Enterprise Manager and click the Tablespaces link on the Server page.

4. Notice that the TBSALERT tablespace space used percentage has increased.

Page 296: Oracle 11g 2 Day DBA Hands-On

296

5. Return to the SQL*Plus window and copy and paste the following commands into your SQL*Plus

session to simulate more user activity on the EMPLOYEES1 table:

delete employees1 where department_id = 50;

begin

for i in 1..500 loop

insert into employees1

select * from hr.employees;

commit;

end loop;

end;

/

Page 297: Oracle 11g 2 Day DBA Hands-On

297

6. Go to the Enterprise Manager window. Refresh your browser (for Linux Mozilla, select View from

the menubar then select Reload). Notice that the TBSALERT tablespace space usage percentage has

increased.

Page 298: Oracle 11g 2 Day DBA Hands-On

298

7. Switch back to the SQL*Plus window and copy and paste the following commands into your

SQL*Plus session to simulate more user activity on the EMPLOYEES1 table:

begin

for i in 1..500 loop

insert into employees1

select * from hr.employees;

commit;

end loop;

end;

/

Page 299: Oracle 11g 2 Day DBA Hands-On

299

8. Copy and paste the following SQL commands into your SQL*Plus session to simulate user activity

on the EMPLOYEES1 table:

delete employees1 where department_id = 30;

commit;

delete employees1 where department_id = 100;

commit;

delete employees1 where department_id = 50;

commit;

delete employees1 where department_id = 80;

commit;

exit

Page 300: Oracle 11g 2 Day DBA Hands-On

300

9. Go to the Enterprise Manager window. Refresh your browser (for Linux Mozilla, select View from

the menubar then select Reload). Notice that the TBSALERT tablespace space usage percentage has

now exceeded the critical threshold level of 60%.

Page 301: Oracle 11g 2 Day DBA Hands-On

301

10. While you are waiting for the space usage alert to be displayed on the Enterprise Manager home

page, review the table segment statistics. Click the Database breadcrumb, the Schema tab and then

click the Tables link.

11. To locate the SYSTEM.EMPLOYEES1 table, enter system in the Schema field and emp in the

Object Name field. Click Go.

Page 302: Oracle 11g 2 Day DBA Hands-On

302

12. Select the EMPLOYEES1 table. Click Edit.

13. Click Segments.

Page 303: Oracle 11g 2 Day DBA Hands-On

303

14. Notice the percentage of wasted space in the EMPLOYEES1 table. You may be able to resolve the

tablespace space usage alert by reclaiming unused space in this table.

On this same page, you can project the EMPLOYEES1 table's future space usage by specifying a date

range for Space Usage Trend and clicking Refresh. Because there has not been enough activity

history on the EMPLOYEES1 table, you will not see very meaningful data in the space usage analysis

graph. Click the Database breadcrumb and then click the Home page tab.

Page 304: Oracle 11g 2 Day DBA Hands-On

304

15. Click the browser refresh/reload button a few times. Scroll down to the Space Summary section of

the Home page. Locate a red x and a number next to Problem Tablespaces. Scroll down to the

Alerts table.

Page 305: Oracle 11g 2 Day DBA Hands-On

305

16. You should see a Tablespaces Full alert. Click the Tablespace TBSALERT is 70 percent full link.

(Note: Your system may display slightly different data).

17. The Tablespaces page is displayed. Note that recommendations are given on how to resolve the issue

by clicking on the Segment Advisor Recommendations button. However, for the purposes of this

exercise, do not make any changes at this time.

Remain on this page to continue with the next exercise.

Setting Up Notification

You can optionally provide notification when events that require your intervention arise. By

default, alerts in critical state such as Database Down, Generic Alert Log Error Stats, and

Tablespace Used are set up for notification. Perform the following:

Page 306: Oracle 11g 2 Day DBA Hands-On

306

1. Click Setup at the top of the Database home page.

2. Click Notification Methods.

3. Enter <your mailserver> in the Outgoing Mail (SMTP) Server field, dbaalert in the Identify Sender

As field and [email protected] in the Sender's E-mail Address field and click Apply.

Page 307: Oracle 11g 2 Day DBA Hands-On

307

4. Your update was successful. Click Preferences at the top of the page.

Page 308: Oracle 11g 2 Day DBA Hands-On

308

5. Click Add Another Row for E-mail Addresses the General option.

6. Enter [email protected] as the email address and click Apply. Then click Database to return to

the Database Home page.

Page 309: Oracle 11g 2 Day DBA Hands-On

309

Diagnosing and Resolving Performance Problems

At times database performance problems arise that require your diagnosis and correction.

Sometimes problems are brought to your attention by users who complain about slow

performance. Other times you might notice performance spikes in the Host CPU chart on the

home page.

In all cases, these problems are flagged by the Automatic Database Diagnostics Monitor

(ADDM), which does a top-down system analysis every 60 minutes by default and reports its

findings on the Oracle Enterprise Manager Home page. ADDM runs automatically every 60

minutes to coincide with the snapshots taken by the Automatic Workload Repository (AWR). Its

output consists of a description of each problem it has identified, and a recommended action.

A Creating a Performance Finding

B. Resolving the Performance Finding using ADDM

Creating a Performance Finding

To show how ADDM works, you will create a performance finding. In this case, you will create

a session waiting on a row lock. To perform certain operations such as updates and deletes, the

session must obtain a lock on the row. Perform the following steps to create a performance

finding:

1. Open a terminal window and execute the following commands:

sqlplus hr/oracle

create table emp as select * from employees;

delete emp;

Page 310: Oracle 11g 2 Day DBA Hands-On

310

2. Open another terminal window and execute the following commands to create a row locking conflict:

sqlplus hr/oracle

delete emp;

3. Click Performance in your Enterprise Manager window.

Page 311: Oracle 11g 2 Day DBA Hands-On

311

4. Click Application in the Average Active Sessions section.

You see that the sessions waiting is very high. Wait about 10 minutes and scroll down to the bottom

of the window.

Page 312: Oracle 11g 2 Day DBA Hands-On

312

.

5. You will now create a snapshot to capture the performance finding. Click on Snapshots.

6. Click Create to create a snapshot.

Page 313: Oracle 11g 2 Day DBA Hands-On

313

7. Click Yes to create a Manual Snapshot.

8. Once the snapshot is created, click the Database Instance breadcrumb and then the Home tab .

9. Click Home. A performance finding is now detected and displayed as an alert in the ADDM

Performance Analysis section.

Page 314: Oracle 11g 2 Day DBA Hands-On

314

Resolving the Performance Finding using ADDM

When a performance finding is encountered, you can use ADDM to resolve it. Perform the

following:

1. Click the finding Row lock waits.

2. Click the SQL ID in the Rationale section.

3. Review the information on the SQL Details page. Click the Database Instance breadcrumb.

Page 315: Oracle 11g 2 Day DBA Hands-On

315

4. Click Performance. Scroll down and select Blocking Sessions under Additional Monitoring Links.

Note: If Blocking Sessions does not appear in the Additional Monitoring Links, click Home to return

to the Database Home page, and then click the Performance tab again.

5. Make sure the highest level HR is selected and click Kill Session.

Page 316: Oracle 11g 2 Day DBA Hands-On

316

6. Click Yes to kill the session.

7. The session has been killed. Click the Database Instance breadcrumb and then click Home.

Page 317: Oracle 11g 2 Day DBA Hands-On

317

Using the SQL Tuning Advisor

Create a directory named $HOME/wkdir. Download the sqltune.tar file and unzip the file into

the $HOME/wkdir directory. Perform the following steps:

1. Connect as SYSDBA through Database Control and navigate to the Performance tab of the

Database Control Home page. On the Performance page, make sure that the View Data field is set

to Real Time: 15 second Refresh.

Page 318: Oracle 11g 2 Day DBA Hands-On

318

2. Open a terminal emulator window connected as user oracle. Change your current directory to your

wkdir directory. Then, enter the following command from the OS prompt:

./setup_dina.sh

3. Execute the start_dinas.sh script as follows:

./start_dinas.sh

4. Return to Enterprise Manager and observe the Performance page for six minutes.

Page 319: Oracle 11g 2 Day DBA Hands-On

319

5. Return to your Database Home page. You will now determine the problem. If the time corresponding

to the problematic time period corresponds with the latest ADDM run detected by Database Control,

you should find the link corresponding to the correct performance analysis directly in the ADDM

Performance Analysis section of the Database Control home page.

Click the finding with the highest impact on the database time. It should correspond to a SQL Tuning

recommendation.

6. On the Performance Finding Details page you see the high-load SQL statement captured by the

ADDM analysis. The information provided indicates that there will be a significant benefit if you

tune this statement. Click the SQL text.

Page 320: Oracle 11g 2 Day DBA Hands-On

320

7. The SQL Details page is displayed. Click Schedule SQL Tuning Advisor.

Page 321: Oracle 11g 2 Day DBA Hands-On

321

8. The Schedule Advisor page is displayed. Click Submit.

Page 322: Oracle 11g 2 Day DBA Hands-On

322

9. The SQL Tuning Advisor task is scheduled. The page will advance when the task completes.

10. Recommendations are displayed. In this case, the recommendation is to create a SQL Profile in order

to get a better execution plan. Click Implement.

Page 323: Oracle 11g 2 Day DBA Hands-On

323

11. On the Confirmation window, click Yes.

12. The SQL Profile is created.

Page 324: Oracle 11g 2 Day DBA Hands-On

324

13. Return to your terminal window. To see the changes you implemented, you must re-execute the SQL.

Stop and start the workload by executing the following commands:

./stop_dinas.sh

./start_dinas.sh

14. Return to Enterprise Manager and access the Performance page to see the benefit of your tuning.

Page 325: Oracle 11g 2 Day DBA Hands-On

325

15. Return to your terminal window. Clean up your environment by executing the following commands:

./stop_dinas.sh

./cleanup_dina.sh

Using the SQL Access Advisor

The SQL Access Advisor provides a number of procedures which can be called to help decide

which materialized views and indexes to create and drop. It makes this decision using either a

Page 326: Oracle 11g 2 Day DBA Hands-On

326

hypothetical workload, which it bases on your schema, or from an actual workload which can be

provided by the user, from Oracle Trace or from the contents of the SQL cache.

Workloads may also be filtered according to different criteria, such as only use queries

containing these tables or queries which have a priority between this range.

A Preparing the Environment

B. Using the SQL Cache to Get Recommendations

C. Reviewing and Implementing the Recommendations

Preparing the Environment

To prepare the environment for using the SQL Access Advisor, perform the steps below.

Materialized views and indexes can be present when the advisor is run, but for the purposes of

this example they are removed so that you can see what the advisor will recommend. You need

to also set up the cache so that the SQL Access Advisor can generate recommendations. Perform

the following:

1. Open a terminal window and execute the following commands to clean up your environment:

sqlplus system/oracle

SELECT * FROM user_objects

WHERE object_type = 'MATERIALIZED VIEW';

If any of the following materialized views exist, delete them as shown:

DROP MATERIALIZED VIEW all_cust_sales_mv;

Page 327: Oracle 11g 2 Day DBA Hands-On

327

DROP MATERIALIZED VIEW costs_mv;

DROP MATERIALIZED VIEW costs_pm_mv;

DROP MATERIALIZED VIEW cust_sales_mv;

DROP MATERIALIZED VIEW some_cust_sales_mv;

DROP MATERIALIZED VIEW cust_id_sales_aggr;

DROP MATERIALIZED VIEW sales_cube_mv;

DROP MATERIALIZED VIEW sales_gby_mv;

DROP MATERIALIZED VIEW CUST_TOTAL_SALES_MV;

DROP MATERIALIZED VIEW CUST_SALES_TIME_MV;

2. Now you need to create the cache. Execute the following commands:

alter system flush shared_pool;

grant advisor to sh;

connect sh/sh;

SELECT c.cust_last_name, sum(s.amount_sold) AS dollars,

sum(s.quantity_sold) as quantity

FROM sales s, customers c, products p

WHERE c.cust_id = s.cust_id

AND s.prod_id = p.prod_id

AND c.cust_state_province IN ('Dublin','Galway')

GROUP BY c.cust_last_name;

Page 328: Oracle 11g 2 Day DBA Hands-On

328

SELECT c.cust_id, SUM(amount_sold) AS dollar_sales

FROM sales s, customers c WHERE s.cust_id= c.cust_id GROUP BY

c.cust_id;

select sum(unit_cost) from costs group by prod_id;

Page 329: Oracle 11g 2 Day DBA Hands-On

329

Using the SQL Cache to Get Recommendations

You will use the SQL Cache you just set up to obtain recommendations from the SQL Access

Advisor. Perform the following:

1. Scroll to the bottom of the Database Home page and click Advisor Central under Related Links.

2. Click the SQL Advisors link.

Page 330: Oracle 11g 2 Day DBA Hands-On

330

3. Click SQL Access Advisor.

4. Select Recommend new access structures and click Continue.

5. Ensure Current and Recent SQL Activity is selected. Expand Filter Options.

Page 331: Oracle 11g 2 Day DBA Hands-On

331

Select Filter Workload Based on these Options. Select Include only SQL statements executed by

these users. Enter SH in the Users field and click Next.

6. Select Both Indexes and Materialized Views and click Next.

Page 332: Oracle 11g 2 Day DBA Hands-On

332

7. Enter the task name SQLACCESS<Today's Date>, select Standard for the Schedule Type and

click Next.

Page 333: Oracle 11g 2 Day DBA Hands-On

333

8. At the summary window, click Submit.

Page 334: Oracle 11g 2 Day DBA Hands-On

334

9. A confirmation message appears.

Reviewing and Implementing the Recommendations

Now you can look at the results and implement them if you wish. Perform the following:

1. On the Advisor Central page, ensure your job is selected and click View Result.

Page 335: Oracle 11g 2 Day DBA Hands-On

335

2. The Summary page is displayed. Click Recommendations.

Page 336: Oracle 11g 2 Day DBA Hands-On

336

Click on the Recommendation ID 1 to see the details of the Recommendations.

3. Here you can customize the Object Name, Schema and Tablespace to implement the

recommendations. Scroll down and change the Schema Name for the Create Materialized View to

SH and click OK.

Page 337: Oracle 11g 2 Day DBA Hands-On

337

4. To implement the recommendations, click Schedule Implementation.

7. Enter SQLACCESSIMPL<today's date> for the Job Name and click Submit.

8. Your implementation job was created and is now executing.

Page 338: Oracle 11g 2 Day DBA Hands-On

338

9. Click Database to return to the Database Home page. Click Schema.

10. Click Materialized Views in the Materialized Views section.

Page 339: Oracle 11g 2 Day DBA Hands-On

339

11. Enter SH in the schema field and click Go.

12. Notice that the newly created Materialized View appears in the list. Click the Database breadcrumb

then click the Home tab.

Page 340: Oracle 11g 2 Day DBA Hands-On

340

Enabling Automatic Shared Memory Management Using the Memory Advisor

In this section, you will proactively manage and automate some of the tasks related to Oracle

Instance memory configuration. By automating memory configuration, you have more time to

deal with real application or business issues that affect your enterprise.

The Memory Advisor is an intelligent expert system within the Oracle database that proactively

determines optimal settings for various SGA and PGA components. When automated, Oracle

will automatically adjust the settings for the various pools and caches according to the

requirements of the workload.

In this section you will verify that automatic shared memory management is enabled. If it is

disabled, you can enable it by following the steps outlined below.

1. Scroll down to the bottom of the home page and click on Advisor Central under Related Links.

Page 341: Oracle 11g 2 Day DBA Hands-On

341

2. Select Memory Advisors.

3. Confirm that Automatic Shared Memory Management is enabled. If you would like to disable

Automatic Shared Memory Management, click Disable.

Page 342: Oracle 11g 2 Day DBA Hands-On

342

Summary

In this tutorial, you learned how to:

Create a tablespace with a specified threshold.

Triggering a tablespace usage alert.

Set metric thresholds.

Create a performance finding.

Solve the performance finding using ADDM.