124
1221 ■ ■ ■ APPENDIX Oracle Database 11g SQL and PL/SQL: A Brief Primer I’m sure most of you are already familiar with SQL to some extent. However, I present in this appendix a quick introduction to Oracle Database 11g SQL and its programmatic cousin, PL/SQL, as a starting point for those new to programming Oracle databases. My goal here is simply to present a short summary of the classic DML and DDL commands and to discuss the newer SQL and PL/SQL concepts in greater detail. Your need to know SQL or PL/SQL depends somewhat on the type of DBA you are—a production support DBA won’t need to know as much about Oracle programming as a DBA assisting in develop- mental efforts. It’s becoming increasingly important, however, for DBAs to learn a number of advanced SQL and PL/SQL concepts, including the new Java and XML-based technologies. The reason is simple: even when you aren’t developing applications yourself, you’re going to be assisting people who are doing so, and it helps to know what they’re doing. This appendix aims to summarize some of the most important Oracle Database 11g SQL and PL/SQL features so you and the developers you work with can take advantage of them. Oracle SQL and PL/SQL represent an enormously broad topic, so this appendix lightly covers several important topics without attempting any detailed explanation due to space considerations. Please refer to the Oracle manuals Application Developer’s Guide—Fundamentals and PL/SQL User’s Guide and Reference for a comprehensive introduction to SQL and PL/SQL. The Oracle Database 11g Sample Schemas The examples in this appendix use the demo schemas provided by Oracle as part of the Oracle Data- base 11g server software. The demo data is for a fictitious company and contains the following five schemas: HR is the human resources division, which contains information on employees. It is the most commonly used schema, with its familiar employees and dept tables. The schema uses scalar data types and simple tables with basic constraints. OE is the order entry department, which contains inventory and sales data. This schema covers a simple order-entry system and includes regular relational objects as well as object- relational objects. Because the OE schema contains synonyms for HR tables, you can query HR’s objects from the OE schema. PM is the product media department, which covers content management. You can use this schema if you’re exploring Oracle’s Multimedia option. The tables in the PM schema contain audio and video tracks, images, and documents.

Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1221

■ ■ ■

A P P E N D I X

Oracle Database 11g SQL and PL/SQL: A Brief Primer

I’m sure most of you are already familiar with SQL to some extent. However, I present in this appendix a quick introduction to Oracle Database 11g SQL and its programmatic cousin, PL/SQL, as a starting point for those new to programming Oracle databases. My goal here is simply to present a short summary of the classic DML and DDL commands and to discuss the newer SQL and PL/SQL concepts in greater detail.

Your need to know SQL or PL/SQL depends somewhat on the type of DBA you are—a production support DBA won’t need to know as much about Oracle programming as a DBA assisting in develop-mental efforts. It’s becoming increasingly important, however, for DBAs to learn a number of advanced SQL and PL/SQL concepts, including the new Java and XML-based technologies. The reason is simple: even when you aren’t developing applications yourself, you’re going to be assisting people who are doing so, and it helps to know what they’re doing.

This appendix aims to summarize some of the most important Oracle Database 11g SQL and PL/SQL features so you and the developers you work with can take advantage of them. Oracle SQL and PL/SQL represent an enormously broad topic, so this appendix lightly covers several important topics without attempting any detailed explanation due to space considerations. Please refer to the Oracle manuals Application Developer’s Guide—Fundamentals and PL/SQL User’s Guide and Reference for a comprehensive introduction to SQL and PL/SQL.

The Oracle Database 11g Sample SchemasThe examples in this appendix use the demo schemas provided by Oracle as part of the Oracle Data-base 11g server software. The demo data is for a fictitious company and contains the following five schemas:

• HR is the human resources division, which contains information on employees. It is the most commonly used schema, with its familiar employees and dept tables. The schema uses scalar data types and simple tables with basic constraints.

• OE is the order entry department, which contains inventory and sales data. This schema covers a simple order-entry system and includes regular relational objects as well as object-relational objects. Because the OE schema contains synonyms for HR tables, you can query HR’s objects from the OE schema.

• PM is the product media department, which covers content management. You can use this schema if you’re exploring Oracle’s Multimedia option. The tables in the PM schema contain audio and video tracks, images, and documents.

Page 2: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1222 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

• IX is the information exchange department in charge of shipping using various B2B applications.

• SH is the sales history department in charge of sales data. It is the largest sample schema, and you can use it for testing examples with large amounts of data. The schema contains parti-tioned tables, an external table, and Online Analytical Processing (OLAP) features. The SALES and COSTS tables contain 750,000 rows and 250,000 rows, respectively, as compared to 107 rows in the employees table from the HR schema.

In order to install the SH schema, you must have the partitioning option installed in your Oracle database; this option lets you use table and index partitioning in your database. Ideally, you should install the Oracle demo schemas in a test database where you can safely practice the parts of SQL you aren’t familiar with. The Oracle Sample Schemas documentation manual provides detailed informa-tion about the sample schemas.

If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software installation (the Basic Installation option), it will have automatically created the sample schemas in the new starter database.

If you’ve chosen to not create the starter database (by selecting a Software Only installation option), you can run the DBCA to install the sample schemas. Choose the Sample Schemas option when you use the DBCA to create the sample schemas in an existing database. By default, all the sample schema accounts are locked, and you must use the ALTER USER . . . ACCOUNT UNLOCK state-ment to unlock them.

If you want to create the sample schemas in a database without using the DBCA, you can run Oracle-provided scripts to install the sample schemas.

Oracle Data TypesData in an Oracle database is organized in rows and columns inside tables. The individual columns are defined with properties that limit the values and format of the column contents. Let’s review the most important Oracle built-in data types before we look at Oracle SQL statements.

Character Data TypesThe CHAR data type is used for fixed-length character literals:

SEX CHAR(1)

The VARCHAR2 data type is used to represent variable-length character literals:

CITY VARCHAR2 (20)

The CLOB data type is used to hold large character strings and the BLOB and BFILE data types are used to store large amounts of binary data.

Numeric Data TypesThere are two important SQL data types used to store numeric data:

• The NUMBER data type is used to store real numbers, either in a fixed-point or floating-point format.

• The BINARY FLOAT and BINARY DOUBLE data types store data in a floating-point format.

Page 3: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1223

Date and Time Data TypesThere are a couple of special data types that let you handle date and time values:

• The DATE data type stores the date and time (such as year, month, day, hours, minutes, and seconds).

• The TIMESTAMP data type stores time values that are precise to fractional seconds.

Conversion FunctionsOracle offers several conversion functions that let you convert data from one format to another. The most common of these functions are the TO_CHAR, TO_NUMBER, TO_DATE, and TO_TIMESTAMP functions. The TO_CHAR function converts a floating number to a string, and the TO_NUMBER function converts a floating number or a string to a number. The TO_DATE function converts character data to a DATE data type. Here are some examples:

SQL> SELECT TO_CHAR(TO_DATE('20-JUL-08', 'DD-MON-RR') ,'YYYY') "Year" FROM DUAL;

Year-------------------------------------------------------------------------------2008SQL>

SQL> SELECT TO_CHAR(SYSDATE, 'DD-MON-YYYY') FROM DUAL;

TO_CHAR(SYSDATE--------------20-JUL-2008SQL>

SQLIn Chapter 7 you saw how Oracle SQL statements include DDL, DML, and other types of statements. Let’s begin with a review of the basic SQL statements.

The SELECT StatementThe SELECT statement is the most common SQL statement (it is also called a projection). A SELECT statement retrieves all or some of the data in a table, based on the criteria that you specify.

The most basic SELECT statement is one that retrieves all the data in the table:

SQL> SELECT * FROM employees;

To retrieve only certain columns from a table, you specify the column names after the SELECT keyword, as shown in the following example:

SQL> SELECT first_name, last_name, hiredate FROM employees;

If you want only the first ten rows of a table, you can use the following statement:

SQL> SELECT * FROM employees WHERE rownum <11;

Page 4: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1224 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

If you want just a count of all the rows in the table, you can use the following statement:

SQL> SELECT COUNT(*) FROM employees;

If a table has duplicate data, you can use the DISTINCT clause to eliminate the duplicate values, as shown here:

SQL> SELECT DISTINCT username FROM V$SESSION;

The optional WHERE clause in a SELECT statement uses conditions to help you specify that only certain rows be returned. Table A-1 lists some of the common conditions you can use in a WHERE clause.

Here are some examples of using the WHERE clause:

SQL> SELECT employee_id WHERE salary = 50000;SQL> SELECT employee_id WHERE salary < 50000;SQL> SELECT employee_id WHERE salary > 50000;SQL> SELECT employee_id WHERE salary <= 50000;SQL> SELECT employee_id WHERE salary >= 50000;SQL> SELECT employee_id WHERE salary ! 50000;

The LIKE Condition

The LIKE condition uses pattern matching to restrict rows in a SELECT statement. Here’s an example:

SQL> SELECT employee_id, last_name FROM employees 2* WHERE last_name LIKE 'Fa%';EMPLOYEE_ID LAST_NAME----------- ---------- 109 Faviet 202 FaySQL>

The pattern that you want the WHERE clause to match should be enclosed in single quotes (' '). In the preceding example, the percent sign (%) indicates that the letters Fa can be followed by any character string. Thus, the percent sign acts as a wildcard for one or more characters, performing the same job as the asterisk (*) in many operating systems. Note that a single underscore character (_) acts as a wildcard for one and only one character.

Table A-1. Common Conditions Used in WHERE Clauses

Symbol Condition

= Equal

> Greater than

< Less than

<+ Less than or equal to

>= Greater than or equal to

<> or ! Not equal to

Page 5: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1225

The INSERT StatementThe INSERT statement enables you to add new data to a table, including duplicate data if there are no unique requirements enforced by a primary key or an index. The general form of the INSERT state-ment is as follows:

INSERT INTO <table> [(<column i, . . . , column j>)]VALUES (<value i, . . . ,value j>);

Here is an example of the insert command:

SQL> INSERT INTO employees( 2 employee_id,last_name,email,hire_date,job_id) 3 VALUES 4* (56789,'alapati','[email protected]', sysdate,98765);1 row created.SQL>

In the preceding list, the column names were specified because only some columns were being populated in the row being inserted. The rest of them are left blank, which is okay, provided the column isn’t defined as a “not null” column.

If you’re inserting values for all the columns of a table, you can use the simpler INSERT statement shown here:

SQL> INSERT INTO department VALUES (34567, 'payroll', 'headquarters', 'dallas'); 1 row created.SQL>

If you want to insert all the columns of a table into another table, you can use the following INSERT statement:

SQL> INSERT INTO b SELECT * FROM a WHERE city='DALLAS';

If table b doesn’t exist, you can use the CREATE TABLE table_name AS SELECT * FROM (CTAS) state-ment, as shown here:

SQL> CREATE table b as SELECT * FROM a;

The DELETE StatementYou use the DELETE statement to remove rows from a table. The DELETE statement has the following structure:

DELETE FROM <table> [WHERE ,condition>];

For example, if you want to delete employee Fay’s row from the employees table, you would use the following DELETE statement:

SQL> DELETE FROM employees 2* WHERE last_name='Fay';1 row deleted.

If you don’t have a limiting WHERE condition, the DELETE statement will result in the removal of all the rows in the table, as shown here:

SQL> DELETE FROM X;

Page 6: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1226 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

You can also remove all rows in a table using the TRUNCATE command, but you can’t undo or roll back the TRUNCATE command’s effects. You can undo a delete by using the ROLLBACK statement:

SQL> ROLLBACK;

The UPDATE StatementThe UPDATE statement changes the value (or values) of one or more columns of a row (or rows) in a table. The expression to which a column is being set or modified can be a constant, arithmetic, or string operation, or the product of a SELECT statement.

The general structure of the UPDATE statement is as follows (note that the elements in square brackets are optional):

UPDATE <table>SET <column i> = <expression i>, . . . , <column j> = <expression j>[WHERE <condition> ];

If you want to change or modify a column’s values for all the rows in the table, you use an UPDATE statement without a WHERE condition:

SQL> UPDATE persons SET salary=salary*0.10;

If you want to modify only some rows, you need to use the WHERE clause in your UPDATE statement:

SQL> UPDATE persons SET salary = salary * 0.10 WHERE review_grade > 5;

Filtering DataThe WHERE clause in a SELECT, INSERT, DELETE, or UPDATE statement lets you filter data. That is, you can restrict the number of rows on which you want to perform a SQL operation. Here’s a simple example:

SQL> INSERT INTO a SELECT * FROM b WHERE city='DALLAS';

Sorting the Results of a QueryFrequently, you’ll have to sort the results of a query in some order. The ORDER BY clause enables you to sort the data based on the value of one or more columns. You can choose the sorting order (ascending or descending) and you can choose to sort by column aliases. You can also sort by multiple columns. Here’s an example:

SQL> SELECT employee_id, salary FROM employees ORDER BY salary;

Changing the Sorting Order

Be default, an ORDER BY clause sorts in ascending order. If you want to sort in descending order, you need to specify the DESC keyword:

SQL> SELECT employee_id, salary FROM employees ORDER BY salary desc;

Page 7: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1227

Sorting by Multiple Columns

You can sort results based on the values of more than one column. The following query sorts on the basis of two columns, salary and dept:

SQL> SELECT employee_id, salary FROM employees ORDER BY salary, dept;

OperatorsSQL provides you with a number of operators to perform various tasks, such as comparing column values and performing logical operations. The following sections outline the important SQL opera-tors: comparison operators, logical operators, and set operators.

Comparison Operators

Comparison operators compare a certain column value with several other column values. These are the main comparison operators:

• BETWEEN: Tests whether a value is between a pair of values

• IN: Tests whether a value is in a list of values

• LIKE: Tests whether a value follows a certain pattern, as shown here:

SQL> SELECT employee_id from employees WHERE dept LIKE 'FIN%';

Logical Operators

The logical operators, also called Boolean operators, logically compare two or more values. The main logical operators are AND, OR, NOT, GE (greater than or equal to), and LE (less than or equal to). Here’s an example that illustrates the use of some of the logical operators:

SQL> SELECT last_name, city WHERE salary GT 100000 and LE 200000;

When there are multiple operators within a single statement, you need rules of precedence. Oracle always evaluates arithmetical operations such as multiplication, division, addition, and subtraction before it evaluates conditions. The following is the order of precedence of operators in Oracle, with the most important first:

=, !=, <, >, <=, >=IS NULL, LIKE, BETWEEN, IN, EXISTSNOTANDOR

The Set Operators

Sometimes your query may need to combine results from more than one SQL statement. In other words, you need to write a compound query. Set operators facilitate compound SQL queries. Here are the important Oracle set operators:

Page 8: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1228 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

• UNION: The UNION operator combines the results of more than one SELECT statement after removing any duplicate rows. Oracle will sort the resulting set of data. Here’s an example:

SQL> SELECT emp_id FROM old_employees UNION SELECT emp_id FROM new_employees;

• UNION ALL: The UNION ALL operator is similar to UNION, but it doesn’t remove the duplicate rows. Oracle doesn’t sort the result set in this case, unlike the UNION operation.

• INTERSECTION: The INTERSECTION operator gets you the common values in two or more result sets derived from separate SELECT statements. The result set is distinct and sorted.

• MINUS: The MINUS operator returns the rows returned by the first query that aren’t in the second query’s results. The result set is distinct and sorted.

SQL FunctionsOracle functions manipulate data items and return a result, and built-in Oracle functions help you perform many transformations quickly, without your having to do any coding. In addition, you can build your own functions. Functions can be divided into several groups: single-row functions, aggre-gate functions, number and date functions, general and conditional functions, and analytical functions.

Single-Row Functions

Single-row functions are typically used to perform tasks such as converting a lowercase word to uppercase or vice versa, or replacing a portion of text in a row. Here are the main single-row functions used in Oracle:

• CONCAT: The CONCAT function concatenates or puts together two or more character strings into one string.

• LENGTH: The LENGTH function gives you the length of a character string.

• LOWER: The LOWER function transforms uppercase letters into lowercase, as shown in the following example:

SQL> SELECT LOWER('SHANNON ALAPATI') from dual;

LOWER('SHANNONALAPATI')-----------------------shannon alapatiSQL>

• SUBSTR: The SUBSTR function returns part of a string.

• INSTR: The INSTR function returns a number indicating where in a string a certain string value starts.

• LPAD: The LPAD function returns a string after padding it for a specified length on the left.

• RPAD: The RPAD function pads a string on the right side.

• TRIM: The TRIM function trims a character string.

• REPLACE: The REPLACE function replaces every occurrence of a specified string with a specified replacement string.

Page 9: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1229

Aggregate Functions

You can use aggregate functions to compute things such as averages and totals of a selected column in a query. Here are the important aggregate functions:

• MIN: The MIN function returns the smallest value. Here’s an example:

SELECT MIN(join_date) FROM employees;

• MAX: The MAX function returns the largest value.

• AVG: The AVG function computes the average value of a column.

• SUM: The SUM function computes the sum of a column:

SQL> SELECT SUM(bytes) FROM dba_free_space;

• COUNT: The COUNT function returns the total number of columns.

• COUNT(*): The COUNT(*) function returns the number of rows in a table.

Number and Date Functions

Oracle includes several number functions, which accept numeric input and return numeric values. The date functions help you format dates and times in different ways. Here are some of the impor-tant number and date functions:

• ROUND: This function returns a number rounded to the specified number of places to the right of the decimal point.

• TRUNC: This function returns the result of a date truncated in the specified format.

• SYSDATE: This commonly used function returns the current date and time:

SQL> SELECT sysdate FROM dual;

SYSDATE--------------------07/AUG/2008SQL>

• TO_TIMESTAMP: This function converts a CHAR or VARCHAR(2) data type to a timestamp data type.

• TO_DATE: You can use this function to change the current date format. The standard date format in Oracle is DD-MMM-YYYY, as shown in the following example:

07-AUG-2008

• The TO_DATE function accepts a character string that contains valid data and converts it into the default Oracle date format. It can also change the date format, as shown here:

SQL> SELECT TO_DATE('August 20,2008', 'MonthDD,YYYY') FROM dual;

TO_DATE('AUGUST20,2008'-----------------------08/20/2008SQL>

Page 10: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1230 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

• TO_CHAR: This function converts a date into a character string, as shown in the following example:

SQL> SELECT SYSDATE FROM dual;

SYSDATE-----------04-AUG-2008SQL>

SQL> SELECT TO_CHAR(SYSDATE, 'DAY, DDTH MONTH YYYY') FROM DUAL;

TO_CHAR(SYSDATE,'DAY,DDTHMON--------------------------------THURSDAY , 04TH AUGUST 2008

SQL>

• TO_NUMBER: This function converts a character string to a number format:

SQL> UPDATE employees SET salary = salary + TO_NUMBER('100.00', '9G999D99') WHERE last_name = 'Alapati';

General and Conditional Functions

Oracle provides some very powerful general and conditional functions that enable you to extend the power of simple SQL statements into something similar to a traditional programming language construct. The conditional functions help you decide among several choices. Here are the important general and conditional Oracle functions:

• NVL: The NVL function replaces the value in a table column with the value after the comma if the column is null. Thus, the NVL function takes care of column values if the column values are null and converts them to non-null values:

SQL> SELECT last_name, title, salary * NVL (commission_pct,0)/100 COMM FROM employees;

• COALESCE: This function is similar to NVL, but it returns the first non-null value in the list:

SQL> COALESCE(region1, region2, region3, region4)

• DECODE: This function is used to incorporate basic if-then functionality into SQL code. The following example assigns a party name to all the voters in the table based on the value in the affiliation column. If there is no value under the affiliation column, the voter is listed as an independent:

SQL> SELECT DECODE(affiliation, 'D', 'Democrat', 'R', 'Republican', 'Independent') FROM voters;

• CASE: This function provides the same functionality as the DECODE function, but in a much more intuitive and elegant way. Here’s a simple example of using the CASE statement, which helps you incorporate if-then logic into your code:

SQL> SELECT ename, (CASE deptno WHEN 10 THEN 'Accounting' WHEN 20 THEN 'Research' WHEN 30 THEN 'Sales'

Page 11: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1231

WHEN 40 THEN 'Operations' ELSE 'Unknown' END) department FROM employees;

Analytical Functions

Oracle’s SQL analytical functions are powerful tools for business intelligence applications. Oracle claims a potential improvement of 200 to 500 percent in query performance with the use of the SQL analytical functions. The purpose behind using analytical functions is to perform complex summary computations without using a lot of code. Here are the main SQL analytical functions of the Oracle database:

• Ranking functions: These enable you to rank items in a data set according to some criteria. Oracle has several types of ranking functions, including RANK, DENSE_RANK, CUME_DIST, PERCENT_RANK, and NTILE. Listing A-1 shows a simple example of how a ranking function can help you rank some sales data.

Listing A-1. An Example of a Ranking Function

SQL> SELECT sales_type, TO_CHAR(SUM(amount_sold), '9,999,999,999') SALES, RANK() OVER (ORDER BY SUM(amount_sold) ) AS original_rank, RANK() OVER (ORDER BY SUM(amount_sold) DESC NULLS LAST) AS derived_rank FROM sales, products, customers, time_frame, sales_types WHERE sales.prod_id=products.prod_id AND sales.cust_id=customers.cust_id AND sales.time_id=time_frame.time_id AND sales.sales_type_id=sales_types.sales_type_id AND timeframe.calendar_month_desc IN ('2008-07', '2008-08') AND country_id='INDIA' GROUP BY sales_type;

SALES_TYPE SALES ORIGINAL_RANK DERIVED_RANK------------- --------- -------------- ------------Direct Sales 5,744,263 5 1Internet 3,625,993 4 2Catalog 1,858,386 3 3Partners 1,500,213 2 4Tele Sales 604,656 1 5SQL>

• Moving-window aggregates: These functions provide cumulative sums and moving averages.

• Period-over-period comparisons: These functions let you compare two periods (for example, “How does the first quarter of 2008 compare with the first quarter of 2006 in terms of percentage growth?”).

• Ratio-to-report comparisons: These make it possible to compare ratios (for example, “What is August’s enrollment as a percentage of the entire year’s enrollment?”).

• Statistical functions: These functions calculate correlations and regression functions so you can see cause-and-effect relationships among data.

• Inverse percentiles: These help you find the data corresponding to a percentile value (for example, “Get me the names of the salespeople who correspond to the median sales value.”).

Page 12: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1232 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

• Hypothetical ranks and distributions: These help you figure out how a new value for a column fits into existing data in terms of its rank and distribution.

• Histograms: These functions return the number of the histogram data appropriate for each row in a table.

• First/last aggregates: These functions are appropriate when you are using the GROUP BY clause to sort data into groups. Aggregate functions let you specify the sort order for the groups.

Hierarchical Retrieval of DataIf a table contains hierarchical data (data that can be grouped into levels, with the parent data at higher levels and child data at lower levels), you can use Oracle’s hierarchical queries. Hierarchical queries typically use the following structure:

• The START WITH clause denotes the root row or rows for the hierarchical relationship.

• The CONNECT BY clause specifies the relationship between parent and child rows, with the prior operator always pointing out the parent row.

Listing A-2 shows a hierarchical relationship between the employees and manager columns. The CONNECT BY clause describes the relationship. The START WITH clause specifies where the state-ment should start tracing the hierarchy.

Listing A-2. A Hierarchical Relationship Between Data

SQL> SELECT employee_id, last_name, manager_id FROM employees START WITH manager_id = 100 CONNECT BY PRIOR employee_id = manager_id;

EMPLOYEE_ID LAST_NAME MANAGER_ID----------- -------------- ---------- 101 Reddy 100 108 Greenberg 101 109 Faviet 108 110 Colon 108 111 Chowdhary 108 112 Urman 108 113 Singh 108 200 Whalen 101SQL>

Selecting Data from Multiple TablesSo far, we’ve mostly looked at how to perform various DML operations on single tables, including using SQL functions and expressions. However, in real life, you’ll mostly deal with query output retrieved from several tables or views. When you need to retrieve data from several tables, you need to join the tables. A join is a query that lets you combine data from tables, views, and materialized views. Note that a table can be joined to other tables or to itself.

The Cartesian product or Cartesian join is simply a join of two tables without a selective WHERE clause. Therefore, the query output will consist of all rows from both tables. Here’s an example of a Cartesian join:

SQL> SELECT * FROM employees, dept;

Page 13: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1233

Cartesian products of two large tables are almost always the result of a mistaken SQL query that omits the join condition. By using a join condition when you’re combining data from two or more tables, you can limit the number of rows returned. A join condition can be used in the WHERE clause or the FROM clause, and it limits the data returned by selecting only data that satisfies the condition stipulated by the join condition.

Here’s an example of a join statement that uses a join condition:

SQL> SELECT * FROM employees, dept WHERE dept='HR';

Types of Oracle Joins

Oracle offers various types of joins based on the way you combine rows from two or more tables or views. The next sections discuss the most commonly used types of Oracle joins.

Equi-Join

With an equi-join, two or more tables are joined based on an equality condition between two columns. In other words, the same column has the same value in all the tables that are being joined. Here’s an example:

SQL> SELECT e.last_name, d.dept FROM emp e, dept d WHERE e.emp_id = d.emp_id;

You can also use the following new syntax for the preceding join statement:

SQL> SELECT e.last_name, d.dept FROM emp e JOIN dept d USING (emp_id);

If you want to join multiple columns, you can do so by using a comma-delimited list of column names, as in USING (dept_id, emp_name).

Natural Join

A natural join is an equi-join where you don’t specify any columns to be matched for the join. Oracle will automatically determine the columns to be joined, based on the matching columns in the two tables. Here’s an example:

SQL> SELECT e.last_name, d.dept FROM emp e NATURAL JOIN dept d;

In the preceding example, the join is based on identical values for the last_name column in both the emp and dept tables.

Self Join

A self join is a join of a table to itself through the use of table aliases. In the following example, the employees table is joined to itself using an alias. The query deletes duplicate rows in the employees table.

SQL> DELETE FROM employees X WHERE ROWID > 2 (select MIN(rowid) FROM employees Y 3 where X.key_values = Y.key_values);

Page 14: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1234 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

Inner Join

An inner join, also known as a simple join, returns all rows that satisfy the join condition. The tradi-tional Oracle inner join syntax used the WHERE clause to specify how the tables were to be joined. Here’s an example:

SQL> SELECT e.flast_name, d.dept FROM emp e, dept d WHERE e.emp_id = d.emp_id;

The newer Oracle inner joins (or simply joins) specify join criteria with the new ON or USING clause. Here’s a simple example:

SQL> SELECT DISTINCT NVL(dname, 'No Dept'), COUNT(empno) nbr_emps FROM emp JOIN DEPT ON emp.deptno = dept.deptno WHERE emp.job IN ('MANAGER', 'SALESMAN', 'ANALYST') GROUP BY dname;

Outer Join

An outer join returns all rows that satisfy the join condition, plus some or all of the rows from the table that doesn’t have matching rows that meet the join condition. There are three types of outer joins: left outer join, right outer join, and full outer join. Usually, the word “outer” is omitted from the full outer join statement.

Oracle provides the outer join operator, wherein you use a plus sign (+) to indicate missing values in one table, but it recommends the use of the newer ISO/ANSI join syntax. Here’s a typical query using the full outer join:

SQL> SELECT DISTINCT NVL(dept_name, 'No Dept') deptname, COUNT(empno) nbr_emps FROM emp FULL JOIN dept ON dept.deptno = emp.deptno GROUP BY dname;

Grouping OperationsOracle provides the GROUP BY clause so you can group the results of a query according to various criteria. The GROUP BY clause enables you to consider a column value for all the rows in the table fulfilling the SELECT condition.

A GROUP BY clause commonly uses aggregate functions to summarize each group defined by the GROUP BY clause. The data is sorted on the GROUP BY columns, and the aggregates are calculated. Here’s an example:

SQL> SELECT department_id, MAX(salary) 2 FROM employees 3* GROUP BY department_id;

DEPARTMENT_ID MAX(SALARY) ------------- ----------- 10 4400 20 13000 30 11000 40 6500 50 8200 5 rows selected.SQL>

Page 15: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1235

Oracle also allows you to nest group functions. The following query gets you the minimum average budget for all departments (the AVG function is nested inside the MIN function here):

SQL> SELECT MIN(AVG(budget)) FROM dept_budgets GROUP BY dept_no;

The GROUP BY Clause with a ROLLUP Operator

You’ve seen how you can derive subtotals with the help of the GROUP BY clause. The GROUP BY clause with a ROLLUP operator gives you subtotals and total values. You can thus build subtotal aggregates at any level. In other words, the ROLLUP operator gets you the aggregates at each group by level. The subtotal rows and the grand total row are called the superaggregate rows.

Listing A-3 shows an example of using the ROLLUP operator.

Listing A-3. A GROUP BY Clause with a ROLLUP Operator

SQL> SELECT Year,Country,SUM(Sales) AS Sales FROM Company_Sales GROUP BY ROLLUP (Year,Country);

YEAR COUNTRY SALES -------- -------- ------- 1997 France 3990 1997 USA 13090 1997 17080 1998 France 4310 1998 USA 13900 1998 18210 1999 France 4570 1999 USA 14670 1999 19240 54530 /*This is the grand total */SQL>

The GROUP BY Clause with a CUBE Operator

You can consider the CUBE operator to be an extension of the ROLLUP operator, as it helps extend the standard Oracle GROUP BY clause. The CUBE operator computes all possible combinations of subtotals in a GROUP BY operation. In the previous example, the ROLLUP operator gave you yearly subtotals. Using the CUBE operator, you can get countrywide totals in addition to the yearly totals. Here’s a simple example:

SQL> SELECT department_id, job_id, SUM(salary) 4 FROM employees 5 GROUP BY CUBE (department_id, job_id);

DEPARTMENT_ID JOB_ID SUM(SALARY)------------- --------- ----------- 10 AD_ASST 44000 20 MK_MAN 130000 20 MK_REP 60000 30 PU_MAN 110000 30 PU_CLERK 139000. . .SQL>

Page 16: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1236 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

The GROUP BY Clause with a GROUPING Operator

As you’ve seen, the ROLLUP operator gets you the superaggregate subtotals and grand totals. The GROUPING operator in a GROUP BY clause helps you distinguish between superaggregated subtotals and the grand total column from the other row data.

The GROUP BY Clause with a GROUPING SETS Operator

The GROUPING SETS operator lets you group multiple sets of columns when you’re calculating aggre-gates such as sums. Here’s an example that shows how you can use this operator to calculate aggregates over three groupings: (year, region, item), (year, item), and (region, item). The GROUPING SETS operator eliminates the need for inefficient UNION ALL operators.

SQL> SELECT year, region, item, sum(sales) FROM regional_salesitem GROUP BY GROUPING SETS (( year, region, item), (year, item), (region, item));

The GROUP BY Clause with a HAVING Operator

The HAVING operator lets you restrict or exclude the results of a GROUP BY operation, in essence putting a WHERE condition on the GROUP BY clause’s result set. In the following example, the HAVING operator restricts the query results to only those departments that have a maximum salary greater than 20,000:

SQL> SELECT department_id, max(salary) 2 FROM employees 3 GROUP BY department_id 4* HAVING MAX(salary)>20000;

DEPARTMENT_ID MAX(SALARY)------------- ----------- 90 24000SQL>

Writing SubqueriesSubqueries resolve queries that have to be processed in multiple steps—where the final result depends on the results of a child query or subquery to the main query. If the subquery occurs in the WHERE clause of the statement, it’s called a nested subquery.

Top-N Analysis

The following query gives you the top ten employees in a firm ranked by salary. You can just as easily retrieve the bottom ten employees by using the ORDER BY clause instead of the ORDER BY DESC clause.

SQL> SELECT emp_id, emp_name, job, manager, salary FROM (SELECT emp_id, emp_name, job, manager, salary, RANK() OVER (ORDER BY SALARY DESC NULLS LAST) AS Employee_Rank FROM employees ORDER BY SALARY DESC NULLS LAST) WHERE employee_Rank < 5;

Subqueries can be single-row or multiple-row SQL statements. Let’s take a quick look at both types of subqueries.

Page 17: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1237

Single-Row Subqueries

Subqueries are useful when you need to answer queries on the basis of as-yet unknown values, such as “Which employees have a salary higher than the employee with the employee ID 9999?” To answer such a question, a subquery or inner query is executed first (and only once). The result of this subquery is then used by the main or outer query. Here’s the query:

SQL> SELECT first_name||last_name, dept 2 FROM employee 3 WHERE sal > 4 (SELECT sal 5 FROM emp 6 WHERE empno= 9999);

Multiple-Row Subqueries

A multiple-row subquery returns multiple rows in the output, so you need to use multiple-row comparison operators, such as IN, ANY, and ALL. Using a single-row operator with a multiple-row subquery returns this common Oracle error:

ERROR:ORA-01427: single-row subquery returns more than one row

Multiple-Column Subqueries

Multiple-column subqueries are queries where the inner query retrieves the values of more than one column. The rows in the subquery are then evaluated in the main query in pair-wise comparison, column by column and row by row.

Advanced Subqueries

Correlated subqueries are more complex than regular subqueries and answer questions such as “What are the names of all employees whose salary is below the average salary of their department?” The inner query computes the average salary, and the outer or main query gets the employee infor-mation. However, for each employee in the main (outer) query, the inner query has to be computed, because department averages depend on the department number of the employee in the outer query.

The Exists and Not Exists Operators

The EXISTS operator tests for the existence of rows in the inner query or subquery when you’re using subqueries. The NOT EXISTS operator tests for the nonexistence of rows in the inner query. In the following statement, the EXISTS operator will be TRUE if the subquery returns at least one row:

SQL> SELECT department_id FROM departments d WHERE EXISTS (SELECT * FROM employees e WHERE d.department_id = e.department_id);

Using Regular ExpressionsOracle Database 11g provides support for regular expressions that you can use as part of SQL state-ments. Regular expressions let you use special operators to manipulate strings or carry out a search.

Page 18: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1238 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

Traditionally, developers used operators such as LIKE, REPLACE, and SUBSTRING in their search expres-sions. However, these expressions forced you to write lengthy SQL and PL/SQL code when performing complex searches. Oracle Database 11g lets you perform complex searches and string manipulations easily with regular expressions.

■Note Oracle’s regular expression features follow the popular POSIX standards.

A regular expression searches for patterns in character strings. The character string has to be one of CHAR, VARCHAR2, NCHAR, or NVARCHAR2, and the regular expression function can be one of the following:

• REGEXP_LIKE

• REGEXP_REPLACE

• REGEXP_INSTRING

• REGEXP_SUBSTRING

The REGEXP_LIKE function evaluates strings using a specified set of characters. The regular expres-sion function searches for a pattern in a string, which is specified with the SOURCE_STRING parameter in the function. The PATTERN variable represents the actual regular expression, which is the pattern to search for. A regular expression is usually a text literal; it can be one of CHAR, VARCHAR2, NCHAR, or NVARCHAR2, and it can be a maximum of 512 bytes long. You can also specify an optional match parameter to modify the matching behavior. For example, a value of i specifies case-insensitive matching, while c specifies case-sensitive matching.

Here is the syntax of the REGEXP_LIKE function:

REGEXP_LIKE(source_string, pattern [,match_parameter])

If you want to carry out string-manipulation tasks, you can use the REGEXP_INSTR, REGEXP_REPLACE, or REGEXP_SUBSTR built-in functions. These are really extensions of the normal SQL INSTR, REPLACE, and SUBSTR functions.

Regular expression features use characters like the period (.), asterisk (*), caret (^), and dollar sign ($), which are common in UNIX and Perl programming. The caret character (^), for example, tells Oracle that the characters following it should be at the beginning of the line. Similarly, the $ character indicates that a character or a set of characters must be at the very end of the line. Here’s an example using the REGEXP_LIKE function that picks up all names with consecutive vowels:

SQL> SELECT last_name FROM employees WHERE REGEXP_LIKE (last_name, '([aeiou])\1', 'i');

LAST_NAME-----------FreedmanGreenbergKhooGeeLee. . .SQL>

Page 19: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1239

Here’s another example that quickly searches for employees who were hired between the years 2000 and 2008.

SQL> SELECT emp_name, salary, 2 TO_CHAR(hire_date,'yyyy') year_of_hire 3 FROM emp 4* WHERE REGEXP_LIKE (TO_CHAR (hire_date, 'yyyy'), '^200[0-8]$');

LAST_NAME FIRST_NAME SALARY YEAR---------- ----------- ---------- ----Austin David 4800 2007Chen John 8200 2007Alapati Shannon 7700 2007Baida Shelli 2900 2007Tobias Sigal 2800 2007Weiss Matthew 8000 2007

Abstract Data TypesThis section briefly reviews the important Oracle features that facilitate object-oriented programming. Abstract types, also called object types, are at the heart of Oracle’s object-oriented programming. Unlike a normal data type, an abstract data type contains a data structure along with the functions and procedures needed to manipulate the data; thus, data and behavior are coupled.

Object types are like other schema objects, and they consist of a name, attributes, and methods. Object types are similar to the concept of classes in C++ and Java. Oracle support for object-oriented features, such as types, makes it feasible to implement object-oriented features, such as encapsula-tion and abstraction, while modeling complex real-life objects and processes. Oracle also supports single inheritance of user-defined SQL types.

The CREATE TYPE CommandObject types are created by users and stored in the database like Oracle data types such as VARCHAR2, for example. The CREATE TYPE command lets you create an abstract template that corresponds to a real-world object. Here’s an example:

SQL> CREATE TYPE person AS object 2 (name varchar2(30), 3 phone varchar2(20));

Type created.SQL>

Object TablesObject tables contain objects such as the person type that was created in the previous section. Here’s an example:

SQL> CREATE TABLE person_table OF person;

Table created.SQL>

Here’s the interesting part. The person_table table doesn’t contain single-value columns like a regular Oracle table—its columns are types, which can hold multiple values. You can use object

Page 20: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1240 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

tables to view the data as a single-column table or a multicolumn table that consists of the compo-nents of the object type. Here’s how you would insert data into an object table:

SQL> INSERT INTO person_table 2 VALUES 3 ('john smith', '1-800-555-9999');

1 row created.SQL>

CollectionsCollections are ideal for representing one-to-many relationships among data. Oracle offers you two main types of collections: varrays and nested tables. We’ll look at these two types of collections in more detail in the following sections.

Varrays

A varray is simply an ordered collection of data elements. Each element in the array is identified by an index, which is used to access that particular element. Here’s how you declare a VARRAY type:

SQL> CREATE TYPE prices AS VARRAY (10) OF NUMBER (12,2);

Nested Tables

A nested table consists of an ordered set of data elements. The ordered set can be of an object type or an Oracle built-in type. Here’s a simple example:

SQL> CREATE TYPE lineitem_table AS TABLE OF lineitem;

To access the elements of a collection with SQL, you can use the TABLE operator, as shown in the following example. Here, history is a nested table and courses is the column you want to insert data into:

SQL> INSERT INTO TABLE(SELECT courses FROM department WHERE name = 'History') VALUES('Modern India');

Type InheritanceYou can create not just types, but also type hierarchies, which consist of parent supertypes and child subtypes connected to the parent types by inheritance. Here’s an example of how you can create a subtype from a supertype. First, create the supertype:

SQL> CREATE TYPE person_t AS OBJECT ( name varchar2(80), social_sec_no number, hire_date date, member function age() RETURN number, member function print() RETURN varchar2) NOT FINAL;

Next, create the subtype, which will inherit all the attributes and methods from its supertype:

Page 21: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1241

SQL> CREATE TYPE employee_t UNDER person_t (salary number, commission number, member function wages () RETURN number, OVERRIDING member function print () RETURN varchar2);

The Cast OperatorThe CAST operator enables you to do two things. It lets you convert built-in data types and also convert a collection-type value into another collection-type value.

Here’s an example of using CAST with built-in data types:

SQL> SELECT product_id, CAST(description AS VARCHAR2(30)) FROM product_desc;

PL/SQLAlthough SQL is easy to learn and has a lot of powerful features, it doesn’t allow the procedural constructs of third-generation languages such as C. PL/SQL is Oracle’s proprietary extension to SQL, and it provides you the functionality of a serious programming language. One of the big advantages of using PL/SQL is that you can use program units called procedures or packages in the database, thus increasing code reuse and performance.

The Basic PL/SQL BlockA PL/SQL block is an executable program. A PL/SQL code block, whether encapsulated in a program unit such as a procedure or specified as a free-form anonymous block, consists of the following structures, with a total of four key statements, only two of which are mandatory:

• DECLARE: In this optional section, you declare the program variables and cursors.

• BEGIN: This mandatory statement indicates that SQL and PL/SQL statements will follow it.

• EXCEPTION: This optional statement specifies error handling.

• END: This mandatory statement indicates the end of the PL/SQL code block.

Here’s an example of a simple PL/SQL code block:

SQL> DECLARE isbn NUMBER(9) BEGIN isbn := 123456789; insert into book values (isbn, 'databases', 59.99); COMMIT; END;SQL>

Declaring VariablesYou can declare both variables and constants in the DECLARE section. Before you can use any variable, you must first declare it. A PL/SQL variable can be a built-in type such as DATE, NUMBER, VARCHAR2, or CHAR, or it can be a composite type such as VARRAY. In addition, PL/SQL uses the BINARY_INTEGER and BOOLEAN data types.

Page 22: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1242 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

Here are some common PL/SQL variable declarations:

hired_date DATE;emp_name VARCHAR2(30);

In addition to declaring variables, you can also declare constants, as shown in the following example:

tax_rate constant number := 0.08;

You can also use the %TYPE attribute to declare a variable that is of the same type as a specified table’s column, as shown here:

emp_num employee.emp_id%TYPE;

The %ROWTYPE attribute specifies that the record (row) is of the same data type as a database table. In the following example, the DeptRecord record has all the columns contained in the depart-ment table, with identical data types and length:

declarev_DeptRecord department%ROWTYPE;

Writing Executable StatementsAfter the BEGIN statement, you can enter all your SQL statements. These look just like your regular SQL statements, but notice the difference in how you handle a SELECT statement and an INSERT state-ment in the following sections.

A SELECT Statement in PL/SQL

When you use a SELECT statement in PL/SQL, you need to store the retrieved values in variables, as shown here:

DECLAREname VARCHAR2(30);BEGINSELECT employee_name INTO name FROM employees WHERE emp_id=99999;END;/

DML Statements in PL/SQL

Any INSERT, DELETE, or UPDATE statements in PL/SQL work just as they do in regular SQL. You can use the COMMIT statement after any such operation, as shown here:

BEGINDELETE FROM employee WHERE emp_id = 99999;COMMIT;END;/

Handling ErrorsIn PL/SQL, an error or a warning is called an exception. PL/SQL has some internally defined errors, and you can also define your own error conditions. When any error occurs, an exception is raised

Page 23: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1243

and program control is handed to the exception-handling section of the PL/SQL program. If you define your own error conditions, you have to raise exceptions by using a special RAISE statement.

The following example shows an exception handler using the RAISE statement:

DECLARE acct_type INTEGER := 7;BEGIN IF acct_type NOT IN (1, 2, 3) THEN RAISE INVALID_NUMBER; -- raise predefined exception END IF;EXCEPTION WHEN INVALID_NUMBER THEN ROLLBACK;END;/

PL/SQL Control StructuresPL/SQL offers you several types of control structures, which enable you to perform iterations of code or conditional execution of certain statements. The various types of control structures in PL/SQL are covered in the following sections.

Conditional Control

The main type of conditional control structure in PL/SQL is the IF statement, which enables condi-tional execution of statements. You can use the IF statement in three forms: IF-THEN, IF-THEN-ELSE, and IF-THEN-ELSEIF. Here’s an example of a simple IF-THEN-ELSEIF statement:

BEGIN . . . IF total_sales > 100000 THEN bonus := 5000; ELSEIF total_sales > 35000 THEN bonus := 500; ELSE bonus := 0; END IF; INSERT INTO new_payroll VALUES (emp_id, bonus . . .);END;/

PL/SQL Looping Constructs

PL/SQL loops provide a way to perform iterations of code for a specified number of times or until a certain condition is true or false. The following sections cover the basic types of looping constructs.

The Simple Loop

The simple loop construct encloses a set of SQL statements between the keywords LOOP and END LOOP. The EXIT statement ends the loop. You use the simple loop construct when you don’t know how many times the loop should execute. The logic inside the LOOP and END LOOP statements decides when the loop is terminated.

Page 24: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1244 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

In the following example, the loop will be executed until a quality grade of 6 is reached:

LOOP . . . if quality_grade > 5 then . . . EXIT; end if;END LOOP;

Another simple loop type is the LOOP . . . EXIT . . . WHEN construct, which controls the dura-tion of the loop with a WHEN statement. A condition is specified for the WHEN statement, and when this condition becomes true, the loop will terminate. Here’s a simple example:

DECLARE count_num NUMBER(6);BEGIN count_num := 1; LOOP dbms_output.put_line(' This is the current count '|| count_num); count_num := count_num + 1; Exit when count_num > 100; END LOOP;END;

The WHILE Loop

The WHILE loop specifies that a certain statement be executed while a certain condition is true. Note that the condition is evaluated outside the loop. Each time the statements within the LOOP and END LOOP statements are executed, the condition is evaluated. When the condition no longer holds true, the loop is exited. Here’s an example of the WHILE loop:

WHILE total <= 25000LOOP . . . SELECT sal INTO salary FROM emp WHERE . . . total := total + salary;END LOOP;

The FOR Loop

The FOR loop is used when you want a statement to be executed a certain number of times. The FOR loop emulates the classic do loop that exists in most programming languages. Here’s an example of the FOR loop:

BEGIN FOR count_num IN 1..100 LOOP dbms_output.put_line('The current count is : '|| count_num); END LOOP;END;

PL/SQL RecordsRecords in PL/SQL let you treat related data as a single unit. Records contain fields, with each field standing for a different item. You can use the %ROWTYPE attribute to declare a table’s columns as a

Page 25: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1245

record, which uses the table as a cursor template, or you can create your own records. Here’s a simple example of a record:

DECLARE TYPE MeetingTyp IS RECORD ( date_held DATE, location VARCHAR2(20), purpose VARCHAR2(50));

To reference an individual field in a record, you use dot notation, as shown here:

MeetingTyp.location

Using CursorsAn Oracle cursor is a handle to an area in memory that holds the result set of a SQL query, enabling you to individually process the rows in the result set. Oracle uses implicit cursors for all DML state-ments. Explicit cursors are created and used by application coders.

Implicit CursorsImplicit cursors are automatically used by Oracle every time you use a SELECT statement in PL/SQL. You can use implicit cursors in statements that return just one row. If your SQL statement returns more than one row, an error will result.

In the following PL/SQL code block, the SELECT statement makes use of an implicit cursor:

DECLARE emp_name varchar2(40); salary float;BEGIN SELECT emp_name, salary FROM employees WHERE employee_id=9999; dbms_output.put_line('employee_name : '||emp_name||' salary :'||salary);END;/

Explicit CursorsExplicit cursors are created by the application developer, and they facilitate operations with a set of rows, which can be processed one by one. You always use explicit cursors when you know your SQL statement will return more than one row. Notice that you have to declare an explicit cursor in the DECLARE section at the beginning of the PL/SQL block, unlike an implicit cursor, which you never refer to in the code.

Once you declare your cursor, the explicit cursor will go through these steps:

1. The OPEN clause will identify the rows that are in the cursor and make them available for the PL/SQL program.

2. The FETCH command will retrieve data from the cursor into a specified variable.

3. The cursor should always be explicitly closed after your processing is completed.

Listing A-4 shows how a cursor is first created and then used within a loop.

Page 26: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1246 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

Listing A-4. Using an Explicit Cursor

DECLARE/* The cursor select_emp is explicitly declared */ CURSOR select_emp IS select emp_id, city from employees where city = 'DALLAS'; v_empno employees.emp_id%TYPE; v_empcity employees.city%TYPE;BEGIN /* The cursor select_emp is opened */ Open select _emp; LOOP /* The select_emp cursor data is fetched into v_empno variable */ FETCH select_emp into v_empno; EXIT WHEN select_emp%NOTFOUND; dbms_output.put_line(v_empno|| ','||v_empcity); END LOOP; /* The cursor select_emp is closed */ Close select_emp;END;/

Cursor AttributesIn the example shown in Listing A-4, a special cursor attribute, %NOTFOUND, is used to indicate when the loop should terminate. Cursor attributes are very useful when you’re dealing with explicit cursors. Here are the main cursor attributes:

• %ISOPEN is a Boolean attribute that evaluates to false after the SQL statement completes execution. It returns true as long as the cursor is open.

• %FOUND is a Boolean attribute that tests whether the SQL statement matches any row—that is, whether the cursor has any more rows to fetch.

• %NOTFOUND is a Boolean attribute that tells you that the SQL statement doesn’t match any row, meaning there are no more rows left to fetch.

• %ROWCOUNT gives you the number of rows the cursor has fetched so far.

Cursor FOR LoopsNormally when you use explicit cursors, cursors have to be opened, the data has to be fetched, and finally the cursor needs to be closed. A cursor FOR loop automatically performs the open, fetch, and close procedures, which simplifies your job. Listing A-5 shows an example that uses a cursor FOR loop construct.

Listing A-5. Using the Cursor FOR Loop

DECLARE CURSOR emp_cursor IS SELECT emp_id, emp_name, salary FROM employees; v_emp_info employees%RowType;

Page 27: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1247

Begin FOR emp_info IN emp_cursor LOOP dbms_output.put_line ('Employee id : '||emp_id||'Employee name : '|| emp_name||'Employee salary :'||salary); END LOOP;END;/

Cursor VariablesCursor variables point to the current row in a multirow result set. Unlike a regular cursor, though, a cursor variable is dynamic—that is, you can assign new values to a cursor variable and pass it to other procedures and functions. Let’s look at how you can create cursor variables in PL/SQL.

First, define a REF CURSOR type, as shown here:

DECLARE TYPE EmpCurTyp IS REF CURSOR RETURN dept%ROWTYPE;

Next, declare cursor variables of the type DeptCurTyp in an anonymous PL/SQL code block or in a procedure (or function), as shown in the following code snippet:

DECLARE TYPE EmpRecTyp IS RECORD ( Emp_id NUMBER(9), emp_name VARCHAR2(3O), sal NUMBER(7,2)); TYPE EmpCurTyp IS REF CURSOR RETURN EmpRecTyp; emp_cv EmpCurTyp; -- declare cursor variable

Procedures, Functions, and PackagesA PL/SQL procedure can be used to perform various DML operations. The following is a simple Oracle procedure:

create or replace procedure new_employee (emp_id number,last_name varchar(2), first_name varchar(2))isbegin insert into employees values ( emp_id, last_name, first_name);end new_employee;/

Unlike a PL/SQL procedure, a function returns a value, as shown in the following example:

CREATE OR REPLACE FUNCTION sal_ok (salary REAL, title VARCHAR2) RETURN BOOLEAN IS min_sal REAL; max_sal REAL;BEGIN SELECT losal, hisal INTO min_sal, max_sal FROM sals WHERE job = title; RETURN (salary >= min_sal) AND (salary <= max_sal);END sal_ok;

Oracle packages are objects that usually consist of several related procedures and functions, and the package is usually designed to perform an application function by invoking all the related procedures

Page 28: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1248 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

and functions within the package. Packages are extremely powerful, because they can contain large amounts of functional code and be repeatedly executed by several users.

A package usually has two parts: a package specification and a package body. The package spec-ification declares the variables, cursors, and subprograms (procedures and functions) that are part of the package. The package body contains the actual cursors and subprogram code.

Listing A-6 shows a simple Oracle package.

Listing A-6. A PL/SQL Package

/* First, the Package Specification /* create or replace package emp_pkg as type list is varray (100) of number (5); procedure new_employee (emp_id number, last_name varchar2, first_name varchar2); procedure salary_raise ( emp_id number, raise number);end emp_pkg;//* The Package Body follows */create or replace package body emp_pkg asprocedure new_employee (emp_id number,last_name varchar(2), first_name varchar(2) is begin insert into employees values ( emp_id, last_name, first_name); end new_employee; procedure salary_raise ( emp_num number, raise_pct real) is begin update employees set salary = salary * raise_pct where emp_id = emp_num; end salary_raise;end emp_pkg;/

If you want to use emp_pkg to award a raise to an employee, all you have to do is execute the following:

SQL> EXECUTE emp_pkg.salary_raise(99999, 0.15);

Oracle XML DBA typical organization has information stored in multiple formats, some of which may be organized in relational databases, but most of which is stored outside the database. The nondatabase information may be stored in application-specific formats, such as Excel spreadsheets. Storing the nondatabase information in XML format instead makes it easier to access and update nonstructured organiza-tional information.

Oracle XML DB isn’t really a special type of database for XML. It simply refers to the set of built-in XML storage and retrieval technologies for the manipulation of XML data. Oracle XML DB provides the advantages of object-relational database technology and XML technology. For example, one of the major problems involved in dealing with XML data from within a relational database is that most XML data is hierarchical in nature, whereas the Oracle database is based on the relational model. Oracle manages to deal effectively with the hierarchical XML data by using special SQL operators and methods that let you easily query and update XML data in an Oracle database. Oracle XML DB builds

Page 29: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1249

the XML Document Object Model (DOM) into the Oracle kernel. Thus, most XML operations are treated as part of normal database processing.

Oracle XML DB provides the ability to view both structured and nonstructured information as relational data. You can view the data as either rows in a table or nodes in an XML document.

Here is a brief list of the benefits offered by Oracle XML DB:

• You can access XML data using regular SQL queries.

• You can use Oracle’s OLTP, data warehousing, test, spatial data, and multimedia features to process XML data.

• You can generate XML from an Oracle SQL query.

• You can transform XML into HTML format easily.

Storing XML in Oracle XML DBOracle uses a special native data type called XMLType to store and manage XML data in a relational table. XMLType and XDBURIType, which is another built-in type for XML data, enable you to leave the XML parsing, storage, and retrieval to the Oracle database. You can use the XMLType data type just as you would the usual data types in an Oracle database. You can now store a well-formed XML docu-ment in the database as an XML test using the CLOB base data type.

Here’s an example of using the XMLType data type:

SQL> CREATE TABLE sales_catalog_table 2 (sales_num number(18), 3 sales_order xmltype);Table created.SQL> DESC sales_catalog_table Name Null? Type --------------------- ----- -------- SALES_NUM NUMBER(18) SALES_ORDER XMLTYPESQL>

The XMLType data type comes with a set of XML-specific methods, which you use to work with XMLType objects. You can use these methods to perform common database operations, such as checking for the existence of a node and extracting a node. The methods also support several oper-ators that enable you to access and manipulate XML data as part of a regular SQL statement. These operators follow the emerging SQL/XML standard. Using the well-known XPath notation, the SQL/XML operators traverse XML structures to find the node or nodes on which they should use the SQL operations. Here are some of the important SQL/XML operators:

• Extract() extracts a subset of the nodes contained in the XMLType.

• ExistsNode() checks whether a certain node exists in the XMLType.

• Validating() validates the XMLType contents against an XML schema.

• Transform() performs an XSL transformation.

• ExtractValue() returns a node corresponding to an XPath expression.

XML is in abstract form compared to the normal relational table entries. To optimize and execute statements that involve XML data, Oracle uses a query-rewrite mechanism to transform an XPath expression into an equivalent regular SQL statement. The optimizer then processes the trans-formed SQL statement like any other SQL statement.

Page 30: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1250 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

You can store XML in Oracle XML DB in the following ways:

• You can use SQL or PL/SQL to insert the data. Using XMLType constructors, you must first convert the sourced data into an XMLType instance.

• You can use the Oracle XML DB repository to store the XML data.

Here’s a simple example using the sales_catalog_table table to demonstrate how to perform SQL-based DML operations with an XML-enabled table. In Listing A-7, an XML document is inserted into sales_catalog_table.

Listing A-7. Inserting an XML Document into an Oracle Table

SQL> INSERT INTO sales_catalog_table 2 VALUES (123456, 3 XMLTYPE( 4 '<SalesOrder> 5 <Reference>Alapati - 200302201428CDT</Reference> 6 <Actions/> 7 <Reject/> 8 <Requestor>Nina U. Alapati</Requestor> 9 <User>ALAPATI</User> 10 <SalesLocation>Dallas</SalesLocation> 11 <ShippingInstructions/> 12 <DeliveryInstructions>Bicycle Courier</DeliveryInstructions> 13 <ItemDescriptions> 14 <ItemDescription ItemNumber="1"> 15 <Description>Expert Oracle DB Administration</Description> 16 <ISBN Number="1590590228"Price="59.95"Quantity="5"/> 17 </ItemDescription> 18 </ItemDescriptions> 19* </SalesOrder>'));1 row created.SQL>

You can query the sales_catalog_table table’s sales_order column, as shown in Listing A-8, to view the XML document in its original format.

Listing A-8. Viewing XML Data Stored in an Oracle Table

SQL> SELECT sales_order FROM 2 sales_catalog_table; <SalesOrder> <Reference>Alapati - 200302201428CDT</Reference> <Actions/> <Reject/> <Requestor>Sam R. Alapati</Requestor> <User>ALAPATI</User> <SalesLocation>Dallas</SalesLocation> <ShippingInstructions/> <DeliveryInstructions>Bicycle Courier</DeliveryInstructions> <ItemDescriptions> <ItemDescription ItemNumber="1"> <Description>Expert Oracle DB Administration</Description> <ISBN Number="9999990228" Price="59.95" Quantity="2"/> </ItemDescription>

Page 31: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1251

</ItemDescriptions></SalesOrder>SQL>

Once you create the sales_catalog_table table, it’s very easy to retrieve data using one of the methods I just described. The following example shows how to query the table using the extract() method. Note that the query includes XPath expressions and the SQL/XML operators extractValue and existsNode to find the requestor’s name where the value of the /SalesOrder/SalesLocation/text() node contains the value Dallas.

SQL> SELECT extractValue(s.sales_order,'/SalesOrder/Requestor') 2 FROM sales_catalog_table s 3 WHERE existsNode(s.SALES_ORDER, 4* '/SalesOrder[SalesLocation="Dallas"]') = 1;

EXTRACTVALUE(S.SALES_ORDER,'/SALESORDER/REQUESTOR')---------------------------------------------------Nina U. AlapatiSQL>

The Oracle XML DB RepositoryThe best way to process XML documents in Oracle XML DB is to first load them into a special repos-itory called the Oracle XML DB repository. The XML repository is hierarchical, like most XML data, and it enables you to easily query XML data. The paths and URLs in the repository represent the rela-tionships among the XML data, and a special hierarchical index is used to traverse the folders and paths within the repository. The XML repository can hold non-XML data such as JPEG images, Word documents, and more.

You can use SQL and PL/SQL to access the XML repository. XML authoring tools can directly access the documents in the XML repository using popular Internet protocols such as HTTP, FTP, and WebDAV. For example, you can use Windows Explorer, Microsoft Office, and Adobe Acrobat to work with the XML documents that are stored in the XML repository. XML is by nature document-centric, and the XML repository provides applications with a file abstraction when dealing with XML data.

Setting Up an XML SchemaBefore you can start using Oracle XML DB to manage XML documents, you need to perform the following tasks:

1. Create an XML schema. For example, SalesOrder, shown in Listing A-7, is a simple XML schema that reflects a simple XML document. Within the SalesOrder schema are elements such as ItemDescription, which provides details about the attributes of the component items.

2. Register the XML schema. After the XML schema is created, you must register it with the Oracle database using a PL/SQL procedure. When you register the XML schema, Oracle will create the SQL objects and the XMLType tables that are necessary to store and manage the XML doc-uments. For the example shown in Listing A-6, registering the XML schema will create a table called SalesOrder automatically, with one row in the table for each SalesOrder document loaded into the XML repository. The XML schema is registered under the URL http://localhost:8080/home/SCOTT/xdb/salesorder.xsd, and it contains the definition of the SalesOrder element.

Page 32: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1252 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

Creating a Relational View from an XML DocumentEven if a developer doesn’t know much XML, he or she can use the XML documents stored in the Oracle database by creating relational views based on the XML documents. The following example maps nodes in an XML document to columns in a relational view called salesorder_view:

SQL> CREATE OR REPLACE VIEW salesorder_view 2 (requestor,description,sales_location) 3 AS SELECT 4 extractValue(s.sales_order,'/SalesOrder/Requestor'), 5 extractValue(s.sales_order,'/SalesOrder/Sales_Location') 6* FROM sales_Catalog_Table s ;

View created.SQL>

You can query salesorder_view like you would any other view in an Oracle database, as shown here:

SQL> SELECT requestor,sales_location FROM salesorder_view;

REQUESTORSALES_LOCATIONAparna AlapatiDallasSQL>

Oracle and JavaYou can use both PL/SQL and Java to write applications that need Oracle database access. Although PL/SQL has several object-oriented features, the Java language is well known as an object-oriented programming language. If your application needs heavy database access and must process large amounts of data, PL/SQL is probably a better bet. However, for open distributed applications, Java-based applications are more suitable.

The Oracle database contains a Java Virtual Machine (JVM) to interpret Java code from within the database. Just as PL/SQL enables you to store code on the server and use it multiple times, you can also create Java stored procedures and store them in the database. These Java stored procedures are in the form of Java classes. You make Java files available to the Oracle JVM by loading them into the Oracle database as schema objects.

You can use the Java programming language in several ways in an Oracle database. You can invoke Java methods in classes that are loaded in the database in the form of Java stored procedures. You can also use two different application programming interfaces (APIs), Java Database Connec-tivity (JDBC) or SQLJ, to access the Oracle database from a Java-based application program. In the sections that follow, we’ll briefly look at the various ways you can work with Java and the Oracle database.

Java Stored ProceduresJava stored procedures are, of course, written using Java, and they facilitate the implementation of data-intensive business logic using Java. These procedures are stored within the database like PL/SQL stored procedures. Java stored procedures can be seen as a link between the Java and non-Java environments.

Page 33: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

A PP E N DI X ■ O R A CL E D AT A B ASE 1 1 G S Q L AN D P L / S QL : A B R I E F P R IM E R 1253

You can execute Java stored procedures just as you would PL/SQL stored procedures. Here’s a summary of the steps involved in creating a Java stored procedure:

1. Define the Java class.

2. Using the Java compiler, compile the new class.

3. Load the class into the Oracle database. You can do this by using the loadjava command-line utility.

4. Publish the Java stored procedure.

Once you’ve completed these steps, you can invoke the Java stored procedure.

JDBCJDBC is a popular method used to connect to an Oracle database from Java. Chapter 10 contains a complete example of a Java program. JDBC provides a set of interfaces for querying databases and processing SQL data in the Java programming language.

Listing A-9 shows a simple JDBC program that connects to an Oracle database and executes a simple SQL query.

Listing A-9. A Simple JDBC Program

import java.sql.*;public class JDBCExample { public static void main(String args[]) throws SQLException/* Declare the type of Oracle Driver you are using */ {DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());/* Create a database connection for the JDBC program */Connection conn=DriverManager.getConnection( "jdbc:oracle:thin:@nicholas:1521:aparna","hr","hr");Statement stmt = conn.createStatement();/* Pass a query to SQL and store the results in the result set rs */ResultSet rs =stmt.executeQuery("select emp_id, emp_name,salary from employees");/* Using the while loop, result set rs is accessed row by row */while(rs.next()){int number = rs.getInt(1);String name= rs.getString(2);System.out.println(number+" "+name+" "+salary); }/* Close the JDBC result set and close the database connection */rs.close();conn.close(); }}

JDBC is ideal for dynamic SQL, where the SQL statements aren’t known until run time.

SQLJSQLJ is a complementary API to JDBC, and it’s ideal for applications in which you’re using static SQL (SQL that’s known before the execution). Being static, SQLJ enables you to trap errors before they

Page 34: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1254 AP P E N D I X ■ O R AC L E D AT AB A SE 1 1 G S QL A N D P L / SQ L : A B R I E F P R I M E R

occur during run time. Keep in mind that even with SQLJ, you still use JDBC drivers to access the database.

There are three steps involved in executing a SQLJ program:

1. Create the SQLJ source code.

2. Translate the SQLJ source code into Java source code using a Java compiler.

3. Execute the SQLJ runtime program after you connect to the database.

Listing A-10 contains a simple SQLJ example that shows how to execute a SQL statement from within Java.

Listing A-10. A Simple SQLJ Program

import java.sql.*;import sqlj.runtime.ref.DefaultContext;import oracle.sqlj.runtime.Oracle;/* Declare the variables here *//* Define an Iterator type to store query results */#sql iterator ExampleIter (int emp_id, String emp_name,float salary);public class MyExample/* The main method */ { public static void main (String args[]) throws SQLException {/* Establish the database connection for SQLJ */ Oracle.connect ("jdbc:oracle:thin:@shannon:1234:nicholas1", "hr", "hr");/* Insert a row into the employees table */ #sql { insert into employees (emp_id, emp_name, salary) values (1001, 'Nina Alapati', 50000) };/* Create an instance of the iterator ExampleIter */ ExampleIter iter;/* Store the results of the select query in the iterator ExampleIter */ #sql iter={ select emp_id, emp_name, salary from employees };/* Access the data stored in the iterator, using the next() method */ while (iter.next()) { System.out.println (iter.emp_id,()+" "+iter.emp_name()+" "+iter.salary()); } }}

As you can see from the SQLJ example in Listing A-10, SQLJ is nothing more than embedded SQL in a Java program. Using SQLJ, you can easily make calls to the database from Java. For a wealth of information on Oracle and Java, please visit Oracle’s Java Center web site (http://otn.oracle.com/tech/java/content.html).

This appendix just provided a very brief introduction to the Oracle Database 11g SQL and PL/SQL capabilities. Although Oracle DBAs aren’t always expected be very proficient in SQL and PL/SQL, the more you know about them, the better off you’ll be as a professional Oracle DBA.

Page 35: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1255

Index

■Symbols! (bang, or exclamation point)

using operating system commands from SQL*Plus, 120

$ (dollar sign) character, SQL, 1238$ sign, UNIX, 53, 55, 69% (percent sign) character, SQL, 1224& prefixing variable names, SQL*Plus, 126* (asterisk) character, SQL, 1238. (period) character, SQL, 1238/ (slash) command, 126, 128/* ... */, comments SQL*Plus, 128@@commandfile notation, SQL, 129^ (caret) character, SQL, 1238_ (underscore) character, SQL, 1224| (pipe) command, UNIX/Linux, 52, 57

■Numerics1:1 (one-to-one) relationship, 261:M (one-to-many) relationship, 2610446 trace event, SQL, 11741NF (First Normal Form), 30–312NF (Second Normal Form), 31–333NF (Third Normal Form), 334NF (Fourth Normal Form), 345NF (Fifth Normal Form), 34

■Aabnormal program failure, 338ABORT option, SHUTDOWN command,

503, 908ABORT_REDEF_TABLE procedure, 941ABP (Autotask Background Process), 1022absolute path, UNIX, 47, 62abstract data types, 1239–1241

CAST operator, 1241collections, 1240CREATE TYPE command, 1239nested tables, 1240object tables, 1239table functions, 664type inheritance, 1240user-defined data types, 264VARRAY type, 1240

ACCEPT command, SQL*Plus, 121accepted addresses, securing network, 614ACCEPT_SQL_PATCH procedure, 1038ACCEPT_SQL_PROFILE procedure, 1115ACCEPT_SQL_PROFILES parameter, 1117, 1118Access Advisor see SQL Access Advisor

access controlfine-grained network access control,

615–618server-side access controls, 614

access control list (ACL), 615, 616, 617access drivers, 648, 650ACCESS PARAMETERS clause, 647access path

ATO analyzing, 1112CBO choosing, 1052

access plan, SQL processing, 1133accessing database see database accessACCOUNT LOCK option, 548ACID properties, transactions, 340acl parameter, CREATE_ACL procedure, 616action components, ADDM, 881Active Session History see ASHactive session management, 554active session pool

Database Resource Manager, 555, 942Active Sessions chart, Database Control, 1196active/inactive pages, memory

management, 81ACTIVE_SESSION_POOL parameter, 560ACTIVE_SESS_POOL_MTH parameter, 560adaptive cursor sharing, 1087–1090adaptive search strategy, 1053adaptive thresholds, 954ADD command, ALTER TABLE, 271ADD LOGFILE GROUP syntax, 983ADD PARTITION command, ALTER TABLE, 291ADD_FILE command, Data Pump, 702, 703,

704, 713ADDFILE procedure, DBMS_LOGMNR, 844ADD_FILTER procedure

DBMS_WORKLOAD_CAPTURE package, 1210Additional Information section, ADDM

reports, 888ADD_LOGFILE procedure, DBMS_LOGMNR,

844, 845ADDM (Automatic Database Diagnostic

Monitor), 146, 209, 877–894analyzing performance problems, 1183–1184automatic performance-tuning features, 1132AWR and, 878configuring, 881–882data dictionary views, 893determining optimal I/O performance, 884enabling, 882findings, 880modes, 882, 883–884

Page 36: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1256 ■IN D E X

performance tuning, 877problems diagnosed by, 878–880pronouncing ADDM, 877purpose of ADDM, 878reasons for invoking ADDM manually, 885recommendations, 878, 880–881running ADDM, 885

using Database Control, 893time-model statistics, 879–880tuning-related advisors, 976when ADDM runs, 882

ADDM analysisPerformance Analysis section, Database

Control, 1197ADDM reports

abbreviated ADDM report, 886components of report, 885confusing with AWR reports, 966content of, 879displaying, 884viewing, 885–891

using Database Control, 890–891using DBMS_ADVISOR, 890

addmrpt.sql script, 885, 888–890ADD_POLICY procedure, DBMS_FGA, 594, 595ADD_POLICY procedure, DBMS_RLS, 584,

585, 586ADD_POLICY_CONTEXT procedure, 584ADD_PRIVILEGE procedure, 616ADD_SQLWKLD_REF procedure, 323ADD_TABLE_RULES procedure, 674adhoc directory, 397admin class, Oracle Secure Backup, 788ADMIN privilege, 612ADMINISTER_RESOURCE_MANAGER

privilege, 555administrative context, 537administrative directories, 397administrative domain, Oracle Secure

Backup, 786administrative files, 394, 397, 399Administrative wait class, 1163Administrators page, Database Control, 148ADMIN_RESTRICTIONS parameter,

listener.ora, 614ADR (Automatic Diagnostic Repository), 178,

211, 1022, 1023–1024alert directory, 178core directory, 178DIAGNOSTIC_DEST parameter, 449flood-controlled incident system, 1026OFA guidelines, 396trace directory, 178viewing results of health check, 1033

ADR Base directory, 1024ADR Command Interpreter see ADRCIADR Home directory, 1024ADRCI, 208, 211, 1022, 1024–1026

ADR homepath, 1025creating incident package, 1027

Advanced Installation option, Universal Installer, 416

Advanced Queuing (AQ), Oracle Streams, 670Advanced Security option, 535, 603, 618ADVISE FAILURE command, Data Recovery

Advisor, 831Advisor Central page

Database Control, 150, 323, 979Grid Control, 890

Advisor Mode section, SQL Access Advisor, 323advisors, 976–977

advisory framework, 212comparing AWR snapshots, 961database metrics, 950instance-related advisor, 976Memory Advisor, 976MTTR Advisor, 976, 981Segment Advisor, 212, 977space-related advisors, 977SQL Access Advisor, 212, 977SQL Tuning Advisor, 212, 976tuning-related advisors, 976Undo Advisor, 977, 980–981

advisory framework, 212, 947, 975–980creating tasks, 978data dictionary views managing, 980Database Control managing, 979DBMS_ADVISOR package managing,

977–979after-image records, redo log files, 176AFTER SUSPEND system event, 386aggregate functions, SQL, 1229, 1232aggregations, materialized views, 315alert directory, ADR, 178

Diag Alert directory, 1024alert log files, 16, 177

creating database, 482location of file, 178managing flash recovery area, 740monitoring using, 958starting Oracle instance, 479viewing alert log using ADRCI, 1025

alert queue, 956alert thresholds

AWR baseline metrics, 953tablespace, 226–227

ALERT_QUE queue, 954alerts

alert queue managing, 956bytes remaining alert, 226critical alert thresholds, 952, 954, 956Database Control managing, 954–955DBA_ALERT_HISTORY view, 958DBA_OUTSTANDING_ALERTS view, 957DBMS_SERVER_ALERT package, 955–956invoking advisors from alert messages, 977managing database alerts, 954, 956managing/monitoring database, 214monitoring system with Grid Control, 160operation suspended alerts, 386

Page 37: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1257■I N D E X

out-of-space warning and critical alerts, 741percent full alert, 226problem-related alerts, 952response action, 954security alerts, 617server-generated alerts, 211, 386, 952–953setting alert thresholds, 954setting notification rules, 955situations causing alerts, 952snapshot-too-old alert, 959stateful/stateless alerts, 952tablespace alerts, 226–227, 956–958threshold-based alerts, 226, 227, 952V$ALERT_TYPES view, 958viewing error alerts, 1029warning alert thresholds, 952, 954, 956

Alerts page, Grid Control, 159Alerts table, Database Control, 953algebra, relational, 21–22algorithms, encryption, 608alias ASM filenames, 917, 918aliases for objects see synonymsAll Metrics page, Database Control, 950ALL PRIVILEGES option, 568ALL value, STATISTICS_LEVEL parameter, 461ALL views, data dictionary views, 204ALLOCATE CHANNEL command, RMAN,

753, 757allocation methods see resource allocationalloc_bytes attribute

CREATE_INDEX_COST procedure, 299ALLOW n CORRUPTION recovery option, 865ALL_ROWS hint, 1067ALL_ROWS value, OPTIMIZER_MODE, 1050ALTER DATABASE command, 224, 232

DATAFILE option, 364OPEN option, 821

ALTER DISKGROUP commandadding/dropping disks, 915, 916DISK_REPAIR_TIME attribute, 908DISMOUNT FORCE clause, 913

ALTER FLASHBACK ARCHIVE statement, 871ALTER INDEX command

COALESCE option, 935INVISIBLE clause, 304modifying type of buffer pool, 189MONITORING USAGE clause, 305REBUILD ONLINE option, 935REBUILD option, 217, 303, 305

ALTER MATERIALIZED VIEW statement, 319ALTER PROFILE command, 552, 599ALTER RESOURCE COST statement, 549ALTER SESSION command

changing dynamic parameter values, 447, 448

ENABLE RESUMABLE clause, 384, 385NAME parameter, 385Resumable Space Allocation, 383SET option, 262

SET SCHEMA option, 327TIMEOUT clause, 384

ALTER SYSTEM command, 262activating Database Resource Manager, 565activating parameter limits in user

profiles, 553changing dynamic parameter values,

447, 448creating Oracle Wallet, 241, 242, 609DEFERRED option, 448dynamic parameter changes, SPFILE, 496SCOPE clause, 496

ALTER TABLE commandADD, 271ADD PARTITION, 291COALESCE PARTITION, 292COMPRESS, 275COMPRESS FOR ALL OPERATIONS, 275, 276COMPRESS FOR DIRECT_LOAD

OPERATIONS, 275DISABLE NOVALIDATE/VALIDATE, 309DROP, 271DROP PARTITION, 291ENABLE NOVALIDATE/VALIDATE, 309ENABLE ROW MOVEMENT, 929EXCHANGE PARTITION, 291MERGE PARTITION, 291migrating tablespaces, 217modifying type of buffer pool, 189MOVE, 273, 275MOVE TABLESPACE, 935PURGE, 244READ ONLY, 273READ WRITE, 274RENAME COLUMN, 272RENAME, 272RENAME PARTITION, 291SHRINK SPACE, 929SPLIT PARTITION, 291UNCOMPRESS, 275

ALTER TABLESPACE commandaltering temporary tablespaces, 231AUTOEXTEND parameter, 224expanding tablespaces, 223FLASHBACK OFF option, 856KEEP clause, 231, 232managing availability of tablespaces,

228, 229renaming tablespaces, 228RETENTION GUARANTEE clause, 363SHRINK SPACE clause, 231–232temporary tablespace groups, 234

ALTER USER command, 547ACCOUNT LOCK option, 548changing user’s password, 547IDENTIFIED BY clause, 547password expiration, 599QUOTA clause, 545

ALTER_ATTRIBUTES procedure, 1013

Page 38: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1258 ■IN D E X

ALTER_PARAM procedure, 533ALTER_SQL_PROFILE procedure, 1115ALWAYS log group, 843ambr_backup_intermediate file, 912analytical functions, SQL, 1231–1232ANALYZE command

collection of optimizer statistics, 1054COMPUTE STATISTICS option, 1055detecting data block corruption, 796INDEX_STATS view, 334managing/monitoring database, 213

ANALYZE TABLE statementLIST CHAINED ROWS clause, 279VALIDATE STRUCTURE clause, 934

ANALYZE_DB/INST/PARTIAL procedures, 883ancestor incarnation, 822, 823APM (Application Performance Monitoring)

tools, 138APPEND clause, SQL*Loader, 629APPEND command, SQL*Plus, 131APPEND option, SQL*Plus

SAVE command, 124SPOOL command, 120STORE command, 116

application attributesfine-grained data access, 579

application contextscreating, 580, 581, 582–583fine-grained data access, 579–581

Application Express, 401Application Performance Monitoring

(APM), 138application security, 618Application Server Control, 139Application wait class, 1163ARBn (ASM rebalance) process, 907arch directory, 397architecture

backup and recovery architecture, 201–202dedicated server architecture, 512Optimal Flexible Architecture, 393–400Oracle Database 11g architecture, 165–214RMAN architecture, 743–744shared server architecture, 512

archival (long-term) backups, RMAN, 780–782ARCHIVE LOG command, SQL*Plus, 135

confirming archive log mode, 491archived redo logs, 175, 184

database recovery with RMAN, 815log%t_%s_%r.arc format, 823not needed for recovery, 867

archivelog deletion policy parameters, RMAN, 766

archivelog destination, 491ARCHIVELOG keyword, CREATE

DATABASE, 459archivelog mode, 184, 459, 726

see also noarchivelog modebacking up redo log files, 775benefits of, 726

Flashback Database limitations, 861noarchivelog/archivelog modes, 176,

491, 492partial database backups, 794whole database backups, 790

archivelog parameters, 459–460archivelog retention policy

out-of-space warning and critical alerts, 741archivelogs

archiving redo log files, 135backing up with RMAN, 775DBCA changing archive logging mode,

491–493defining archivelog destinations, 459LIST ARCHIVELOG ALL command, 761turning on, 492viewing details about, 135

archiver (ARCn) process, 181, 184database hangs, 1187–1188flash recovery area, 735multiple archiver processes, 184

archiving databackup guidelines, 730Flashback Data Archive, 202, 870–874flashback data archiver (FBDA) process, 186partitioned tables, 281

archiving, UNIX, 76ARCHVIELOG parameter, RMAN, 766ARCn see archiver (ARCn) processarguments, UNIX, 70arrays

transforming array data with rules, 668–670user-defined data types, 264

ARRAYSIZE variable, SQL*Plus, 107AS clause

materialized views, 319privileged SQL*Plus sessions, 99

AS OF clause, SELECT statementFlashback Query, 367–368Flashback Versions Query, 370, 372

ASA_RECOMMENDATIONS function, 980ASH (Active Session History), 210, 947, 971–975

analyzing database activity, 1195analyzing waits, 1169current active session data, 972manageability monitor light (MMNL)

process, 185objects with highest waits, 1170older active session history data, 972sample data, 948V$ACTIVE_SESSION_HISTORY view, 1169

ASH reports, 972–975, 1201analyzing recent session activity with, 1186wait events, 975

ashrpt.sql script, 972, 1186ashrpti.sql script, 1186ASM (Automatic Storage Management), 94, 209,

900–920architecture, 901–902benefits of, 901

Page 39: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1259■I N D E X

Cluster Synchronization Service (CSS) and, 902–904

COMPATIBLE parameters, 910Database Control managing, 900disk space allocation units, 902DISK_REPAIR_TIME attribute, 910fast mirror resync feature, 908–909file templates, 917, 918installing, 902Logical Volume Manager, 900OSASM group, 408preferred mirror read feature, 909specifying database or ASM instance, 452storage, 902, 904SYSASM privilege, 570TEMPLATE.TNAME attributes, 910

ASM background (ASMB) process, 185, 907ASM Cache component, SGA, 906ASM databases

backing up ASM database, 907creating ASM-based database, 919migrating with Database Control, 920–921migrating with RMAN, 919–920

ASM disk groups, 900, 901, 902adding disks to, 915adding performance/redundancy with,

913–914ALTER DISKGROUP command, 908ASM compatibility level, 910asmcmd managing files/directories

within, 911ASM_DISKGROUPS parameter, 905, 906, 907changing ASM disk group attributes, 909–911creating, 914–915creating diskgroup directories for alias

filenames, 917creating new tablespace on, 916disk repair time, 910dropping disks and, 916dropping files from, 918failure groups, 914managing, 913mirroring for redundancy, 914no diskgroups mounted error, 906RDBMS compatibility level, 910rebalancing disk groups, 916redundancy levels, 909specifying allocation unit (AU) sizes, 909striping for performance, 914template redundancy, 910template striping, 910

ASM files, 901, 902, 916, 917–918ASM instances, 900, 901, 902, 903, 904–908

Database Control managing, 907, 914shutting down, 908, 910

ASM mirroring, 901, 909, 914ASM rebalance (ARBn) processes, 185

asmcmd command-line tool, 911–913md_backup command, 911, 912, 913md_restore command, 911, 912, 913requiring ASM instances, 911

ASM_DISKGROUPS parameter, 905, 906, 907ASM_DISKSTRING parameter, 905ASM_POWER_LIMIT parameter, 905, 916ASM_PREFERRED_READ_FAILURE_GROUPS

parameter, 909ASM-related background processes, 185AS_OF clause, Flashback Data Archive, 873–874ASSIGN_ACL procedure, 616asterisk (*) character, SQL, 1238asynchronous I/O, DBWn process, 182at (@) sign, SQL*Plus, 124, 125at command, UNIX/Linux, 78at scheduling utility, Windows, 126ATO (Automatic Tuning Optimizer),

1111–1113, 1115atomicity property, transactions, 340ATTACH parameter

Data Pump Export utility, 688, 700, 701, 702, 703

ATTRIBUTE clause, ASM, 909–911attributes, relational database model, 20

entity-relationship (ER) modeling, 25, 27AUD$ table, 611audit files, default location for, 587AUDIT SESSION statement, 553, 589audit trails, 596, 587audit_column parameter, 594audit_column_opts parameter, 594, 595audit_condition parameter, 594AUDIT_FILE_DEST parameter, 451, 587, 588auditing

audit levels, 587autonomous transactions, 382database auditing, 612database security, 611database usage, 586–596DBA_AUDIT_TRAIL view, 588default location for audit file, 587fine-grained auditing, 593–596limiting data written to audit trail, 587NOAUDIT keyword, 589standard auditing, 587–593SYS.AUD$ table, 588, 596

audit-related parameters, 450–451AUDIT_SYS_OPERATIONS parameter, 451, 458,

588, 612AUDIT_TRAIL parameter, 450, 587, 588, 611audit_trail parameter, 594AUM (Automatic Undo Management), 200,

356–362, 921creating default undo tablespace, 460reducing buffer busy wait events, 1176snapshot-too-old error, 364

Page 40: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1260 ■IN D E X

undo segments, 361UNDO_MANAGEMENT parameter, 357UNDO_RETENTION parameter, 359–362UNDO_TABLESPACE parameter, 357–359

authenticationsee also passwords; securitydatabase authentication, 596–601

connecting to RMAN, 745–746locking accounts, 598

denying remote client authentication, 615external authentication, 601–602password authentication, 602proxy authentication, 602users, 596–602

AUTHENTICATION_SERVICES parameter, 526AUTHID clause, CREATE PROCEDURE, 573authorization

see also database accesscentralized user authorization, 602database creation, 446role authorization, 575–576

AUTO option/parametersegment space management, 217, 219, 220

AUTO value, OPTIONS attributeGATHER_DATABASE_STATS procedure, 1055

AUTOALLOCATE optioncreating tablespaces, 222extent sizing, 216, 219, 220locally managed tablespaces, 219managing extent sizes, 237tablespace storage parameters, 221temporary tablespaces, 233

AUTOBACKUP optionCONTROLFILE parameter, RMAN, 765, 770

AUTOCOMMIT variable, 107, 133, 339AUTOEXTEND clause, 224, 227, 230, 238,

358, 362automated maintenance tasks, 1019–1022automated tasks feature, 211automatic checkpoint tuning, 183, 932–933automatic consumer group switching, 555, 560Automatic Database Diagnostic Monitor

see ADDMautomatic database management, 208–209automatic database startup, 499–501Automatic Diagnostic Repository see ADRAutomatic Disk-Based Backup and

Recovery, 734Automatic Maintenance Tasks page, 488automatic memory management, 195–196,

894–897memory-related initialization

parameters, 457Automatic Optimizer Statistics Collection, 209,

212, 213, 897–899providing statistics to CBO, 1053

automatic performance tuning, 1131–1132automatic PGA memory management, 194, 894automatic secure configuration, 611

Automatic Segment Advisor, 212Automatic Segment Space Management, 218,

928, 1173, 1176automatic service registration, 521–522Automatic Shared Memory Management,

894, 1178automatic space management, 921–933

see also space managementAutomatic SQL Tuning Advisor, 209, 212,

1115–1120SQL plan baselines, 1081

Automatic Storage Management see ASMAutomatic Undo Management see AUMautomatic undo retention tuning, 209Automatic Workload Repository see AWRAUTOMATIC_ORDER

transforming array data with rules, 670autonomous transactions, Oracle, 380–382AUTO_SAMPLE_SIZE procedure, 1055AUTO_SPACE_ADVISOR_JOB, 931Autotask Background Process (ABP), 1022AUTO_TASK_CONSUMER_GROUP, 558Autotrace utility, SQL, 1095–1099auxiliary database

using RMAN for TSPITR, 840, 841AUX_STATS$ table, 1060availability

benefits of archivelog mode, 726disk configuration strategies, 87

Availability page, Database Control, 146Available Targets, Database Control roles, 150Average Active Sessions chart, 1199AVERAGE_WAIT column,

V$SYSTEM_EVENT, 1166AVG function, SQL, 1229AVG_XYZ_TICKS statistic, 1182avm, vmstat utility, 82AWR (Automatic Workload Repository), 210,

947, 959–971ADDM and, 878automatic performance tuning features, 1132baseline metrics, 953baseline templates, 965–971configuring ADDM, 882controlling volume of statistics collected, 882data handling, 960data retention period, 960determining number of undo segments, 359DISPLAY_AWR function, 1092loading SQL plans manually, 1081managing AWR statistics with data

dictionary views, 971moving window baselines, 965performance statistics, 877, 878performance statistics for SQL

statements, 1184performance statistics formats, 959statistics retention period, 960storage space requirement, 960, 964

Page 41: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1261■I N D E X

time-model statistics, 880types of data collected by AWR, 960

AWR page, Database Control, 962AWR reports, 966–971, 1201AWR snapshots, 878, 959

comparing, 961CREATE_SNAPSHOT procedure, 961creating/deleting snapshot baselines,

963–964Database Control managing, 961–963DBMS_WORKLOAD_REPOSITORY

managing, 961DROP_SNAPSHOT procedure, 961managing, 961preserved snapshot set, 963purging, 964–965retention time period, 964running ADDM, 885setting snapshot interval to zero, 961snapshot interval, 964Time Periods Comparison feature, 1206

AWR_REPORT_HTML function, 967AWR_REPORT_TEXT function, 967awrrpt.sql script, 966, 967, 971awrsqrpt.sql script, 1184

■Bbackground CPU time

V$SESS_TIME_MODEL view, 1206background processes, 179, 180–186

archiver (ARCn) process, 181, 184ASM background (ASMB) process, 185ASM rebalance (ARBn) processes, 185change-tracking writer (CTWR), 185checkpoint (CKPT) process, 181, 183database writer (DBWn) process, 180,

181–182flashback data archiver (FBDA), 186getting complete list of, 184job queue coordination (CJQO) process,

181, 185key Oracle background processes, 180lock (LCKn) process, 186log writer (LGWR) process, 180, 182–183manageability monitor (MMON) process,

181, 185manageability monitor light (MMNL)

process, 181, 185memory manager (MMAN) process, 181, 185process monitor (PMON) process, 181, 183rebalance master (RBAL) process, 185recoverer (RECO), 185recovery writer (RVWR) process, 185result cache background (RCBG), 186system monitor (SMON) process, 181, 184viewing all available processes, 186

background processes, UNIX, 75BACKGROUND_DUMP_DEST parameter, 178

Backout feature see Flashback Transaction Backout feature

BACKUP command, 792BACKUP commands, RMAN, 755–757

backing up online with scripts, 775BACKUP ARCHIVELOG ALL, 775BACKUP AS BACKUPSET, 754BACKUP AS BACKUPSET DATABASE, 755BACKUP AS COMPRESSED

BACKUPSET, 780BACKUP AS COPY, 735, 752, 754, 756, 757BACKUP BACKUPSET, 754BACKUP CONTROLFILE, 785BACKUP CURRENT CONTROLFILE, 776BACKUP DATABASE, 742, 755, 756, 774, 777BACKUP DATABASE PLUS

ARCHIVELOG, 775BACKUP DATAFILE, 777BACKUP INCREMENTAL LEVEL, 778BACKUP RECOVERY AREA, 739, 741BACKUP RECOVERY FILES, 739BACKUP TABLESPACE USERS, 777BACKUP VALIDATE, 783, 784cumulative backup, 756, 757differential backup, 756, 757DURATION clause, 777FORMAT clause, 754incremental backups, 756–757KEEP clause, 780KEEP FOREVER clause, 780, 781KEEP UNTIL TIME clause, 780, 781making multiple copies of backup sets, 754RESTORE POINT clause, 780resynchronizing recovery catalog, 769specifying limits for backup duration,

777–778specifying multiple copies, 754

backup files, RMAN, 178backup formats, RMAN, 753backup levels, 728BACKUP OPTIMIZATION parameter,

RMAN, 765backup pieces, RMAN, 752, 754backup retention policy parameters, RMAN,

762–763backup schedules, 733backup sets, RMAN, 752

BACKUP DATABASE command, 755making multiple copies of, 754RMAN storing metadata, 744VALIDATE BACKUPSET command, 761, 783

Backup Solutions Program (BSP), 745backup tags, RMAN, 753backup, DBA role, 3, 6, 95backups, 728–730

see also flash recovery area; recovery; RMAN; RMAN backups

architecture, 201–202archivelog mode, 726–727

Page 42: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1262 ■IN D E X

backing up control file, 784–785backing up Oracle databases, 725–734backup levels, 728backup schedules, 733benefits of tablespaces, 171change-tracking writer (CTWR) process, 185classifying backup media, Oracle Secure

Backup, 789cloning databases, 833–840closed/cold backups, 728consistent backups, 727control file, 201Data Pump technology, 679Data Recovery Advisor, 829–833database backups, 201Database Control tool, 146database corruption detection, 795–798database failures, 801–804datafile backups, 728disaster recovery, 798–800Flashback Data Archive, 870–874flashback recovery techniques, 202Flashback techniques, 847–861frequency of backups, 732HARD initiative, 798inconsistent backups, 727incremental backups, 732, 733incrementally updated backups, RMAN, 778logical backups, 728loss of data since previous backup, 726manual database upgrade process, 437, 439noarchivelog mode, 726–727open backups, 726open/warm/hot backups, 728Oracle Secure Backup, 202, 785–790partial database backups, 727physical backups, 728RAID, 92redo logs, 201redundancy set, maintaining, 730–731RMAN, 774service level agreements (SLAs), 731–732setting record keep time in control file, 454SHUTDOWN ABORT command, 504strategies, 731–734system change number (SCN), 200, 727tablespace backups, 728terminology, 726testing backups, 730undo records, 201UNIX utilities, 76–77upgrading with DBUA, 432, 433user-managed backups, 201, 790–795ways of performing physical backups, 725whole database backups, 727, 728

BAD FILE parameter, 648BAD parameter, SQL*Loader, 635balanced tree index see B-tree indexes

bandwidthperformance monitoring, UNIX, 81

base recovery catalog, RMAN, 772baselines

AWR baseline templates, 965–971AWR snapshots, 961, 963–964baseline metrics, 953–959CREATE_BASELINE procedure, 963DROP_BASELINE procedure, 964performance statistics, 948SQL plan baselines, 1080–1085

BASH (Bourne Again Shell), 45see also shells, UNIX

.bash_profile file, 55, 410, 413

.bashrc file, 55BASIC value, STATISTICS_LEVEL

parameter, 462batch command, UNIX/Linux, 78batch jobs, 554batch mode, UNIX, 54BATCH option, 339batch script, Windows, 126BATCH_GROUP resource consumer group, 558before-image records, 176, 197, 198, 356BEGIN BACKUP command, 792BEGIN statement, PL/SQL, 1241, 1242BEGINDATA clause, SQL*Loader, 628, 630BEGIN_DISCRETE_TRANSACTION

procedure, 380BEGIN_SNAPSHOT parameter, ADDM, 883benefits, ADDM findings, 880BETWEEN operator, SQL, 1227BFILE data type, 1222BFT (bigfile tablespace), 172, 236–238bin directory, ORACLE_HOME, 395bin directory, UNIX, 48binary compression feature, RMAN, 742BINARY data types, 1222binary dumps, data blocks, 167binary files, 253, 254binary large objects (BLOBs), 40binary operations, relational algebra, 21bind array, SQL*Loader, 634bind peeking technique, parsing, 1087bind variables

converting hard parse to soft parse, 1141cursor sharing using, 1087efficient SQL, 1075identical SQL statements, 1134optimizing library cache, 1138–1139reducing parse time CPU usage, 1157

binding, 343adaptive cursor sharing, 1087, 1088, 1089

bind-sensitive cursors, 1088BINDSIZE parameter, SQL*Loader, 634bitmap indexes, 301, 1071bitmap join indexes (BJI), 1069BITMAP keyword, CREATE INDEX, 301

Page 43: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1263■I N D E X

BITMAP_AREA_SIZE parameter, 194bitmaps, 172, 217BJI (bitmap join index), 1069Blackouts page, Database Control tool, 148BLOB data type, 1222block checking, 470, 471block corruption, 167block dumps, 167block media recovery (BMR), 742, 808, 864–865BLOCK option, RECOVER command, 864block special files, UNIX, 57block-change tracking, RMAN, 779BLOCKED status, Oracle listener, 522blocking locks, 351–352blocking sessions, 354BLOCKRECOVER command, RMAN, 864blocks see data blocksBLOCKSIZE clause, 223BLOCKTERMINATOR variable, SQL, 130, 132Boolean operators, SQL, 1227bouncing the database, 448Bourne Again Shell (BASH), 45Bourne shell, 45Boyce-Codd normal form (BCNF), 33bps column, iostat command, 82branch blocks, B-tree index, 298bread column, sar command, 83BREAK command, SQL*Plus, 122

CLEAR BREAKS command, 115BSP (Oracle Backup Solutions Program), 745BTITLE command, SQL*Plus, 123, 124B-tree indexes, 298, 301

BLEVEL column, 333index organized tables, 278using appropriate index types, 1071

buffer busy wait events, 1175–1177buffer cache, 187, 188–189

aging out blocks, 1145assign table or index to, 1147buffer busy wait events, 1175buffer cache hit ratio, 1144, 1145buffer gets, 1144consistent gets, 1144database writer (DBWn) process, 199DB block gets, 1144description, 456faster instance startup, 805high buffer cache hit ratio, 1161hit ratio, 190how Oracle processes transactions, 197logical reads, 1144multiple database block sizes and, 189–190physical reads, 1144sizing, 1144–1145

increasing buffer cache size, 1145nonstandard-sized, 456, 458optimal buffer cache size, 1145standard-sized, 456

specifying values for subcaches, 190total size of, 190

tuning, 1144–1148using multiple pools for buffer cache,

1146–1148buffer cache pools, 188–189

behavior of, 457keep pool, 189, 457listing, 1145main types, 189recycle pool, 189, 457setting size of default buffer pool, 457using multiple block size feature, 223

buffer gets, 1144buffer_gets column, V$SQL view, 1108buffers

CLEAR BUFFER command, SQL*Plus, 115dirty buffers, 188free buffers, 188least recently used (LRU) algorithm, 188memory buffers, 187, 188pinned buffers, 188redo log buffer, 176, 187, 192–193saving SQL buffer contents to file, 124

BUILD DEFERRED/IMMEDIATE clausesCREATE MATERIALIZED VIEW

statement, 319BUILD procedure, DBMS_LOGMNR_D, 844Burleson Consulting, 14Business Copy XP, 746business rules, 36, 37

application logic or integrity constraints, 306BUSY_TICKS system usage statistic, 1181bwrit column, sar command, 83BYDAY/BYHOUR/BYXYZ keywords, jobs, 999BYPASS procedure, 1123, 1125bytes remaining tablespace alert, 226, 227

■CC shell, 45, 55

see also shells, UNIXcache

buffer cache pools, 188–189cache misses affecting performance, 192Client Query Result Cache, 1125–1126CLIENT_RESULT_CACHE_XYZ

parameters, 458creating cacheable function, 1124creating SQL cache, 321data block sizes and tablespaces, 171data dictionary cache, 191DB_XYZ parameters, 457, 458library cache, 191measuring library cache efficiency,

1137–1138PL/SQL Function Result Cache, 1124–1125result cache, 192, 1120–1126result cache background (RCBG)

process, 186RESULT_CACHE_XYZ parameters, 464SQL Query Result Cache, 1124

cache buffer chain latch free wait, 1180

Page 44: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1264 ■IN D E X

cache recovery, 804, 806Cache Sizes section, AWR reports, 968calculus, relational, 22calendaring expression, Scheduler, 999cancel-based recovery, 824CANCEL_REPLAY procedure, 1215CANCEL_SQL switch group, 561, 555candidate keys, 26CAN_REDEF_TABLE procedure, 937capacity planning, DBA role, 6capture process, Oracle Streams, 671cardinality, ER modeling, 26, 28caret (^) character, SQL, 1238Cartesian product/join, SQL, 21, 1045, 1232CASCADE CONSTRAINTS clause

DROP TABLESPACE statement, 225CASCADE clause

DROP PROFILE statement, 553DROP TABLE statement, 276DROP USER statement, 548, 853GATHER_DATABASE_STATS

procedure, 1055TRANSACTION_BACKOUT procedure,

380, 869case command, UNIX/Linux, 74CASE statement, SQL, 1066, 1230CAST operator, abstract data types, 1241cat command, UNIX/Linux, 52, 56, 58CATALOG command, RMAN, 752, 759, 768, 770CATALOG START WITH command, 760, 770catalog.sql script, 485, 486

data dictionary creation, 204cataloging backups, RMAN, 770catblock.sql script, 353catdwgrd.sql script, 434, 442catproc.sql script, 485, 486catupgrd.sql script, 434, 438, 440catuppst.sql script, 438, 439CBO (Cost-Based Optimizer), 205, 1047–1053

application developer knowledge, 1053automatic optimizer statistics collection, 209Automatic Tuning Optimizer (ATO), 1111Autotrace utility, 1098, 1099cost-based query optimization, 1044–1046cost model of optimizer, 1060dependence on correct statistics

gathering, 1053drawbacks of CBO, 1053heavy data skew in table, 1066how CBO optimizes queries, 1051–1053IN list, 1066inefficiently written queries, 1065materialized views, 314normal mode, 1111Oracle version differences, 1053plan stability feature, 1077providing statistics to CBO, 1053–1056providing statistics to optimizer, 1047–1049query processing optimization phase, 1043

query rewriting, 315rule-based optimization compared, 1047selectivity, 1065setting optimizer level, 1050–1051setting optimizer mode, 1049–1050specifying use of pending statistics, 463stored outlines improving SQL processing,

1077–1080storing optimizer statistics, 1054TKPROF utility output, 1104tuning mode, 1111, 1115understanding logic of, 1090views in query, 1065WHERE clauses, 1065

cd command, UNIX/Linux, 48, 62CDs

installing Oracle software using staging directory, 416

Oracle Enterprise Edition CDs, 414–415using explicit command to load, 414

centralized configuration, Oracle Net Services, 512

centralized user authorization, 602certification, DBA, 10, 11–13chained rows, Flashback Transaction

Query, 374chains, Oracle Scheduler, 995, 996, 1008–1010CHANGE command, SQL*Plus, 129change management, 212–213

DBA role, 7Oracle Change Management Pack, 149, 949Schema page, Database Control, 147

change vectors, redo log files, 176change-based SCN

incomplete recovery using RMAN, 820user-managed incomplete recovery, 824

change-tracking file, RMAN, 779change-tracking writer (CTWR) process, 185channel configuration parameters, RMAN, 764CHANNEL parameter, RMAN, 764channels, RMAN, 753CHAR/character data types, 1222character large objects (CLOBs), 40character sets, 481, 488character special files, UNIX, 57CHECK constraint, 37, 307, 313CHECK LOGICAL clause

VALIDATE command, RMAN, 784CHECK_OBJECT procedure, 797checkpoint (CKPT) process, 175, 181, 183, 479CHECKPOINT clause, 271checkpoint completed wait event, 1177“checkpoint not complete” messages, 1188checkpoints

automatic checkpoint tuning, 183, 932–933Fast Start Checkpointing, 805

CHECK_PRIVILEGE function, 617checksumming, detecting corruption, 470, 796CHECKSYNTAX parameter, RMAN, 749

Page 45: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1265■I N D E X

Chen, Peter, 25chgrp command, UNIX/Linux, 62child nodes, B-tree index, 298child processes, UNIX, 54Childs, D.L., 20chmod command, UNIX/Linux, 60, 61, 70Choosing Database Backup Procedure window,

DBUA, 432chsh command, UNIX/Linux, 46classes, object-oriented database model, 39CLEAR command, SQL*Plus, 115clear_pending_area procedure, 556client authentication, 615client host server, administrative domain, 786client processes, Data Pump, 686Client Query Result Cache, 1125–1126client software

Instant Client software, 519–520Oracle Client software, 517–519

client/server model, database connectivity, 511CLIENT_IDENTIFIER attribute, 1105CLIENT_ID_TRACE_ENABLE package, 1106CLIENT_RESULT_CACHE view, 1126CLIENT_RESULT_CACHE_XYZ parameters,

458, 1126CLOB data type, 1222cloning databases, 833–840

Database Control, 148, 838–839Grid Control, 148Oracle software cloning, 148

closed backups, 728whole closed backups, 790–791

closed recovery, 807CLOSE_WINDOW procedure, 1015CLUSTER clause, CREATE TABLE, 295Cluster Synchronization Service see CSSCluster wait class, 1163clustered tables, 266clusters, 295–296

hash clusters, 296Oracle Real Application Clusters (RACs), 173

CMON (Connection Monitor) process, 532COALESCE function, SQL, 1230COALESCE option, ALTER INDEX, 935COALESCE PARTITION command, 292coalescing indexes online, SQL, 935Codd, E.F., 20, 21, 29cold backups see closed backupscollection types, ORDBMS model, 40collections, abstract data types, 1240COLSEP variable, SQL*Plus, 107COLUMN command, SQL*Plus, 123column groups, 1058, 1059column specifications, data types, 36COLUMNARRAYROWS parameter,

SQL*Loader, 641column-level object privileges, 572column-level security, 312column-level VPD, 585–586

columnsadding to/dropping from tables, 271CLEAR COLUMNS command, 115creating tables, 265DBA_CONS_COLUMNS view, 311DBA_IND_COLUMNS view, 333DBA_TAB_COLUMNS view, 293, 332default values for, 270indexing strategy, 1071listing table columns and specifications, 119ordering of columns in tables, 20partitioning, 281renaming, 272setting as unused, 271showing properties of, 123virtual columns, 270–271

COMMAND column, top command, 84command files, SQL*Plus, 124–129command interpreters, UNIX, 46command line

Data Pump Export utility using, 687command line arguments, UNIX

executing shell scripts with, 70command line parameters, SQL*Loader,

633–636command line utilities

Data Pump components, 680command-line options, SQL*Plus, 113–115commands

listener commands, 522–523operating system file executing RMAN

commands, 749commands, list of see SQL*Plus commands, list ofcommands, SQL*Plus see SQL*Plus commands,

list ofcommands, UNIX see UNIX commandsCOMMENT parameter

creating resource consumer groups, 557comments

adding comments to scripts, SQL*Plus, 132init.ora file, 496SPFILE (server parameter file), 496using comments in SQL*Plus, 128

COMMENTS attribute, CREATE_JOB procedure, 999

commit method, JDBC conn, 540COMMIT statement, 133, 197, 263,

338–339, 1242Commit wait class, 1163COMMIT_LOGGING parameter,

transactions, 339committing transactions, 196, 197–198

fast commit mechanism, 183log writer (LGWR) process, 199redo log buffer, 182

COMMIT_WAIT parameter, transactions, 339common manageability infrastructure, 210–213communication protocol, connect

descriptors, 515

Page 46: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1266 ■IN D E X

compaction phase, segment shrinking, 929Companion CD, Oracle Enterprise Edition, 414COMPARE function, DBMS_COMPARISION

package, 989Compare Periods Report, Database Control,

1206–1208COMPARE_PERFORMANCE parameter, 1219comparison operators, SQL, 1227

WHERE clause, 1224COMPATIBLE parameter, 452

database compatibility level, 429Pre-Upgrade Information Tool, 428setting up Oracle Streams, 673

compensation transactions, 868COMPLETE option, materialized views, 316complete recovery, 807composite indexes, 297, 298, 1072composite keys, 31, 334composite partitioning, 281, 287–290COMPOSITE_LIMIT parameter, 549comprehensive analysis mode, Segment

Advisor, 930COMPRESS clause, ALTER TABLE, 275, 276COMPRESS keyword, 1076compressed backups, RMAN, 780compression

key-compressed indexes, 301table compression, 274–276tablespace compression, 274

COMPRESSION parameterData Pump Export utility, 691populating external tables, 652RMAN, 764

compression techniques, SQL tables, 1076COMPUTE command, SQL*Plus, 123COMPUTE STATISTICS option

ANALYZE command, 1055CREATE INDEX statement, 299

CONCAT function, SQL, 1228CONCATENATE clause, SQL*Loader, 630concatenated indexes, 297, 1072concurrency see data concurrencyConcurrency wait class, 1163conditional branching, UNIX, 71–72conditional control, PL/SQL, 1243conditional functions, SQL, 1230configuration

database management, 146, 148enterprise-wide with Grid Control, 158Oracle Configuration Management Pack,

149, 949RMAN configuration parameters, 761–766Setup page, Database Control tool, 148–149

Configuration Assistants window, 155Configuration Manager

products installed with 11.1 release, 401Configuration Options window, 419

CONFIGURE command, RMAN, 762BACKUP COPIES option, 754configuration parameters, 761–766default device types, 753

CONFIGURE procedure, DBMS_SPM package, 1085

CONFIGURE_POOL procedure, 533CONNECT BY clause, SQL, 1232CONNECT CATALOG command, RMAN, 767CONNECT command, SQL*Plus, 100connect descriptors, Oracle networking, 514connect identifiers, Oracle networking, 515

net service names, 525CONNECT privilege, 616CONNECT role, 430, 574connect strings, Oracle networking, 515

TWO_TASK environment variable, 519CONNECT_IDENTIFIER variable, SQL*Plus,

118, 119, 127connection architecture, 512connection broker, DRCP, 180connection management call elapsed

time, 1206Connection Manager feature, 512Connection Mode tab, DBCA, 488Connection Monitor process (CMON), 532connection naming

directory naming method, 534–537easy connect naming method, 529–530external naming method, 533–534local naming method, 525–529

connection pooling, 180, 531–533connectionless SQL*Plus session with

NOLOG, 101connections

concurrent connection requests, 523connecting to RMAN, 745–746database links, 985–987naming, 525operating system authentication method, 99securing network, 614starting SQL*Plus session from command

line, 98–100CONNECTION_TIME_SCALE parameter, 1214connectivity, 511

see also Oracle networkingdatabase resident connection pooling

(DRCP), 531–533establishing Oracle connectivity, 516–517Instant Client software, 519–520Java Database Connectivity see JDBCnaming, 525net service names, 525Oracle Client software, 517–519Oracle Internet Directory (OID), 535Oracle listener see listenersOracle Net Services, 511–512, 516Oracle networking, 513–516web applications connecting to Oracle, 513

Page 47: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1267■I N D E X

CONNECT_TIME parameter, 549CONNECT_TIME_FAILOVER parameter, 523consistency see data consistencyconsistency property, transactions, 340consistent backups, 727consistent gets, 1144CONSTANT parameter, SQL*Loader, 636constraints

built-in database constraints, 37CASCADE CONSTRAINTS clause, 225CHECK constraint, 307DBA_CONS_COLUMNS view, 311DBA_CONSTRAINTS view, 310deferrable constraints, 310DISABLE VALIDATE command, 309disabling, 308domain constraints, 37dropping tables, 276ENABLE VALIDATE command, 309ENABLED VALIDATED constraints, 316ensuring data integrity, 36immediate constraints, 310integrity constraints, 306–310NOT NULL constraint, 306, 307orderid_refconstraint, 285primary key constraints, 306referential integrity constraints, 225, 308RELY constraints, 310SQL*Loader direct-path loading, 641temporary tables, 277UNIQUE constraint, 307

CONSTRAINTS parameter, export utility, 692consumer groups see resource consumer

groupsCONSUMER_GROUP parameter, 557consumption, Oracle Streams architecture, 671CONTENT parameter

Data Pump Export utility, 692, 704Data Pump Import utility, 708

context-sensitive security policy, 584context switches, 80contexts, 536, 537continuation characters, SQL*Plus, 102, 133CONTINUE_CLIENT parameter, Data Pump,

703, 713CONTINUEIF clause, SQL*Loader, 630CONTINUOUS_MINE procedure, 847control files, 173, 174–175

auto-backups, flash recovery area, 735backing up control file, 784–785backing up with RMAN, 765–766, 776backup and recovery architecture, 201backup guidelines, 729checkpoint (CKPT) process, 175configuration parameters contained, 447creating database, 481creating/locating OMF files, 251, 926database files, 398database integrity, 175

default file locations, 738flash recovery area, 738getting names of all control files, 175managing RMAN, 744multiplexing, 453, 455naming conventions, 398OMF file-naming conventions, 249, 923Oracle Managed Files (OMF), 250, 924

creating/locating OMF files, 252recovering from loss of control files, 824–828RMAN repository data (metadata), 766setting record keep time before

overwriting, 454specifying default location for OMF files, 455SQL*Loader, 628–636system change number, 174V$CONTROLFILE view, 175whole closed backups, 790whole database backups, 791

CONTROL parameter, SQL*Loader, 633control structures, PL/SQL, 1243CONTROLFILE parameter, RMAN, 765, 766

backing up recovery catalog, 770BACKUP command, 785CREATE command, 826, 827RESTORE command, 825

CONTROL_FILE_RECORD_KEEP_TIME parameter, 454, 770

CONTROL_FILES parameter, 453Oracle Managed Files (OMF), 250

controllers, disk I/O, 1159CONTROL_MANAGEMENT_PACK_ACCESS

parameter, 459, 882conventional data loading

direct-path loading compared, 640SQL*Loader, 627, 628, 639

CONVERGE procedure, DBMS_COMPARISION, 990

conversion functions, Oracle data types, 1223CONVERT TABLESPACE command, 721COPY command, Oracle, 757COPY command, RMAN, 758

resynchronizing recovery catalog, 769COPY command, SQL*Plus, 132–133copy command, Windows, 790COPYCOMMIT variable, SQL*Plus, 107COPY_FILE procedure, 253, 991copying files, RMAN, 752–753, 754copying files, UNIX, 59, 79COPY_TABLE_DEPENDENTS procedure, 939coraenv script, 424, 425core directory, ADR, 178correlated subqueries, SQL, 1237corruption

data blocks, 167database corruption detection, 795–798detecting physical/logical corruption,

RMAN, 783

Page 48: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1268 ■IN D E X

enabling detection of, 470monitoring and verifying RMAN jobs, 782repairing datafiles with RMAN, 742

corruption-checking parameters, 470–472Cost-Based Optimizer see CBOcost-based query optimization, 1044–1046COUNT function, SQL, 1229cp command, UNIX/Linux, 59

physical database backups, 725, 790cpio command, UNIX/Linux, 76, 77CPU column, top command, 84CPU method

creating plan directives, 560, 561Database Resource Manager, 555

CPU performance, 1153–1158CPU usage

causes of intensive CPU usage, 1153cost model of Oracle optimizer, 1060CPU units used by processes, 1154determining session-level CPU usage, 1155eliminating wait event contention, 1208enforcing per-session CPU limits, 564–565finding inefficient SQL, 1109, 1110identifying high CPU users, 1154parse time CPU usage, 1156–1157performance monitoring, UNIX, 80production database problems, 554recursive CPU usage, 1157reducing parse time CPU usage, 1157run queue length, 1153sar command output showing, 1153SQL Trace tool showing, 1100system performance, 1203system usage problems, 1188tuning shared pool, 1133uses of CPU time, 1155–1158V$SESSTAT view, 1203

CPU_MTH parameter, 557, 560CPU_PER_CALL parameter, 549CPU_PER_SESSION parameter, 549CPUSPEED statistic, 1061CPUSPEEDNW statistic, 1061cpu_time column, V$SQL view, 1108crash recovery, Oracle, 804–805CREATE ANY DIRECTORY privilege, 683CREATE ANY TABLE privilege, 268CREATE BIGFILE statement, 237CREATE CATALOG command, RMAN, 768CREATE CLUSTER statement, 295, 296CREATE CONTROLFILE statement, 826, 827CREATE DATABASE statement, 480–481

DEFAULT TABLESPACE clause, 236SYSAUX clause, 239

create directory, 397CREATE DISKGROUP command, 915CREATE FLASHBACK ARCHIVE statement, 871CREATE GLOBAL SCRIPT command,

RMAN, 750

CREATE INDEX statement, 299–300BITMAP keyword, 301B-tree index, 298COMPUTE STATISTICS option, 299GLOBAL PARTITION BY option, 302INVISIBLE clause, 304PARTITION BY HASH option, 303PRIMARY KEY constraint, 300

CREATE JOB privilege, Scheduler, 997CREATE MATERIALIZED VIEW statement,

318–319CREATE option

SPOOL command, SQL*Plus, 120STORE command, SQL*Plus, 116

CREATE OR REPLACE VIEW statement, 313CREATE OUTLINE statement, 1079CREATE PROCEDURE statement

AUTHID clause, 573CREATE PROFILE statement, 548Create Role Administrators page, Database

Control, 150Create Role Properties page, Database

Control, 150CREATE ROLE statement, 575, 576CREATE SCHEMA statement, 264, 265CREATE SCRIPT statement, RMAN, 748, 750CREATE SESSION privilege, 568, 569

creating users, 545CREATE SYNONYM statement, 324, 326CREATE TABLE privilege, 268CREATE TABLE statement, 269

CLUSTER clause, 295CREATE TABLE AS SELECT (CTAS)

command, 273creating external table layer, 647ENABLE ROW MOVEMENT clause, 286ENCRYPT clause, 269FOREIGN KEY REFERENCES clause, 285INCLUDING clause, 279, 280INTERVAL clause, 283LOGGING clause, 227ORGANIZATION INDEX phrase, 279PARTITION BY HASH clause, 283PARTITION BY LIST clause, 284PARTITION BY RANGE clause, 282PARTITION BY REFERENCE clause, 285PARTITIONED BY SYSTEM clause, 287PCTTHRESHOLD clause, 279, 280PRIMARY KEY constraint, 300, 306STORE IN clause, 283SUBPARTITION BY HASH clause, 288SUBPARTITION BY LIST clause, 288SUBPARTITION BY RANGE clause, 289, 290UNIQUE constraint, 300VALUES LESS THAN clause, 281

CREATE TABLESPACE statement, 218AUTOEXTEND ON clause, 230creating permanent tablespaces, 219creating temporary tablespaces, 230–231

Page 49: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1269■I N D E X

ENCRYPTION clause, 242, 610EXTENT MANAGEMENT clause, 230EXTENT MANAGEMENT LOCAL clause, 220NOLOGGING clause, 227SIZE clause, 230TABLESPACE GROUP clause, 233TEMPORARY clause, 230UNDO keyword, 358UNIFORM SIZE clause, 230

CREATE TRIGGER statement, 328CREATE TYPE statement, 1239CREATE UNDO TABLESPACE statement, 218

AUTOEXTEND keyword, 358RETENTION GUARANTEE clause, 460

CREATE UNIQUE INDEX statement, 299CREATE USER statement, 544–547

DEFAULT TABLESPACE clause, 547IDENTIFIED BY clause, 544QUOTA clause, 546RMAN clause, 767

CREATE VIEW statement/privilege, 312CREATE VIRTUAL CATALOG command,

RMAN, 773CREATE_ACL procedure, 616CREATE_ANALYSIS_TASK procedure, 1218CREATE_BASELINE procedure, 963CREATE_BASELINE_TEMPLATE

procedure, 965CREATE_CHAIN procedure, 1009CREATE_COMPARISON procedure, 988create_consumer_group procedure, 557CREATE_CREDENTIAL procedure, 1005CREATE_DIAGNSOTIC_TASK procedure, 1036CREATE_EXTENDED_STATS function,

1059, 1060CREATE_INDEX_COST procedure, 298, 299CREATE_JOB procedure, 998

attributes, 999events, 1011external jobs, 1005lightweight jobs, 1001, 1002programs, 1007

CREATE_JOB_CLASS procedure, 1012create_pending_area procedure, 556CREATE_PLAN procedure, 560CREATE_PLAN_DIRECTIVE procedure,

561, 565CREATE_POLICY_GROUP procedure, 584CREATE_PROGRAM procedure, 1006CREATE_REPORT procedure, 885CREATE_SCHEDULE procedure, 1007, 1008CREATE_SNAPSHOT procedure, 961CREATE_SQLSET procedure, 1217CREATE_SQLWKLD procedure, 323createStatement method, JDBC conn, 539CREATE_STGTAB_SQLSET procedure, 1218CREATE_STORED_OUTLINES parameter,

1078, 1079

CREATE_TABLE_COST procedure, 268CREATE_TASK procedure, 323, 890, 978CREATE_TUNING_TASK procedure, 1113CREATE_WINDOW procedure, 1014, 1015Creation Options window, DBCA, 488CREDENTIAL_NAME attribute,

Scheduler, 1005Credentials window, Database Upgrade

Assistant, 432critical alert thresholds, 226, 952, 954, 956Critical Patch Updates, 617critical_value attribute, 227crontab command, 77–78CROSSCHECK command, RMAN, 758, 761, 783CRSCTL utility, 903csh (C shell), 45, 55

see also shells, UNIX.cshrc file, UNIX, 55CSS (Cluster Synchronization Service), 902–904CTAS (CREATE TABLE AS SELECT)

command, 273deriving data from existing tables, 657LONG columns, 133managing logging of redo data, 227using with large tables, 132writing to external tables, 651

CUBE operator, SQL, 1235cumulative backup, RMAN, 756, 757cumulative statistics, 948current incarnation, database recovery, 823current_user attribute, 580currval pseudo-column, sequences, 327cursors

bind-sensitive cursors, 1088cursor sharing, 466, 1087–1090description, 343maximum number of cursors in session, 194open cursors, 194, 456, 1141preventing early deallocation of

cursors, 1141cursors, PL/SQL, 1245–1247CURSOR_SHARING parameter, 466, 1087, 1138,

1139, 1141, 1209CURSOR_SPACE_FOR_TIME parameter,

1140, 1141Custom installation, Oracle software, 417custom option, installing Oracle Client, 518custom.rsp response file template, 422cut command, UNIX/Linux, 66

■Ddata

database triggers ensuring validity of, 37modifying data on disk, 181separating table and index data, 170

data access see database accessdata anomalies, 29

denormalization, 34

Page 50: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1270 ■IN D E X

data blocks, 166–169allocating to objects, 172bigfile tablespace (BFT), 236binary dumps, 167block corruption, 167block dumps, 167buffer busy wait events, 1176changing block size, 467checking for corrupted data blocks, 471creating tablespaces with nonstandard block

sizes, 223DB_BLOCK_SIZE parameter, 466detecting data block corruption, 795–798determining size of, 166–167dumping contents, 167, 168extents, 166, 169free space section, 167identifying file and block IDs, 168inner workings, 167–169keeping track of space in blocks, 172multiple data block sizes, 167multiple sizes and buffer cache, 189–190online database block-size changes, 943–944operating system disk block size, 166querying data, 466repairing corrupted data blocks, 864row data section, 167segment space management, 217–218setting block size, 466size units, 166specifying maximum number read during

full table scan, 467tablespaces and block sizes, 171–172using multiple block size feature, 223

data buffer cache see buffer cachedata center disasters, 802data concurrency, 198–200, 341–342

allowing DDL locks to wait for DML locks, 350

data consistency and, 346dirty reads problem, 341explicit locking in Oracle, 351–352explicit table locking, 350–351implementing concurrency control, 347–355isolation levels, 342–346isolation property, 340locking, 341, 347, 348–350locks affecting, 386lost-update problem, 341managing Oracle locks, 353–355multiversion concurrency control

system, 347nonrepeatable (fuzzy) read problem, 342phantom reads problem, 341serializable schedules, 342time-stamping methods, 347validation methods, 347

data consistency, 198–200read consistency, 199redo log files, 176

system monitor (SMON) process, 184transactions, 196, 340, 341, 342, 346transaction-set consistent data, 199undo management, 200undo segments, 199Workspace Manager, 386

data corruption, 864–866data decryption, 604data dictionary, 191, 203, 204

extracting, LogMiner utility, 843monitoring database status, 507protecting, database security, 613

data dictionary cache, 191, 1134–1135data dictionary locks, 351data dictionary objects, 485data dictionary tables, 203, 204data dictionary views, 204

see also DBA views; V$ viewsADDM related, 893AWR snapshots, 959INDEX_STATS view, 334listing, 203managing advisory framework, 980managing AWR statistics with, 971managing Database Resource Manager, 566managing tables, 292–295managing tablespaces, 243–246managing undo space information, 365managing users/roles/privileges, 577metrics and alerts, 958–959using dictionary views for SQL tuning,

1108, 1110viewing object information, 329

data encryption, 603–608ENCRYPT keyword, 604encrypting table columns, 607–608encryption algorithms, 608generating master encryption key, 607Oracle Wallet, 604, 605–606

data extraction see ETL (extraction, transformation, loading)

Data Guard see Oracle Data Guarddata integrity, 36, 37data loading see ETL (extraction,

transformation, loading)data manipulation statements, 313, 314Data Migration Assistant, 427data modeling, 25, 27, 38Data Movement page, Database Control, 148DATA pages, Oracle process component, 1190DATA parameter, SQL*Loader, 634data protection, 798–800

Oracle Streams, 672Data Pump utilities (Export, Import), 677

accessing Data Pump utilities, 678API creating export/import jobs, 715attaching to running Data Pump job,

679, 688benefits of Data Pump technology, 678–679compatibility, 677

Page 51: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1271■I N D E X

components, 680correcting human error, 802Data Pump technology, 677–686data-access methods, 680–681DBMS_DATAPUMP package, 680DBMS_METADATA package, 680description, 808directory objects, 681–684estimating space requirements, 679Export parameters, 689–704

ADD_FILE, 702, 703, 704ATTACH, 700, 701, 702, 703COMPRESSION, 691CONTENT, 692, 704CONTINUE_CLIENT, 703DATA_OPTIONS, 694DIRECTORY, 690DUMPFILE, 690, 705encryption parameters, 694–696, 698estimate parameters, 696–697EXCLUDE, 692–693, 704EXIT_CLIENT, 703, 704export filtering parameters, 692–694export mode parameters, 691file and directory parameters, 690–691FILESIZE, 690, 705FLASHBACK_SCN, 699FLASHBACK_TIME, 700FULL, 688HELP, 703, 704INCLUDE, 692–693interactive mode parameters, 701–704job parameters, 699–701JOB_NAME, 699, 705KILL_JOB, 703, 704LOGFILE, 690NETWORK_LINK, 698, 717NOLOGFILE, 691PARALLEL, 700–705PARFILE, 690QUERY, 694, 704REMAP_DATA, 693REUSE_DUMPFILE, 691SAMPLE, 694SCHEMAS, 688, 705START_JOB, 703, 704STATUS, 699, 703, 704STOP_JOB, 702, 703, 704TABLES, 688TABLESPACES, 688TRANSPORTABLE, 694TRANSPORT_FULL_CHECK, 691, 717, 721TRANSPORT_TABLESPACES, 688, 718USERID, 718

Export utility, 207backup guidelines, 730creating export dump file, 704dpdump directory containing files, 397export prompt, interactive mode, 688exporting metadata using, 721

exporting tables from schema, 705generating transportable tablespace

set, 717initiating network export, 698interactive commands, 703logical backups, 728methods, 687–688modes, 688–689read-only database, 698schema mode, 688, 705using parameter file, 704

files, 681–685fine-grained data import capability, 679Import parameters, 705–713

CONTENT, 708CONTINUE_CLIENT, 713DATA_OPTIONS, 710DIRECTORY, 706DUMPFILE, 706EXCLUDE, 708EXIT_CLIENT, 713file and directory parameters, 706–707filtering parameters, 708FLASHBACK_XYZ parameters, 713FULL, 708HELP, 713import mode parameters, 708–709INCLUDE, 708interactive import parameters, 713job parameters, 708JOB_NAME, 708KILL_JOB, 713LOGFILE, 706NETWORK_LINK, 711–713NOLOGFILE, 706PARALLEL, 708, 713PARFILE, 706QUERY, 708remapping parameters, 709–711REUSE_DATAFILES, 707SCHEMAS, 708SQLFILE, 706–707START_JOB, 713STATUS, 708, 713STOP_JOB, 713TABLE_EXISTS_ACTION, 708TABLES, 708TABLESPACES, 708TRANSFORM, 710–711TRANSPORTABLE, 710TRANSPORT_XYZ parameters, 705, 708

Import utility, 207disabling constraints, 308import modes, 705import prompt, interactive mode, 688import types, 705importing metadata using, 723performing transportable tablespace

import, 719–720SQLFILE parameter, 681

Page 52: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1272 ■IN D E X

managing/monitoring database, 213manual upgrade process, 427mechanics of Data Pump job, 685–686metadata filtering, 692monitoring Data Pump jobs, 713–714network mode of operation, 679nonprivileged users using, 683order of precedence for file locations, 684–685parallel execution, 678performance, 678performing exports and imports, 686–713privileges, 685processes, 685–686remapping capabilities, 679restarting jobs, 678roles, 574tasks performed by Data Pump

technology, 677transportable tablespaces, 171, 716–723uses for, 679–680using Data Pump API, 715

Data Recovery Advisor, 211, 829–833, 1023ADVISE FAILURE command, 831data block corruption, 167data repair, 803failure properties, 830LIST FAILURE command, 830REPAIR commands, 832, 833

data redefinition online, 935–941data reorganization online, 933–935

Database Control, 933SQL commands performing, 934–935

Data Reorganization page, Database Control, 934

data replication, Oracle Streams, 670data storage technologies, 93–95

RAID systems for disks, 88–93data transfer element (dte), 789data transformation see transforming datadata types

abstract data types, 1239–1241column specifications, 36Oracle data types, 1222–1223ORDBMS model, 40SQL*Loader control file, 632user-defined object types, 264XMLType, 1249

data warehousingAutomatic Workload Repository (AWR), 210bitmap join indexes (BJI), 1069building, 27DB_BLOCK_SIZE parameter, 466detail tables, 314external tables, 280, 646indexing strategy, 1071loading, Oracle Streams, 670program global area (PGA), 187table compression, 1076transportable tablespaces, 716using indexes, 296

database access, 567–586see also authorizationapplication contexts, 580, 581auditing database usage, 586–596authenticating users, 596–602DBA views managing users/roles/

privileges, 577definer’s rights, 573denying users access to database, 548fine-grained data access, 578–586

application contexts, 579–581column-level VPD, 585–586fine-grained access control, 582–585

invoker’s rights, 573privileges, 567–574

object privileges, 570–573system privileges, 567–570

restricting database access, 501–502roles, 574–577SQL Access Advisor, 212views and stored procedures, 577

database administration commands, SQL*Plus, 134–135

database admistrator see DBAdatabase alerts see alertsdatabase architecture, 165–178database auditing, 612database authentication see authenticationdatabase availability, 171database backups, 201database buffers

see also buffer cachecommitting transactions, 198least recently used (LRU) algorithm, 181modifying data via Oracle memory, 181

database concurrency see data concurrencyDatabase Configuration Assistant see DBCAdatabase connections

OID making, 535–536setting upper limit for OS processes, 455

database connectivity see connectivitydatabase consistency see data consistencyDatabase Content page, DBCA, 487Database Control, 137, 139, 140–153

accessing, 143–144accessing MTTR Advisor, 981Alerts table, 953automatic optimizer statistics collection, 899cloning databases, 838–839cloning Oracle home, 148Compare Periods Report, 1206–1208configuring and using, 140–143configuring automatic SQL tuning

parameters, 1119configuring automatically, 140configuring Flashback Database, 855, 856configuring manually, 141–143creating database links, 987creating roles, 150Data Grid, OEM alternative, 206

Page 53: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1273■I N D E X

Data Pump Export and Import operations, 688

database management, 146database usage metrics, 151–153DBMS_ADVISOR package and, 320default port, 140default URL, 140emca utility, 141end-to-end tracing, 1107estimating table size before creating, 266examining database feature-usage

statistics, 152examining database performance,

1195–1201, 1206–1208examining SQL response time with, 1183GATHER_STATS_JOB, 899introductory tour, 144investigating waits, 145invoking SQL Access Advisor, 320–323linking to MetaLink, 150logging in, 144login screen, 142managing advisory framework, 979managing alerts, 954–955managing ASM instances, 907managing ASM operations, 900managing AWR snapshots, 961–963managing database, 213managing session locks, 354–355managing users, 567migrating databases to ASM, 920–921online database reorganization with, 933policy-based configuration framework, 151running ADDM using, 893setting alert thresholds, 954setting notification rules, 955starting, 490SYSMAN (super administrator account), 148tracing individual user sessions, 1105upgrading with DBUA, 432versions, 137viewing ADDM reports, 890–891

Database Control Memory Advisor see Memory Advisor

Database Control pagesAdministrators page, 148Advisor Central page, 150, 979All Metrics page, 950AWR page, 962Availability page, 146Blackouts page, 148Data Movement page, 148Data Reorganization page, 934Database Performance page, 1197–1200Dictionary Comparisons page, 147Edit Thresholds page, 954, 955Hang Analysis page, 1192–1194home page, 145, 1195–1197

Manage Policy Library page, 151Management Pack Access page, 149Notification Methods page, 148Patching Setup page, 148Performance Data Report page, 1201–1202Performance page, 145–146performing RMAN backup and recovery

tasks, 813physical database backups, 725, 726Policy Violations page, 151Related Links section, 150Schema page, 147Segment Advisor page, 931Segment Advisor Recommendations

page, 980Server page, 146–147Setup page, 148–149Software and Support page, 148

database corruption detection, 795–798database creation, 474–493

authorizations, 446creating file system, 444–445creating parameter files, 446–474Database Configuration Assistant (DBCA),

486–493default memory management option, 196ensuring sufficient memory allocation, 445installing Oracle software, 444introduction, 443locating files, 445manual database creation, 474–486Oracle Managed Files (OMF), 250–253,

924–927server parameter file (SPFILE), 493–497setting OS environment variables, 446sizing file system, 444–445

Database Credentials window, 432, 487database design

attribute dependence on primary key, 31, 33business rules and data integrity, 36DBA role, 3, 7–8designing different types of tables, 35entity-relationship (ER) modeling, 24–26ER modeling tools, 34functional dependencies, 33importance of, 20logical database design, 24–34lossless-join dependency, 34multivalued dependencies, 34normal forms, 29–34normalization, 28–29performance, 36performance tuning, 1042physical database design, 34–37repeating groups, 30requirements gathering, 23–24transforming ER diagrams into relational

tables, 35

Page 54: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1274 ■IN D E X

database directories, creating, 410database failures, 801

data center disasters, 802data repair, 803–804hardware-related recovery, 802human error, 802, 803media failures, 802, 803Oracle recovery process, 804–809recovery with RMAN, 809–814system failures, 802Transparent Application Failover

feature, 802Database File Locations window, 155, 487database files, 398–400

making transactions permanent, 181database hangs, 1186–1194

abnormal increase in process size, 1190–1191

archiver process stuck, 1187–1188bad statistics, 1191collecting information during database

hang, 1191gathering error messages, 1193getting systemstate dump, 1193locking issues, 1189severe contention for resources, 1188shared pool problems, 1191system usage problems, 1188using Database Control’s Hang Analysis

page, 1192–1194using hanganalyze utility, 1193

database hit ratios, 1161–1162Database Identification window, 155, 487database incarnations, recovery through, 822database installation see installing Oracle

Database 11gdatabase instance names, 514database instances see instancesdatabase integrity see integritydatabase jobs, Oracle Scheduler, 995database links, 985–987

DBA_DB_LINKS view, 329Related Links, Database Control, 150

database load affecting performance, 1205database maintenance, quiescing

databases, 505database management

see also OEM (Oracle Enterprise Manager)automatic database management, 208–209database management tools, 137

database metrics see metricsdatabase mode, ADDM, 882database models, 38–41

nonrelational database models, 20database mounted statement, 484database names, global, 514database objects, 987–991

comparing data, 987–989configuring, Oracle Secure Backup, 789

converging data, 990–991initial extent, 169segments, 169storage allocation to, 222

database operations see also Oracle processesDatabase page, Grid Control, 153database parameter files see parameter filesdatabase passwords

DBCA changing passwords for default users, 490–491

Database Performance page, Database Control, 1197–1200

database quiescing, 505, 944–945database recovery see recoveryDatabase Replay, 213, 1209–1216

change management, 7database management, 148

database resident connection pooling (DRCP), 180, 531–533

Database Resource Manager, 208, 554–567, 941–943

activating, 565allocating scarce resources with

Scheduler, 996data dictionary views managing, 566deactivating, 566limiting transactions with operation

queuing, 942limiting execution times for transactions,

942–943managing, 555managing resources, 554managing undo space information, 365OEM administering, 566–567pending area, 556, 562plan directives, 942privileges for, 555resource allocation methods, 555resource consumer groups, 554, 555, 556,

557–559assigning users to, 562–565automatic assignment to session, 564enforcing per-session CPU and I/O limits,

564–565managing job classes, 1011

resource plan directives, 555, 556, 560–562resource plans, 554, 555, 556, 559–560steps when starting to use, 556switching long-running transactions, 942

database schemas, 20database security see securitydatabase server

copying files with, 991–992database service names

connect descriptors, 515Oracle networking, 514

database sessions, terminating, 75database shutdown command, 492database sizing, 37database startup triggers, 591

Page 55: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1275■I N D E X

database storagecreating database directories,

preinstallation, 410implementing physical database design, 37

Database Storage window, 488database structures see Oracle database

structuresDatabase Templates window, 487database transaction management, 337database transactions see transactionsdatabase triggers see triggersdatabase types, 9–10Database Upgrade Assistant see DBUAdatabase usage metrics, Database Control,

151–153Database Usage Statistics property sheet,

152, 153Database Vault, 401, 430database wait statistics see wait statisticsdatabase writer (DBWn), 180, 181–182, 183

how Oracle processes transactions, 197starting Oracle instance, 479write ahead protocol and, 199

DATABASE_PROPERTIES view, 544bigfile tablespace information, 238monitoring current status of instance, 507

databasessee also Oracle database; relational databasesaudit parameters, 450auditing database usage, 586–596backing up Oracle databases see backupsbouncing, 448changing into read-only mode, 502changing to restricted mode, 501cloning, 833–840communicating with database, 205–207copying files between, 253–255creating stored outlines for, 1079dropping, 506migrating to ASM, 919–921monitoring database status, 507mounting database, 482Oracle XML DB, 1248–1252preserving database performance, 1080quiescing, 505recovering Oracle databases see recoveryrestoring pre-upgrade database, 433reverse engineering, 38shutting down database from SQL*Plus,

502–505starting database from SQL*Plus, 497–499suspending databases, 505, 945variable naming database connected to, 127

database-sizing spreadsheets, 392DATA_CACHE parameter, SQL*Loader, 641datafile backups, 728

DATAFILE clausecreating Sysaux tablespace, 239creating tablespaces, 219Oracle Managed Files (OMF), 247, 253

datafiles, 173–174, 394accidentally dropping datafiles, 248adding within OMF file system, 253allocating data blocks to objects, 172backing up with RMAN, 777converting to match endian format, 721database files, 398DBA_DATA_FILES view, 245dropping, 806dumping data block, 167expanding tablespaces, 223extent allocation/deallocation, 220flash recovery area, 735Flashback Database restoring, 853free and used space in, 172increasing size of, 174making plain copy of, 757making whole closed backups, 790mount points, 394, 404names and locations of, 174naming conventions, 398OFA guidelines, 396Oracle Managed Files (OMF), 247, 249, 250,

923, 924recovering datafiles, 818–820recovering datafiles without backup,

828–829repairing corrupt datafiles, 742RESIZE clause, 219restoring vs. recovering, 806REUSE_DATAFILES parameter, 707separation from logical objects, 174setting location for, 239sizing for database creation, 444specifying default location for, 455SQL*Loader utility, 628tablespaces, 166, 219–220tablespaces and, 170, 173V$DATAFILE view, 246

data-flow diagrams (DFDs), 23DATA_OPTIONS parameter, Data Pump,

694, 710DATA_PUMP_DIR objects, 682, 684, 685datasets, Oracle Secure Backup, 789date and time data types, 1223date command, UNIX/Linux, 48DATE data type, 1223date functions, SQL, 1229DATE variable, SQL*Plus, 119, 127dates, 449, 453DB block gets, 1144db file scattered read wait event, 1166, 1167,

1168, 1177, 1204db file sequential read wait event, 1165, 1166,

1167, 1168, 1178, 1204

Page 56: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1276 ■IN D E X

db file single write wait event, 1204DB time metric, 878, 1206DBA (database admistrator)

asking experts (non-DBA), 16avoid making problems worse, 17certification, 11–13changing user’s password, 547connecting to Oracle database, 99daily routine, 15–16database design role, 7–8database security with multiple DBAs, 613development DBA, 8different organizational roles, 8general advice, 16–17hands-on learning, 10help, knowing when to ask for, 16improving SQL processing, 1075–1080job classifications, 8managing users, 544performance tuning tasks, 1086–1087production database problems, 554production DBA, 8resources, 13–14responsibility of DBA, 3–8security role, 4system administration and Oracle DBA,

12–13system management role, 5–7terminating database sessions, 75thinking outside the box, 17training, 10, 11, 12, 13, 14, 15UNIX/Linux for DBA, 43–95

dba (default name) see OSDBA groupDBA role, 574DBA views, 204

DBA_ADVISOR_ACTIONS, 894, 980DBA_ADVISOR_DEF_PARAMETERS, 884DBA_ADVISOR_EXECUTIONS, 1120, 1220DBA_ADVISOR_FINDINGS, 893, 980, 1220DBA_ADVISOR_PARAMETERS, 980DBA_ADVISOR_RATIONALE, 894, 980DBA_ADVISOR_RECOMMENDATIONS,

893, 978, 980DBA_ADVISOR_SQLXYZ views, 1120, 1220DBA_ADVISOR_TASKS, 980, 1220DBA_ALERT_HISTORY, 958DBA_ALL_TABLES, 330DBA_AUDIT_TRAIL, 588, 596DBA_AUTO_SEGADV_CTL, 980DBA_AUTOTASK_XYZ views, 1020, 1022DBA_BLOCKERS, 351, 354DBA_COL_PRIVS, 577DBA_COMMON_AUDIT_TRAIL, 594, 596DBA_COMPARISION_XYZ views, 989DBA_CONS_COLUMNS, 311DBA_CONSTRAINTS, 310DBA_DATA_FILES, 245DBA_DATAPUMP_XYZ views, 713, 714DBA_DB_LINKS, 329

DBA_ENABLED_TRACES, 1107DBA_EXTENTS, 255DBA_EXTERNAL_TABLES, 330DBA_FGA_AUDIT_TRAIL, 594, 596DBA_FLASHBACK_ARCHIVE, 872DBA_FLASHBACK_TRANSACTION_XYZ

views, 870DBA_FREE_SPACE, 243, 850DBA_HIST_ACTIVE_SESS_HISTORY, 971,

972, 1169, 1186DBA_HIST_BASELINE, 971DBA_HIST_SNAPSHOT, 963, 971DBA_HIST_SYSMETRIC_HISTORY, 958DBA_HIST_WR_CONTROL, 971DBA_HIST_XYZ views, 952DBA_IND_COLUMNS, 333DBA_INDEXES, 333DBA_MVIEWS, 333DBA_OBJECTS, 329, 1146, 1147DBA_OUTSTANDING_ALERTS, 740,

957, 958DBA_PART_TABLES, 331DBA_PROFILES, 258DBA_RECYCLEBIN, 850DBA_REDEFINITION_ERRORS, 940DBA_REGISTRY, 427DBA_RESUMABLE, 386DBA_ROLE_PRIVS, 577DBA_ROLES, 577DBA_ROLLBACK_SEGS, 361, 365DBA_RSRC_CONSUMER_GROUP_

PRIVS, 566DBA_RSRC_CONSUMER_GROUPS, 557, 559DBA_RSRC_PLANS, 566DBA_SCHEDULER_JOB_XYZ views, 1018DBA_SCHEDULER_JOBS, 931, 997, 1001,

1018, 1047DBA_SCHEDULER_XYZ views, 1018DBA_SEGMENTS, 244, 255DBA_SEQUENCES, 329DBA_SERVER_REGISTRY, 427, 429, 440DBA_SQL_MANAGEMENT_CONFIG, 1085DBA_SQL_PATCHES, 1038DBA_SQL_PLAN_BASELINES, 1083DBA_SQL_PROFILES, 1117DBA_STAT_EXTENSIONS, 1060DBA_SYNONYMS, 326, 329DBA_SYS_PRIVS, 577DBA_TAB_COL_STATISTICS, 1049, 1087DBA_TAB_COLUMNS, 293, 332DBA_TABLES, 292, 330DBA_TABLESPACE_GROUPS, 235, 246DBA_TABLESPACES, 238, 243, 365, 610DBA_TAB_MODIFICATIONS, 331, 1047DBA_TAB_PARTITIONS, 292, 330DBA_TAB_PRIVS, 577DBA_TAB_STATISTICS table, 1049DBA_TEMP_FILES, 230, 246DBA_THRESHOLDS, 956, 958, 959

Page 57: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1277■I N D E X

DBA_TRIGGERS, 329DBA_TS_QUOTAS, 546DBA_UNDO_EXTENTS, 365DBA_USERS, 235, 258, 577, 619DBA_VIEWS, 332DBA_WORKLOAD_CAPTURES, 1211DBA_WORKLOAD_XYZ views, 1216

DBAsupport.com, 14DB_BLOCK_CHECKING parameter, 470,

471, 796DB_BLOCK_CHECKSUM parameter, 470, 796,

853, 984DB_BLOCK_SIZE parameter, 166, 167, 189,

223, 466DBCA (Database Configuration Assistant),

486–493creating Sysaux tablespace, 239enabling automatic memory management,

895–896managing/monitoring database, 213memory management configuration

options, 196uninstalling Oracle, 425

DBCA Operations window, 487dbca.rsp response file template, 422DB_CACHE_SIZE parameter, 189, 195, 457

creating tablespaces with nonstandard block size, 223

Oracle’s guidelines, 456dbconsole process, 141, 143DB_CPOOL_INFO view, 533DB_CREATE_FILE_DEST parameter, 455, 919

OMF, 247, 249, 250, 251, 252, 253, 738, 739, 923, 925, 926, 927

DB_CREATE_ONLINE_LOG_DEST parameter, 926

DB_CREATE_ONLINE_LOG_DEST_n parameter, 455, 738, 739

OMF, 247, 249, 250, 251, 252, 923, 924, 926DB_DOMAIN parameter, 452DB_FILE_MULTIBLOCK_READ_COUNT

parameter, 467, 1052, 1158, 1177DB_FILE_NAME_CONVERT parameter, 721,

722, 834, 836DB_FLASHBACK_RETENTION_TARGET

parameter, 469, 855, 858DB_ID parameter, ADDM, 883DBIO_EXPECTED parameter, ADDM, 884DB_KEEP_CACHE_SIZE parameter, 189,

195, 457DB_LOST_WRITE_PROTECT parameter, 470DBMS_ADDM package, 883, 884DBMS_ADVISOR package, 320, 323–324

CREATE_REPORT procedure, 885CREATE_TASK procedure, 890, 978DELETE_TASK procedure, 890EXECUTE_TASK procedure, 890, 978GET_TASK_REPORT procedure, 890, 978invoking SQL Access Advisor, 323

managing advisory framework, 977–979QUICK_TUNE procedure, 320, 324SET_DEFAULT_TASK procedure, 890SET_DEFAULT_TASK_PARAMETER

procedure, 884, 890SET_TASK_PARAMETER procedure, 978viewing ADDM reports, 890

DBMS_APPLICATION package, 943DBMS_APPLICATION_INFO package, 1106DBMS_AQ package, 956DBMS_AQADM package, 956, 1011DBMS_AUTO_TASK_ADMIN package, 1020,

1021, 1118–1119DBMS_COMPARISION package, 987, 988,

989, 990DBMS_CONNECTION_POOL package, 532, 533DBMS_CRYPTO package, 240, 603, 608DBMS_DATAPUMP package, 680, 715DBMS_FGA package, 594, 595DBMS_FILE_TRANSFER package, 253–255, 947,

991–992DBMS_FLASHBACK package, 368–369

TRANSACTION_BACKOUT procedure, 379, 868, 869

DBMS_HM package, 1033DBMS_JOB package, 994, 996DBMS_JOBS package, 208DBMS_LOGMNR package, 842, 844, 845,

846, 847DBMS_LOGMNR_D package, 842, 844DBMS_METADATA package, 294, 295, 680DBMS_MONITOR package, 1102,

1106–1107, 1175DBMS_MVIEW package, 316, 317DBMS_NETWORK_ACL_ADMIN package, 615,

616, 617DBMS_NETWORK_ACL_UTILITY package, 615DBMS_NETWORK_ADMIN package, 616DBMS_OBFUSCATION_TOOLKIT package,

240, 603, 608DBMS_OLAP package, 1077DBMS_OUTLN package, 1078DBMS_OUTLN_EDIT package, 1078, 1080DBMS_OUTPUT package, 109DBMS_PIPE package, 745DBMS_REDEFINITION package, 275, 937, 938,

939, 940, 941DBMS_REPAIR package, 797, 864DBMS_RESOURCE_MANAGER package,

555, 560assigning users to consumer groups, 563CLEAR_PENDING_AREA procedure, 556CREATE_CONSUMER_GROUP

procedure, 557CREATE_PENDING_AREA procedure, 556CREATE_PLAN procedure, 560CREATE_PLAN_DIRECTIVE procedure,

561, 565determining profile parameter limits, 553

Page 58: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1278 ■IN D E X

SET_CONSUMER_GROUP_MAPPING procedure, 564

SET_CONSUMER_MAPPING_PRI procedure, 564

SET_INITIAL_CONSUMER_GROUP procedure, 563

SUBMIT_PENDING_AREA procedure, 562VALIDATE_PENDING_AREA procedure, 562

DBMS_RESULT_CACHE package, 1123, 1124, 1125

DBMS_RESUMABLE package, 385, 386DBMS_RLS package, 584DBMS_RULE_ADM package, 1009DBMS_SCHEDULER package, 994

administering Scheduler jobs, 1000ALTER_ATTRIBUTES procedure, 1013CLOSE_WINDOW procedure, 1015CREATE_CHAIN procedure, 1009CREATE_CREDENTIAL procedure, 1005CREATE_JOB procedure, 998, 999, 1001,

1002, 1005, 1007, 1011CREATE_JOB_CLASS procedure, 1012CREATE_PROGRAM procedure, 1006CREATE_SCHEDULE procedure, 1007, 1008CREATE_WINDOW procedure, 1014DEFINE_CHAIN_RULE procedure, 1009DEFINE_CHAIN_STEP procedure, 1009DISABLE procedure, 1016, 1007DROP_JOB procedure, 1000DROP_JOB_CLASS procedure, 1012DROP_PROGRAM procedure, 1007DROP_SCHEDULE procedure, 1008DROP_WINDOW procedure, 1016ENABLE procedure, 1006, 1007, 1009GET_SCHEDULER_ATTRIBUTE

procedure, 1017LOGGING_XYZ values, 1012, 1019OPEN_WINDOW procedure, 1015PURGE_LOG procedure, 1012RUN_CHAIN procedure, 1010RUN_JOB procedure, 1000SET_ATTRIBUTE procedure, 1005,

1008, 1018SET_ATTRIBUTE_NULL procedure, 1017SET_ATTRIBUTES procedure, 1016SET_SCHEDULER_ATTRIBUTE

procedure, 1017STOP_JOB procedure, 1000

DBMS_SERVER_ALERT package, 227, 955–956, 957

DBMS_SERVER_REGISTRY view, 439DBMS_SESSION package, 1101, 1106, 1107DBMS_SHARED_POOL package, 1138, 1142DBMS_SPACE package, 255–256

ASA_RECOMMENDATIONS function, 980CREATE_INDEX_COST procedure, 298, 299estimating size of index, 298–299estimating space requirements, 268finding unused space in segments, 928

FREE_BLOCKS procedure, 255SPACE_USAGE procedure, 255, 268UNUSED_SPACE procedure, 255

DBMS_SPACE_ADMIN package, 218DBMS_SPM package, 1081, 1082, 1083, 1085DBMS_SQLDIAG package, 1035–1038DBMS_SQLPA package, 1217DBMS_SQLTUNE package

ACCEPT_SQL_PROFILE procedure, 1115ALTER_SQL_PROFILE procedure, 1115configuring automatic SQL tuning,

1117–1118CREATE_ANALYSIS_TASK procedure, 1218CREATE_SQLSET procedure, 1217CREATE_STGTAB_SQLSET procedure, 1218CREATE_TUNING_TASK procedure, 1113EXECUTE_ANALYSIS_TASK procedure,

1218, 1219EXECUTE_TUNING_TASK procedure,

1114, 1117EXPORT_TUNING_TASK procedure, 1117interpreting automatic SQL tuning

reports, 1119managing SQL profiles, 1115PACK_STGTAB_SQLSET procedure, 1218performing automatic SQL tuning,

1113–1114REPORT_ANALYSIS_TASK function, 1219REPORT_AUTO_TUNING_TASK

function, 1119REPORT_TUNING_TASK procedure, 1114running SQL Tuning Advisor, 1113–1115SELECT_CURSOR_CACHE procedure, 1217SET_TUNING_TASK_PARAMETERS

procedure, 1117SYS_AUTO_SQL_TUNING_TASK

procedure, 1118UNPACK_STGTAB_SQLSET procedure, 1218

DBMS_STATS packageautomatic optimizer statistics collection, 898AUTO_SAMPLE_SIZE procedure, 1055collecting statistics, 1053–1056CREATE_EXTENDED_STATS function,

1059, 1060DELETE_PENDING_STATS procedure, 1057DROP_EXTENDED_STATS function, 1059EXPORT_PENDING_STATS procedure, 1057frequency for refreshing statistics, 1086GATHER_DATABASE_STATS procedure,

1055–1056, 1062, 1063GATHER_DATABASE_STATS_JOB_PROC

procedure, 899GATHER_DICTIONARY_STATS

procedure, 1063GATHER_FIXED_OBJECTS_STATS

procedure, 1062gathering statistics, 1048GATHER_TABLE_STATS procedure,

1059, 1060

Page 59: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1279■I N D E X

GATHER_XYZ_STATISTICS procedures, 1086GATHER_XYZ_STATS procedures, 1054GET_PREFS procedure, 1056managing/monitoring database, 213manually collecting optimizer statistics, 900METHOD_OPT attribute, 1086PUBLISH_PENDING_STATS procedure, 1057SET_TABLE_PREFS function, 1057

DBMS_STORAGE_MAP package, 994DBMS_STREAMS_ADM package, 674DBMS_STREAMS_AUTH package, 674DBMS_SYSTEM package, 1102, 1175DBMS_TRANSACTION package, 380DBMS_TTS package, 717, 721DBMS_WORKLOAD_CAPTURE package, 1210

ADD_FILTER procedure, 1210CANCEL_REPLAY procedure, 1215FINISH_CAPTURE procedure, 1211GET_REPLAY_INFO function, 1215INITIALIZE_REPLAY procedure, 1213PREPARE_REPLAY procedure, 1214PROCESS_CAPTURE procedure, 1211REMAP_CONNECTION procedure, 1214REPLAY_REPORT function, 1215START_CAPTURE procedure, 1211START_REPLAY procedure, 1214

DBMS_WORKLOAD_REPOSITORY packageAWR_REPORT_XYZ functions, 967configuring ADDM, 881CREATE_BASELINE procedure, 963CREATE_BASELINE_TEMPLATE

procedure, 965CREATE_SNAPSHOT procedure, 961DROP_BASELINE procedure, 964DROP_SNAPSHOT procedure, 961managing AWR snapshots, 961modifying snapshot settings, 964MODIFY_SNAPSHOT_SETTINGS

procedure, 882DBMS_XPLAN package, 1083, 1084, 1092db_name attribute, USERENV namespace, 580DB_NAME parameter, 398, 451, 452, 446db_name_restore.sh script, 432DB_nK_CACHE_SIZE parameter, 190, 196,

458, 943DB_RECOVERY_FILE_DEST parameter,

469, 738creating ASM databases, 919flash recovery, 400, 410, 737, 738, 739OMF, 247, 249, 250, 252, 923, 926

DB_RECOVERY_FILE_DEST_SIZE parameter, 469, 741, 919

flash recovery area, 249, 250, 400, 737, 923DB_RECYCLE_CACHE_SIZE parameter, 189,

195, 458DB_SECUREFILE parameter, 472dbshut.sh script, 423, 499, 500DBSNMP account, 490, 596dbstart.sh script, 423, 499, 500

DBUA (Database Upgrade Assistant), 428, 429, 430–433

creating Sysaux tablespace, 239managing/monitoring database, 213

DB_ULTRA_SAFE parameter, 470, 796DB_UNIQUE_NAME parameter, 451DBVERIFY utility, 797DBWn see database writerDB_WRITER_PROCESSES parameter, 455, 1179

SPFILE, 182dd command, UNIX/Linux, 76, 725, 752, 790DDL (data definition language)

DBMS_METADATA package extracting, 294DDL statements, 22executing SQL statements, JDBC, 539–540locks, 350pending transactions, 134resumable database operations, 383SQL statements, 264transaction processing of, 337, 338triggers, 591, 592using ROLLBACK command with, 272

ddl_lock_timeout parameter, 350DDL_LOG table, 592DDL_LOG_TRIG trigger, 592deadlocks, 340, 346, 352DEALLOCATE UNUSED option, 220, 928decision-support system (DSS), 9declarative referential integrity, 36DECLARE statement, PL/SQL, 1241, 1245DECODE function, SQL, 1230DECRYPT keyword, 608decryption, data, 604dedicated server architecture, 512dedicated server configuration, 180default accounts, 491default auditing, 588default buffer pool, 189, 1146DEFAULT DEVICE TYPE parameter,

RMAN, 763DEFAULT DIRECTORY clause, 648default file location, 738default permanent tablespaces, 235–236

creating/managing users, 544database creation, 444, 482

default profile, users, 550–551default role, 574DEFAULT TABLESPACE clause, 236, 547default tablespaces, 237, 544default temporary tablespaces, 232, 444, 482

creating/managing users, 544default trace directory (UDUMP), 168DEFAULT_CONSUMER_GROUP, 558,

563, 1011DEFAULTIF parameter, SQL*Loader, 642DEFAULT_JOB_CLASS, Scheduler, 1011DEFAULT_MAINTENANCE_PLAN, 559, 1022DEFAULT_PLAN resource plan, 559deferrable constraints, 310

Page 60: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1280 ■IN D E X

deferred statistics publishing, 1056–1057DEFINE command, SQL*Plus, 107, 126, 127DEFINE_CHAIN procedure, 1009DEFINE_CHAIN_RULE procedure, 1009definer’s rights, 573degree of parallelism see parallelismDEL command, SQL*Plus, 131delete anomaly, 29, 32, 33DELETE clause, MERGE statement, 660DELETE command, RMAN, 758

EXPIRED option, 758OBSOLETE option, 741, 758, 759SCRIPT option, 750

DELETE statement, 263, 272, 287PL/SQL, 1242SQL, 1225–1226

DELETE_CATALOG_ROLE, 569DELETE_PENDING_STATS procedure, 1057DELETE_TASK procedure, 890deleting files, UNIX, 59DELETION POLICY option, RMAN, 766DELIMITED BY clause, 648delimiters, SQL*Loader, 632delta values, 948denormalization, 29, 34dependencies, transportable tablespaces,

716, 717Deployment Procedure Manager, 148Deployments page, Grid Control, 159DESC keyword, ORDER BY clause, SQL, 1226DESCRIBE command, 293

Scheduler managing external jobs, 1003SQL*Plus, 119viewing object information, SQL, 329

detached jobs, Oracle Scheduler, 996detail tables, materialized views, 314/dev directory, UNIX, 63/dev/null, UNIX, 56development databases, 9development DBA, 8device column, iostat command, 82device files, UNIX, 63DEVICE TYPE parameter, RMAN, 763, 764, 765devices, Oracle Secure Backup, 789df command, UNIX/Linux, 81, 86, 219DFDs (data-flow diagrams), 23Diag Alert/Incident/Trace directories, ADR,

1024, 1026diagnostic framework, 947diagnostic pack, 459Diagnostic Summary, Database Control, 145DIAGNOSTIC_DEST parameter, 178, 449

ADR, 396, 1023OMF, 926

diagnosticssee also ADDM (Automatic Database

Diagnostic Monitor)ADR, 178, 211, 396, 1022, 1023–1024ADRCI, 1022, 1024–1026application knowledge for diagnosis, 1182

Data Recovery Advisor, 803, 829, 1023fault diagnosability infrastructure, 210–211,

1022–1038Health Monitor, 1022, 1032–1035incident packaging service (IPS), 1022,

1026–1028Oracle Diagnostics Pack, 149, 949performance- and diagnostics-related

parameters, 461–468SQL Repair Advisor, 1023, 1035–1038SQL Test Case Builder, 1023, 1038Support Workbench, 1022, 1028–1032

dictionary cache, 191, 1134–1135Dictionary Comparisons page, Database

Control, 147dictionary-managed tablespaces, 217dictionary tables, 1062–1063DICTIONARY value, extent management, 221DICTIONARY_ACCESSIBILITY parameter, 613diff command, UNIX/Linux, 53difference operation, 21differential backup, RMAN, 756, 757dimensions

MODEL clause creating multidimensional arrays, 668, 670

DIRECT clause, SQL*Loader, 641direct hand-off to dispatcher, 512DIRECT parameter, SQL*Loader, 634Direct Path API, 680direct path read/write wait events, 1178directories, Oracle

administrative directories, 397creating directories for database files, 399creating directories, preinstallation, 409–410directory structure, OFA guidelines, 395mount points, 394naming conventions, OFA guidelines, 394Oracle base, 395Oracle home, 395, 396Oracle Inventory directory, 396

directories, UNIXbin directory, 48changing directories, 48creating, 62device files, 63directory management, 62file types, 57home directory, 46, 63indicating file is directory, 60individual directories described, 63listing files in directory, 58locating directories, 52mount points, 86navigating directory structure, 62present working directory, 49removing directories, 62root directory, 63system configuration files, 63temporary files, 63

Page 61: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1281■I N D E X

directory administration tools, OID, 535Directory Information Tree (DIT), 536directory management, UNIX, 62directory naming context, 537directory naming method, 525, 534–537directory objects, 178, 682

creating external table layer, 648–649Data Pump utilities using, 681–685

DIRECTORY parameter, Data Pump, 683, 684, 690, 706

directory privileges, 571directory services, 534directory structure, OFA-compliant, 399directory structure, UNIX, 47DIRECTORY_PATH parameter, NAMES, 530direct-path loading, SQL*Loader, 627, 628,

639–642dirty buffers, 188dirty reads problem, 341, 344, 345disable no validate state, 309DISABLE procedure

DBMS_AUTO_TASK_ADMIN, 1021, 1118DBMS_SCHEDULER, 1007, 1016

disable validate state, 309disaster recovery, 798–800

see also recoveryDISCARD FILE parameter, 648DISCARD parameter, SQL*Loader, 635DISCARDMAX parameter, SQL*Loader, 635discrete transactions, Oracle, 380disk allocation/layout, OFA, 393disk blocks, 166disk cache for tape, flash recovery area, 735disk configuration strategies, 85–88, 93–95

RAID systems, 88–93disk fragmentation, ASM, 901disk groups, ASM see ASM disk groupsdisk I/O see I/Odisk mirroring see mirroringDISK PARALLELISM parameter, RMAN,

764, 765disk partitioning, 87disk reads, 1109disk space, 403disk storage requirements, Oracle Database

11g, 392disk storage, UNIX, 85–88

performance monitoring, 81RAID systems, 88–93

disk striping, 87, 88Disk-Based Backup and Recovery, 734disk_reads column, V$SQL view, 1108DISK_REPAIR_TIME attribute, 908, 910disks

configuring physical disks, 88cost of disk I/O, 186disk I/O, 1159modifying data on, 181monitoring disk usage, UNIX, 86

RAID systems, 88–93recovering from damaged disk drive, 849

DISMOUNT FORCE clause, ALTER DISKGROUP, 913

dispatchers, 512shared server processes, 180

DISPLAY environment variable, DBCA, 486DISPLAY function, DBMS_XPLAN package, 1092DISPLAY variable, 411, 412, 414, 416, 422DISPLAY_AWR function, 1092DISPLAY_SQL_PLAN_BASELINE function,

1083, 1084DISTINCT operation, indexing strategy, 1071distinguished names (DNs), 536, 537distributed locks, 351distribution files, OFA guidelines, 399distribution functions, SQL, 1232DIT (Directory Information Tree), OID, 536DML (data manipulation language)

DML statements, 22, 263executing SQL statements, JDBC, 539–540indexing strategy, 1071locks, 349–350making DML changes permanent, 133PL/SQL, 1242resumable database operations, 383row- and table-level locks, 349transaction processing of, 337, 338triggers, 590–591VERSIONS_OPERATION pseudo-

column, 371view showing DML changes, 331

DMnn processes, Data Pump, 685DNs (distinguished names), 536, 537documentation review, Oracle Database 11g, 392dollar sign ($) character, SQL, 1238domain component, DNs, 537domain constraints, 37domains, 20, 514DOUBLE data type, 1222double failure protection mode, Oracle Data

Guard, 800downgrading from Oracle Database 11g, 441downloading Oracle software, 415–416

Oracle Client software, 517dpdump directory, 397d_predicate predicate, 583DRCP (database resident connection pooling),

180, 531–533DriverManager class, JDBC, 538drivers see JDBC driversDROP CATALOG command, RMAN, 768,

772, 774DROP command, ALTER TABLE statement, 271DROP DATABASE command, 506DROP DATAFILE command, 806DROP FLASHBACK ARCHIVE command, 872DROP MATERIALIZED VIEW command, 320DROP OUTLINE command, 1079

Page 62: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1282 ■IN D E X

DROP PARTITION command, 291, 302DROP PROFILE command, 553DROP ROLE command, 577DROP STORAGE command, 220DROP SYNONYM command, 326DROP TABLE command, 116, 224, 276, 548, 849DROP TABLE PURGE command, 116DROP TABLESPACE command, 224, 225,

248, 364DROP UNUSED COLUMNS command, 271DROP USER command, 547–548

CASCADE option, 548, 853DROP VIEW command, 313DROP_ACL procedure, 617DROP_BASELINE procedure, 964DROP_EXTENDED_STATS function, 1059DROP_JOB procedure, 1000DROP_JOB_CLASS procedure, 1012dropped tables, restoring, 851–852dropping databases, 506DROP_PROGRAM procedure, 1007DROP_SCHEDULE procedure, 1008DROP_SNAPSHOT procedure, 961DROP_SQL_PATCH procedure, 1038DROP_WINDOW procedure, 1016dte (data transfer element), Oracle Secure

Backup, 789du command, UNIX/Linux, 81, 86dual table, 102, 265dual-mode encryption, 763, 782dump files

COMPRESSION parameter, Data Pump, 691creating export dump file, 704Data Pump utilities, 678, 680, 681importing metadata from, 719matching degree of parallelism, 700REUSE_DUMPFILE parameter, Data

Pump, 691DUMPFILE parameter, Data Pump, 690, 700,

705, 706dumping data block contents, 167, 168duplexing, redo log groups, 983DUPLICATE command, RMAN, 810, 834–837durability property, transactions, 340DWnn processes, Data Pump, 686dynamic data sampling, ATO, 1112dynamic initialization parameters, 177dynamic parameters, 448, 493, 496–497dynamic performance tables, 203, 204

collecting fixed object statistics, 1062dynamic performance views, 203, 204

see also V$ viewsautomatic performance tuning compared,

1131–1132database metrics, 950, 959temporary statistics, 959

dynamic resource management, 941–943dynamic sampling, 1063dynamic security policy, 584

dynamic service registration, 183Oracle PMON process, 521

dynamic-access predicates, row-level security, 583

■Eeasy connect method, 98, 100, 206easy connect naming method, 525, 529–530echo command, UNIX/Linux, 48, 53, 55ECHO variable, SQL*Plus, 107ed command, SQL*Plus, 130EDIT command, SQL*Plus, 106Edit Thresholds page, Database Control,

954, 955EDITFILE variable, SQL*Plus, 107editing files with vi editor, UNIX, 63–65editing within SQL*Plus, 129–134EDITOR variable, SQL*Plus, 128editors, SQL*Plus default, 124egrep command, UNIX/Linux, 66elapsed_time column, V$SQL view, 1108elementstape libraries, Oracle Secure

Backup, 789else keyword, UNIX, 72Emacs text editor, UNIX, 65e-mail notifications, Database Control, 148embedded SQL statements, 262emca utility, 141emca.rsp response file template, 422emctl utility, 143, 156, 157EMPHASIS method, resource plans, 560, 561emulators, UNIX, 46enable no validate state, 309enable parameter, ADD_POLICY

procedure, 594ENABLE procedure

DBMS_AUTO_TASK_ADMIN, 1021, 1118DBMS_SCHEDULER, 1006, 1007, 1009

ENABLE QUERY REWRITE clause, 319ENABLE RESUMABLE clause, 384, 385ENABLE ROW MOVEMENT clause, 286, 929ENABLE TRIGGERS clause, 377enable validate state, 309ENABLE_AT_SYSTEM_CHANGE_NUMBER

procedure, 369ENABLE_AT_TIME procedure, 368ENABLED attribute, CREATE_JOB

procedure, 999ENABLED VALIDATED constraints, 316encapsulation, 39ENCLOSED BY clause, SQL*Loader, 632ENCRYPT clause, creating tables, 269ENCRYPT keyword, 604, 607–608encrypted passwords, database

authentication, 601encrypted tablespaces, 240–243encryption

data decryption, 604data encryption, 603–608

Page 63: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1283■I N D E X

dual-mode encryption, 763generating master encryption key, 607password-based encryption, 763tablespace encryption, 608–610transparent data encryption, 604–608transparent encryption, 763

encryption algorithms, 608ENCRYPTION clause, creating tablespaces,

242, 610ENCRYPTION parameter

Data Pump Export utility, 695populating external tables, 652RMAN, 763, 764

encryption walletcreating Oracle Wallet, 241–242

encryption, RMAN, 781, 782ENCRYPTION_ALGORITHM parameter, Data

Pump, 695ENCRYPTION_MODE parameter, Data

Pump, 695ENCRYPTION_PASSWORD parameter, Data

Pump, 695, 696, 698ENCRYPTION_WALLET_LOCATION

parameter, 241, 609END BACKUP command, 792End of Installation window, 420END statement, PL/SQL, 1241END_DATE attribute

CREATE_JOB procedure, 999CREATE_WINDOW procedure, 1014

endian format, 720–723END_SNAPSHOT parameter, ADDM, 883end-to-end tracing, 1105–1107ENFORCED mode, 316enforced value, 465enqueue waits event, 1179Enterprise Edition, 417, 422Enterprise Manager, 15enterprise user security, 603–611

data encryption, 603–608LDAP, 603shared schemas, 603Single Sign-On feature, 603tablespace encryption, 608–610

enterprise.rsp response file template, 422entity-relationship (ER) diagrams, 27–28

transforming ER diagrams into relational tables, 35

entity-relationship (ER) modeling, 24–26business rules and data integrity, 36ER modeling tools, 34

entryID attribute, USERENV namespace, 580env command, UNIX/Linux, 54environment variables

see also SQL*Plus environment variablesOEM versions managing, 139Oracle user’s home directory, 413setting, post-installation, 424setting, preinstallation, 410–413

setting for database creation, 446UNIX, 54, 55

equi joins, 1066, 1233error handling

Java programs, 540PL/SQL, 1242

error loggingautonomous transactions, 381SQL*Plus error logging, 111–112

error messages, database hangs, 1193errors

benefits of RMAN, 742common resumable errors, 383data block corruption, 167Flashback error correction using undo data,

366–368normal program conclusion without, 338ORA-00257: Archiver error, 741ORA-00376: file # cannot be read ..., 868ORA-01031: insufficient privileges error, 938ORA-01078: failure to process system

parameters, 478ORA-01152: file # was not restored ..., 867ORA-01194: file # needs more

recovery …, 866ORA-01536: space quota error, 383ORA-01555: snapshot-too-old error, 209,

356, 359, 364ORA-01588: must use RESETLOGS

option ..., 866ORA-01589: must use RESETLOGS or ..., 866ORA-01628: maximum extents error, 383ORA-01653: out of space error, 383ORA-01756: quoted string not properly

terminated, 132ORA-15110: no diskgroups mounted, 906ORA-19804: cannot reclaim string

bytes …, 741ORA-19809: limit exceeded for recovery

file, 741ORA-19815: WARNING:

db_recovery_file_dest_size, 740ORA-29701: unable to connect to Cluster

Manager, 905ORA-30032: the statement has timed out, 384ORA-30036: unable to extend segment, 385ORA-30393: a query block in the statement

did not write, 316ORA-4031: out of shared pool memory, 894recovery errors, 866–870REWRITE_OR_ERROR hint, 315sec_protocol_error_xyz_action

parameters, 615SHOW ERRORS command, 118standard error, UNIX, 56viewing error alerts, Support

Workbench, 1029ERRORS parameter, SQL*Loader, 634

Page 64: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1284 ■IN D E X

esac keyword, case command, UNIX/Linux, 74ESTIMATE parameter, Data Pump, 696Estimate Table Size page, Database

Control, 266ESTIMATE_ONLY parameter, Data Pump, 697/etc directory, UNIX, 63, 67ETL (extraction, transformation, loading),

625, 626see also transforming datadata loading, 627external tables, loading data using, 645–656multitable inserts, 660–662Oracle Streams, 671–675populating external tables, 650SQL*Loader utility, 627–645

evaluation mode, SQL Access Advisor, 321event class metrics, 951event management and notification, Oracle

Streams, 670event metrics, 951events

event 10046, tracing SQL code, 1174Oracle Streams, 670setting events, caution when, 1193wait events, 1163

events, Oracle Scheduler, 995, 1010–1011EVOLVE_SQL_PLAN_BASELINE function, 1083EXCEPTION statement, PL/SQL, 1241, 1243exceptions, UTL_FILE package, 258EXCHANGE PARTITION command, 291exclamation point (!)

using operating system commands from SQL*Plus, 120

EXCLUDE parameterData Pump Export utility, 692–693, 704Data Pump Import utility, 708

excluded addresses, securing network, 614exclusive locks, 199, 349executable files

components of Oracle process, 1190Oracle home directory, 177, 395

EXECUTE command, SQL*Plus, 121execute permission, UNIX files, 59EXECUTE privileges, Scheduler, 997EXECUTE SCRIPT command, RMAN, 749EXECUTE_ANALYSIS_TASK procedure,

1218, 1219EXECUTE_CATALOG_ROLE, 569, 717EXECUTE_DIAGNOSTIC_TASK

procedure, 1037executeQuery method, JDBC, 539EXECUTE_TASK procedure, 324, 890, 978EXECUTE_TUNING_TASK procedure,

1114, 1117executeUpdate method, JDBC, 539execution history, ATO, 1112execution phase

SQL processing, 343, 1133TKPROF utility output, 1104

execution plan generation phase, 1044execution plans, 343

Autotrace utility, SQL, 1097EXPLAIN PLAN tool, 1090–1095query processing, 1043query with index, 1098

after analyzing table, 1099query without index, 1097SQL plan baselines, 1080–1085SQL Plan Management (SPM), 1080–1087TKPROF utility output, 1105using hints to influence, 1067–1068

execution stage, query processing, 1046execution time, query optimization, 1043execution time limit method, 555execution times, limiting, 942EXECUTION_DAYS_TO_EXPIRE

parameter, 1118EXECUTION_TYPE parameter, 1219EX_FAIL/EX_FTL, SQL*Loader return

codes, 639EXISTS operator, subqueries, SQL, 1237existsNode operator, SQL/XML, 1249, 1251exit code, finding, 69exit command, RMAN, 745EXIT command, SQL*Plus, 102, 134exit command, UNIX/Linux, 48EXIT_CLIENT parameter, Data Pump, 703,

704, 713exp utility, 680expdp utility, 678, 680, 687EXP_FULL_DATABASE privilege, 685EXP_FULL_DATABASE role, Data Pump,

574, 703EXPIRATION parameter, AWR, 966EXPIRATION_DATE parameter,

Scheduler, 1003expired account, database authentication, 597EXPLAIN parameter, TKPROF utility, 1102EXPLAIN PLAN tool, SQL, 319, 1090–1095

indexing strategy, 1070monitoring index usage, 304

EXPLAIN PLANsAutotrace utility, 1095, 1096, 1098comparing SQL statements, 1127RESULTCACHE hint, 1121SQL Trace tool using, 1100

EXPLAIN_MVIEW procedure, 317EXPLAIN_REWRITE procedure, 316, 317explicit capture, Oracle Streams, 671explicit cursors, 1245explicit locking, 350–352export command, UNIX/Linux, 51, 53, 54export modes, Data Pump, 688–689export parameters, Data Pump, 689–704export prompt, Data Pump, 688export utilities

CONSTRAINTS parameter, 692continued support for, 677

Page 65: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1285■I N D E X

FILE parameter, 690GRANTS parameter, 692INDEXES parameter, 692manual upgrade process, 427

Export utility see under Data Pump utilities (Export, Import)

EXPORT_PENDING_STATS procedure, 1057EXPORT_SQL_TESTCASE_DIR_BY_XYZ

function, 1038EXPORT_TUNING_TASK procedure, 1117EXPRESSION parameter, SQL*Loader, 636expression statistics, 1059EX_SUCC, SQL*Loader return codes, 639extended optimizer statistics, 1058–1060EXTENT MANAGEMENT clause, 230EXTENT MANAGEMENT LOCAL clause, 220extents, 166, 169

allocating data blocks to objects, 172amalgamating free extents, 184ASM mirroring, 914AUTOALLOCATE option, 216, 221, 222deallocating unused space, 268default for tablespace extent

management, 216default number of, 221extent allocation/deallocation, 220–222extent management, 219, 221extent sizing, 216, 219

determining sizing, 220–222temporary tablespaces, 230

INITIAL_EXTENT parameter, 221NEXT_EXTENT parameter, 221, 222operating system files, 220performance, 220segments, 166, 169UNIFORM option, 216, 221UNIFORM SIZE clause, 221using bigfile tablespaces, 237

external authentication, 601–602external authorization, roles, 576external data loading, SQL*Loader, 627external jobs

local/remote external jobs, 1002Oracle Scheduler, 996, 1002–1006

external naming method, 525, 533–534external redundancy level, ASM, 909, 914external tables, 280

creating external table layer, 646–649access drivers, 648

directory objects and locations, 648–649ETL components, 626existence of, 645indexing, 646loading data using, 645–656manual collection of statistics required, 1054populating external tables, 649–652SQL*Loader, 625, 646using external tables, 652–653using SQL*Loader with, 653–656writing to external tables, 651–652

external tables feature, 207Data Pump data access, 680data warehousing, 646SQL*Loader, 627

external_name attribute, USERENV namespace, 580

EXTERNAL_TABLE parameter, 653EXTPROC functionality, PL/SQL, 614extract operator, SQL/XML, 1249, 1251extracting data see ETL (extraction,

transformation, loading)extractValue operator, SQL/XML, 1249, 1251EX_WARN, SQL*Loader return codes, 639EZ Connect string, DRCP connection, 532EZCONNECT method, 530

■FFAILED_LOGIN_ATTEMPTS parameter, 550,

599, 612FAILGROUP keyword, ASM disk groups, 915failure code, SQL*Loader return codes, 639failure grouping, Data Recovery Advisor, 830failure groups, ASM disk groups, 914failure priority, Data Recovery Advisor, 830failure status, Data Recovery Advisor, 830failures, database, 801–804

Transparent Application Failover, 802FAN (Fast Application Notification) events, 101fast commit mechanism, 183, 199fast mirror resync feature, ASM, 908–909FAST option, materialized views, 317, 318, 319Fast Start Checkpointing, 805Fast Start Fault Recovery, 804, 805FAST_START_MTTR_TARGET parameter, 805

automatic checkpoint tuning, 933MTTR Advisor, 981redo log sizing, 1205

fatal error code, SQL*Loader return codes, 639fault diagnosability infrastructure, 210–211,

1022–1038Automatic Diagnostic Repository, 211, 1022,

1023–1024ADRCI, 211, 1022, 1024–1026Data Recovery Advisor, 211, 1023Health Monitor, 1022, 1032–1035health monitor, 211incident packaging service (IPS), 211, 1022,

1026–1028SQL Repair Advisor, 1023, 1035–1038SQL Test Case Builder, 211, 1023, 1038Support Workbench, 211, 1022, 1028–1032

FCLOSE/FCLOSE_ALL procedures, UTL_FILE, 258

FEEDBACK variable, SQL*Plus, 107, 108FETCH command, explicit cursors, PL/SQL, 1245Fetch operation, TKPROF utility, 1104fetching, SQL processing steps, 1133FGAC (fine-grained access control), 578,

582–585DBA_FGA_AUDIT_TRAIL, 596

Page 66: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1286 ■IN D E X

fgrep command, UNIX/Linux, 66field list, SQL*Loader, 629Fifth Normal Form (5NF), 34FILE ARRIVAL event, 1010, 1011file deletion policy, flash recovery area, 740file directory, UTL_FILE package creating, 256file locations, flash recovery area, 738file management

see also ASM (Automatic Storage Management)

Oracle Managed Files (OMF), 247–253, 922–927

file mapping, 993–994file metrics, 951FILE parameter, export utility, 690file systems

alias for file system directory, 178database creation, 444–445disk configuration strategies, 87Oracle Managed Files (OMF) managing, 247

filemap.ora file, 993FILE_MAPPING parameter, 993, 994FILENAME parameter, TKPROF utility, 1102filename.lst file, 120filenames, ASM, 917–918file-related parameters, 453–454files

administrative files, 397alert log file, 177backup files, 178control files, 173, 174–175copying files between databases, 253–255database files, 398–400datafiles, 173–174FCLOSE procedure, 258FCLOSE_ALL procedure, 258FOPEN function, 257initialization files, 173locating for database creation, 445naming conventions, OFA guidelines, 394network administration files, 173operating system files, 256–259password file, 177product files, 397recovering, SQL*Plus, 134redo log files, 173, 175–176setting file permissions, preinstallation, 409SPFILE (server parameter file), 177trace files, 178UTL_FILE package, 256–259

files, UNIX, 57–62changing filename, 59changing group, 62comparing files, 53copying, 59creating file without data, 63device files, 63directory management, 62editing files with vi, 65

editing text with vi, 63file types, 57indicating file is directory, 60joining files, 67linking files, 57–58listing files in directory, 58locating files, 52location of executable files, 49locations and paths, 47managing files, 58–59moving around files, 65moving file location, 59outputting columns, 66pattern matching, 65permissions, 59–62protecting files from overwriting, 57reading contents of files, 52removing directories containing files, 62removing duplicate lines of text, 68removing files, 59sending and receiving files using FTP, 79shell scripts, 68–74sorting text, 68special files, 57system configuration files, 63temporary files, 63text extraction utilities, 65viewing contents of, 58

FILESIZE parameter, Data Pump, 690, 705FILE_TYPE, UTL_FILE package, 257Filter Options page, SQL Access Advisor, 322filtering

metadata filtering, 692WHERE clause, SQL 1066, 1226

find command, UNIX/Linux, 52findings, ADDM, 880

ADDM reports, 888, 891fine-grained auditing, 586, 593–596fine-grained data access, 578–586

application contexts, 579–581column-level VPD, 585–586fine-grained access control (FGAC), 578,

582–585fine-grained network access control, 615–618fine-grained recovery, 840–847FINISH_CAPTURE procedure, 1211FINISH_REDEF_TABLE procedure, 940, 941Finnegan, Peter, 614firewalls, 614First Normal Form (1NF), 30–31FIRST_ROWS value, OPTIMIZER_MODE, 1050FIRST_ROWS(n) hint, 1067FIX_CONTROL parameter, 1036FIXED clause, external table layer, 647fixed dictionary tables, 1062fixed record format, SQL*Loader, 631fixed SQL plan baselines, 1083fixed value thresholds, 954FIXED_DATE parameter, 449

Page 67: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1287■I N D E X

flash recovery area, 201, 734–741Automatic Disk-Based Backup and

Recovery, 734backing up, 739configuring, 737contents of, 735control files, 738creating, 400, 736–739creating, preinstallation, 410database creation log, 485DB_RECOVERY_FILE_DEST parameters, 249default file location, 738description, 468disabling, 737dynamically defining, 737Flashback Database, 854, 857, 858LOG_ARCHIVE_DEST_10 destination, 736managing, 740–741managing/monitoring database, 213OFA guidelines, 396Oracle Managed Files (OMF), 734, 738out-of-space warning and critical alerts, 741parameters, setting up, 739redo log files, 738sizing, 736sizing for database creation, 445specifying default location for, 469specifying size of, 469upgrading with DBUA, 432

Flashback Data Archive feature, 202, 870–874Flashback techniques, 848

flashback data archiver (FBDA) process, 186Flashback Database, 202, 469, 853–861

block media recovery (BMR), 864brief comment, 367configuring, 854–856data repair, 803database-level Flashback techniques, 848disabling, 856–857enabling, 855example using, 859–861flash recovery area, 735, 854, 857, 858flashback database logs, 854limitations, 861privileges, 857restore points, 863RVWR (recovery writer), 857storage limits, 857–858

FLASHBACK DATABASE statement, 854, 857Flashback Database logs

flash recovery area, 857Flashback Drop, 202, 276, 848, 849–853

description, 367, 376, 377flashback features, 200

using flashback features for auditing, 593flashback levels, 848flashback logs, flash recovery area, 735Flashback Query, 202, 366, 367–368

correcting human error, 802RETENTION GUARANTEE clause, 374

row-level Flashback techniques, 848using flashback features for auditing, 593

flashback recovery techniques, 202Flashback Table, 202, 366, 376–378, 848FLASHBACK TABLE statement, 377, 378, 852Flashback techniques, 808, 848FLASHBACK TO BEFORE DROP statement, 116Flashback Transaction, 366, 379–380Flashback Transaction Backout, 202, 848,

868–870Flashback Transaction Query, 366, 372–375,

593, 848Flashback Versions Query, 366, 369–372,

375–376, 593, 848FLASHBACK_RETENTION_TARGET

parameter, 857flashbacks

DBMS_FLASHBACK package, 368–369error correction using undo data, 366–368Oracle Database 11g features, 366specifying flashback time, 469undo tablespaces, 367UNDO_RETENTION parameter, 359

FLASHBACK_SCN parameter, Data Pump, 699, 713

FLASHBACK_TIME parameter, Data Pump, 700, 713

FLASHBACK_TRANSACTION_QUERY view, 372, 373

FLOAT data type, 1222flow control structures, UNIX, 71–74FLUSH clause, ALTER SYSTEM, 1135FLUSH procedure, DBMS_RESULT_

CACHE, 1123FLUSH variable, SQL*Plus, 108FMON process, file mapping, 993FMPUTL process, file mapping, 993footers, SQL*Plus, 123FOPEN function, UTL_FILE package, 257FOR LOOP statement, PL/SQL, 1244, 1246FORCE attribute, Scheduler jobs, 1000FORCE option

refreshing materialized views, 317starting ASM instances, 908

FORCE valueCURSOR_SHARING parameter, 466, 1139QUERY_REWRITE_ENABLED parameter, 315

for-do-done loop, UNIX, 73FOREIGN KEY REFERENCES clause, 285foreign keys, 35, 36, 308, 1071FORMAT clause

BACKUP command, RMAN, 754SET SERVEROUTPUT command,

SQL*Plus, 109FORMAT parameter

converting datafiles to match endian format, 721

RMAN backup file locations, 755formatting, SQL*Plus, 118, 122–124forName method, java.lang, 538

Page 68: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1288 ■IN D E X

%FOUND attribute, PL/SQL, 1246Fourth Normal Form (4NF), 34fractured block problem, whole open

backups, 792fragmentation, segment space

management, 928free buffer waits event, 1178free buffers, 188free space, 255–256

alerts, 226database writer (DBWn) process, 199datafiles, 219DBA_FREE_SPACE view, 243extent allocation/deallocation, 220preinstallation checks, 403, 404Recycle Bin, 244segment space management, 217

free space section, data blocks, 167free, vmstat utility, 82FREE_BLOCKS procedure, DBMS_SPACE, 255freelists, segment space management, 217FREQ keyword, Oracle Scheduler, 999FROM clause, SELECT statement

necessity for dual table in Oracle’s SQL, 102subqueries, 263

FTP (File Transfer Protocol), 79full export mode, Data Pump, 688FULL hint, 1067FULL parameter, Data Pump, 688, 708full table scans

avoiding unnecessary full table scans, 1075guidelines for creating indexes, 297INDEX_FFS hint, 1068query optimization, 1052

fully qualified name, 452function-based indexes, 302, 1066, 1072function privileges, 571functional dependence, 29, 33functions, SQL see SQL functionsfuzzy-read problem, data concurrency, 342

■GGather Statistics Wizard, 1195GATHER_DATABASE_STATS procedure,

1055–1056, 1062, 1063GATHER_DATABASE_STATS_JOB_PROC

procedure, 899GATHER_DICTIONARY_STATS

procedure, 1063GATHER_FIXED_OBJECTS_STATS procedure,

1054, 1062GATHERING_MODE parameter, 1060GATHER_STATS_JOB, 898–899, 1047–1049, 1065GATHER_SYSTEM_STATS procedure,

1060–1062GATHER_TABLE_STATS procedure, 1059, 1060GATHER_XYZ_STATISTICS procedures, 1086GATHER_XYZ_STATS procedures, 1054

GENERATED ALWAYS AS clause, 270GET command, SQL*Plus, 106, 128get command, UNIX/Linux, 79, 80getConnection method, JDBC drivers, 538GET_DDL procedure, 295GET_FILE procedure, 253, 254, 992GET_LINE procedure, 257GET_PREFS procedure, 1056GET_REPLAY_INFO function, 1215GET_REPORT function, 884GET_RUN_REPORT function, 1033GET_SCHEDULER_ATTRIBUTE procedure, 1017GET_SYSTEM_CHANGE procedure, 369GET_TASK_REPORT procedure, 890, 978GET_THRESHOLD procedure, 956glance command, UNIX/Linux, 85GlancePlus package, performance

monitoring, 84global authorization, roles, 576global database names, Oracle networking, 514global partitioned indexes, 302, 1073global preferences file, SQL*Plus, 110GLOBAL QUERY REWRITE privilege, 317GLOBAL SCRIPT command, RMAN, 750GLOBALLY clause, CREATE ROLE, 576GLOBAL_NAMES parameter, Oracle

Streams, 673glogin.sql file, 110, 111gpm command, UNIX/Linux, 85GRANT ANY OBJECT privilege, 569, 573GRANT ANY PRIVILEGE privilege, 569GRANT command, SQL*Plus, 136GRANT statement, 567, 568–569, 572GRANT_ADMIN_PRIVILEGE procedure, 674granting privileges, 612, 618

to users with UTL_FILE package, 257granting roles, recovery catalog, 767GRANTS parameter, export utility, 692granular recovery techniques, 840–847

LogMiner utility, 841–847tablespace point-in-time recovery, 840–841

granularityautonomous transactions, 381Data Pump technology, 679locks, 348

GRANULARITY attribute, 1055grep command, UNIX/Linux, 49, 65, 75Grid Control, 139, 153–161

alerts, 160analyzing page performance, 160components of Grid Control framework, 154configuring automatic SQL tuning

parameters, 1119connecting to, 157critical patch advisories, 159Database Control, OEM alternative, 206database management, 158, 213deployments summary, 159enterprise configuration management, 158

Page 69: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1289■I N D E X

features, 158–159grouping targets, 159installing, 154–156logging into, 157Management Repository, 154managing enterprise using, 159managing groups, 161monitoring and managing enterprise

configuration, 158monitoring application servers, 160monitoring host performance, 160monitoring host/databases/services, 154monitoring system with, 159–161monitoring web applications, 160obtaining host and database configuration

information, 158OEM Management Agent, 154, 156Oracle Management Service (OMS), 154, 157Oracle software cloning, 148resource center, 159status information, 159transaction performance, 160upgrading with DBUA, 432user interface for, 154versions, 137viewing ADDM reports, 890–892

Grid Control pages, 159–160Database page, 153

GROUP BY clausesguidelines for creating indexes, 297indexing strategy, 1071program global area (PGA), 193SQL, 1234–1236

group commits, log writer (LGWR) process, 199grouping operations, SQL, 1234–1236groups, Grid Control, 159, 161groups, UNIX, 62, 406–408guaranteed restore points, 862, 863guaranteed undo retention, 362–365

■Hhandler_xyz parameters, ADD_POLICY

procedure, 594, 595Hang Analysis page, Database Control, 355,

1192–1194hanganalyze utility, database hangs, 1193hangs see database hangsHARD (Hardware Assisted Resilient Data),

95, 798hard links, UNIX, 57hard parse elapsed time,

V$SESS_TIME_MODEL, 1206hard parsing, 191, 343, 1135, 1136

converting to soft parsing, 1141reducing number of, 1141resources used, 1138sessions with lots of, 1139

hardware, ADDM recommendations, 881

Hardware Assisted Resilient Data (HARD), 95, 798

hash clusters, 296hash joins, 1052, 1068hash partitioning, 283–284, 288HASH_AREA_SIZE parameter, 194HASHKEYS value, CREATE CLUSTER, 296hash-partitioned global indexes, 303HAVING clause, 1067HAVING operator, GROUP BY clause, SQL, 1236head command, UNIX/Linux, 65headers, SQL*Plus, 123HEADING variable, SQL*Plus, 108Health Monitor, 211, 1022, 1032–1035heap, 1190heap indexes, 300heap-organized tables, 265, 1072help

man command, UNIX/Linux, 50showing help topics, SQL*Plus, 106

HELP command, Data Pump, 703, 704, 713help command, lsnrctl utility, 522HELP INDEX command, SQL*Plus, 106Help page, Grid Control, 159heuristic strategies, query processing, 1046hidden Oracle parameters, 177hierarchical queries, SQL, 1232High Availability, Database Control

Performance page, 145high redundancy level, ASM, 909, 914high water mark see HWMHigh Water Marks page, 153high-availability systems, 798–799hints

NO_RESULT_CACHE hint, 1122optimizer hints, 1051optimizing queries, 205RESULT_CACHE hint, 1121, 1122REWRITE_OR_ERROR hint, 315using hints to influence execution plans,

1067–1068histogram functions, SQL, 1232histograms, 1086–1087history

Active Session History (ASH), 210, 971–975history command, UNIX/Linux, 49hit ratios

buffer cache hit ratio, 190, 1144database hit ratios, 1161–1162latch hit ratio, 1179library cache hit ratio, 1137not relying on, 1182

HM_RUN command, 1034Home Details window, Oracle Universal

Installer, 417home directories

naming conventions, OFA guidelines, 394home directory, UNIX, 46, 63HOME shell variable, UNIX, 54

Page 70: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1290 ■IN D E X

host attribute, USERENV namespace, 580Host chart, Database Performance page, 1199HOST command, SQL*Plus, 105, 106, 119Host CPU chart, Database Control, 1196Host home page, Grid Control, 160host names

connect descriptors, 515precedence order for evaluating, 617

host parametereasy connect naming method, 529

hosts, Oracle Secure Backup, 786, 788hot backups see open backupshot restore, RMAN, 816hot spares, RAID systems, 88hot swapping, RAID systems, 88Hotsos, DBA resources, 14HR (human resources) schema, 1221HWM (high water mark)

Database Control, 151, 153determining free space, 255manual segment shrinking, 929online segment shrinking, 927reclaiming unused space below HWM, 935

hyphen pair notation (--), SQL*Plus, 128hypothetical ranks and distribution functions,

SQL, 1232

■IIDENTIFIED BY clause, 544, 547, 575IDENTIFIED EXTERNALLY clause, 576IDENTIFIED GLOBALLY clause, 576IDENTIFIED USING clause, role

authorization, 575identifiers see keysidle events, 1181idle time method, Database Resource

Manager, 555Idle wait class, 1163IDLE_TICKS system usage statistic, 1181IDLE_TIME parameter, 549, 553idle-time-limit resource directive, 560, 561IE (information exchange) schema, 1222iee (import-export element), Oracle Secure

Backup, 789IFILE parameter, 453IF-THEN statements, PL/SQL, 1243if-then-else-if structure, UNIX, 71image copies, RMAN, 743, 752–753, 754,

756, 780immediate constraints, 310IMMEDIATE option

committing transactions, 339SHUTDOWN command, 503

imp utility, 680Impact column, ADDM reports, 891impact estimate, ADDM findings, 880impdp utility, 678, 680IMP_FULL_DATABASE privilege, 685IMP_FULL_DATABASE role, 574, 703

implementation, 3, 37implicit capture, Oracle Streams, 671implicit commit, 338, 339implicit cursors, PL/SQL, 1245implicit locking, 351IMPORT CATALOG command, RMAN, 771, 772import modes, Data Pump, 705import parameters, Data Pump, 705–713import prompt, Data Pump interactive

mode, 688import types, Data Pump, 705import utilities, 677

see also Data Pump utilities (Export, Import)INDEXFILE parameter, 706

Import utility see under Data Pump utilities (Export, Import)

import-export element (iee), Oracle Secure Backup, 789

IMPORT_FULL_DATABASE role, Data Pump, 705

IN clause, SQL subqueries, 1067in memory metrics, 951IN operator, SQL, 1227INACTIVITY TIMEOUT parameter, DRCP,

532, 533INCARNATION option, LIST command,

RMAN, 823incarnations, database, 822incident, 1026incident packages

creating, Support Workbench, 1030–1031Diag Incident directory, ADR, 1024

incident packaging service (IPS), 211, 1022, 1026–1028

INCLUDE parameter, Data Pump, 692–693, 708INCLUDING clause, CREATE TABLE, 279, 280INCLUDING CONTENTS clause, DROP

TABLESPACE, 224, 225, 853incomplete recovery, 807, 820–824inconsistent backups, 727incremental backups, 732, 733

flash recovery area, 735RMAN, 742, 756–757, 778, 779

INDEX hint, 1067index key compression, 1076index-organized tables see IOTsindex range scans, 1095index scans, query optimization, 1052index segments, 169index skip scan feature, 1072indexes

ALTER INDEX REBUILD command, 217bitmap indexes, 1071bitmap join indexes (BJI), 1069coalescing indexes online, 935column data with low cardinality, 1071concatenated indexes, 1072creating indexes online, 935creating tablespaces first, 215

Page 71: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1291■I N D E X

data block sizes and tablespaces, 171efficient SQL indexing strategy, 1070–1073EXPLAIN PLAN tool examples, 1093, 1094function-based indexes, 1066, 1072index-only plans, 1071index-organized tables (IOTs), 1072monitoring index usage, 1073moving from development to

production, 1070partitioned indexes, 1073primary indexes, 1070rebuilding indexes online, 934rebuilding indexes regularly, 1089removing unnecessary indexes, 1073reverse key indexes, 1072secondary indexes, 1070, 1071separating table and index data, 170sizing for database creation, 444SQL*Loader utility, 644using appropriate index types, 1071–1073views in query preventing use of, 1065what to index, 1071when to use indexes, 1070–1071

INDEXES parameter, 692indexes, Oracle, 296–300

bitmap indexes, 301B-tree index, 298, 301creating an index, 299–300DBA_IND_COLUMNS view, 333DBA_INDEXES view, 333dropping tables, 276estimating size of index, 298–299extracting DDL statements for, 294function-based indexes, 302global partitioned indexes, 302guidelines for creating, 297–298heap indexes, 300invisible indexes, 303–304key-compressed indexes, 301keys compared, 297locally partitioned indexes, 303maintaining, 305materialized views, 314monitoring usage, 304–305OPTIMIZER_USE_INVISIBLE_INDEXES

parameter, 463Oracle index schemes, 298partitioned indexes, 302–303performance enhancement

recommendations, 320performance trade-off using, 296, 301rebuilding, 305reverse-key indexes, 301special types of, 300–304SQL Access Advisor recommendations, 303transparency of, 296types, 297

INDEX_FFS hint, 1068INDEXFILE parameter, 706

index-organized tables see IOTsINDEX_STATS view, 334INFILE parameter, SQL*Loader, 628, 630InfiniBand, 94Information Lifecycle Management (ILM)

applications, 874inheritance, 39init.cssd script, 904init.ora file

see also initialization files; PFILEactivating parameter limits in user

profiles, 553automatic service registration, 521backup guidelines, 729cloning databases with RMAN, 834creating new database, 177creating OMF-based instance, 251database instance names, 514DB_BLOCK_SIZE parameter, 166manual database upgrade process, 437OMF redo log files, 250Oracle Managed Files (OMF), 250post-upgrade actions, 441REMOTE_OS_AUTHENT parameter, 615setting initialization parameters,

post-installation, 424upgrading with DBUA, 430

init+asm.ora file, 905INITCAP function, 657initial extent, database objects, 169Initial Options page, SQL Access Advisor, 322INITIAL_EXTENT parameter, 221initialization files, 173, 447, 448–449

see also init.ora file; PFILEnesting initialization files, 453Oracle looking for correct file, 494, 497setting up flash recovery parameters, 739

initialization parameter file see PFILEinitialization parameters, 449–473

ADDM recommendations, 881archivelog parameters, 459–460audit-related parameters, 450–451BACKGROUND_DUMP_DEST, 178changing for session only, 262corruption-checking parameters, 470–472creating Oracle Managed Files, 922–923detecting data block corruption, 796DIAGNOSTIC_DEST, 178dynamic initialization parameters, 177file-related parameters, 453–454memory allocation parameters, 456–459modifying, 262optimal settings for, 1129Oracle licensing parameters, 461Oracle Managed Files (OMF), 248–249,

454–455performance- and diagnostics-related

parameters, 461–468Pre-Upgrade Information Tool, 428

Page 72: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1292 ■IN D E X

process-related parameters, 455recovery-related parameters, 468–470security-related parameters, 472session-related parameters, 456setting security-related initialization

parameters, 615setting, post-installation, 424undocumented initialization

parameters, 473undo-related parameters, 460–461upgrading with DBUA, 430V$SPPARAMETER data dictionary, 177viewing current values, 473–474

Initialization Parameters page, DBCA, 487initialization parameters, list of

AUDIT_FILE_DEST, 451AUDIT_SYS_OPERATIONS, 451, 458AUDIT_TRAIL, 450CLIENT_RESULT_CACHE_XYZ

parameters, 458COMPATIBLE, 452CONTROL_FILE_RECORD_KEEP_TIME, 454CONTROL_FILES, 453CONTROL_MANAGEMENT_PACK_

ACCESS, 459CURSOR_SHARING, 466DB_BLOCK_CHECKING, 471DB_BLOCK_CHECKSUM, 470DB_BLOCK_SIZE, 466DB_CACHE_SIZE, 457DB_CREATE_FILE_DEST, 455DB_CREATE_ONLINE_LOG_DEST_n, 455DB_DOMAIN, 452DB_FILE_MULTIBLOCK_READ_

COUNT, 467DB_FLASHBACK_RETENTION_

TARGET, 469DB_KEEP_CACHE_SIZE, 457DB_LOST_WRITE_PROTECT, 470DB_NAME, 451DB_nK_CACHE_SIZE, 458DB_RECOVERY_FILE_DEST, 469DB_RECYCLE_CACHE_SIZE, 458DB_SECUREFILE, 472DB_ULTRA_SAFE, 470DB_UNIQUE_NAME, 451DB_WRITER_PROCESSES, 455DIAGNOSTIC_DEST, 449FIXED_DATE, 449IFILE, 453INSTANCE_XYZ parameters, 452LARGE_POOL_SIZE, 459LDAP_DIRECTORY_SYSAUTH, 451LICENSE_MAX_SESSIONS, 461LICENSE_MAX_USERS, 461LOG_ARCHIVE_DEST_n, 459LOG_ARCHIVE_FORMAT, 460MEMORY_MAX_TARGET, 456MEMORY_TARGET, 457

NLS_DATE_FORMAT, 453OPEN_CURSORS, 456OPTIMIZER_CAPTURE_SQL_PLAN_

BASELINES, 462OPTIMIZER_DYNAMIC_SAMPLING, 463OPTIMIZER_FEATURES_ENABLE, 463OPTIMIZER_MODE, 462OPTIMIZER_USE_INVISIBLE_INDEXES, 463OPTIMIZER_USE_PENDING_

STATISTICS, 463OPTIMIZER_USE_SQL_PLAN_

BASELINES, 464OS_AUTHENT_PREFIX, 472PARALLEL_MAX_SERVERS, 467PLSQL_CODE_TYPE, 464PLSQL_OPTIMIZE_LEVEL, 468PROCESSES, 455QUERY_REWRITE_ENABLED, 465QUERY_REWRITE_INTEGRITY, 465REMOTE_LOGIN_PASSWORDFILE, 472RESULT_CACHE_XYZ parameters, 464RESUMABLE_TIMEOUT, 470SEC_XYZ parameters, 465SERVICE_NAME, 452SQL_TRACE, 467STATISTICS_LEVEL, 461TIMED_STATISTICS, 468UNDO_XYZ parameters, 460UTL_FILE_DIR, 454

INITIALIZE_REPLAY procedure, 1213INITRANS parameter, 346, 1176inline stored functions, 1074–1075inline view, 263inner join, SQL, 1234INPUT command, SQL*Plus, 130, 131input/output (I/O)

ADDM determining optimal I/O performance, 884

assigning objects to multiple buffer pools, 189

asynchronous I/O for DBWn process, 182block size and I/O performance, 1158cost model of Oracle optimizer, 1060cost of disk I/O, 186data block sizes and tablespaces, 171db file scattered read wait event, 1177disk I/O, 246, 1158–1159distribution of I/O, 1159eliminating wait event contention, 1208enforcing per-session I/O limits, 564–565excessive reads and writes on some

disks, 1160finding inefficient SQL, 1109, 1110measuring I/O performance, 1159–1161performing text input and output,

UTL_FILE, 258rebalancing ASM disk groups, 916reducing I/O contention, 1160SAME guidelines for optimal disk usage, 1160

Page 73: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1293■I N D E X

saving output to operating system, SQL*Plus, 120

saving user input in variable, SQL*Plus, 121silent option, SQL*Plus output, 115specifying directory for processing I/O, 454system performance, 1204system usage problems, 1188tuning shared pool, 1133viewing output screen by screen,

SQL*Plus, 121input/output redirection, UNIX, 56–57input/output statistics, UNIX, 82INSERT ALL statement, 661insert anomaly, 29INSERT clause, SQL*Loader, 629INSERT FIRST statement, 661INSERT INTO PARTITION clause, 287INSERT parameter, TKPROF utility, 1102INSERT statement, SQL, 1225

creating tables, 269DML statements, 263table functions, 662, 666

INSERT statement, PL/SQL, 1242inserting data into tables, 660–662Install window, Oracle Universal Installer, 420Installation Guide, Oracle, 392Installation Type window, Oracle Universal

Installer, 417installations

Instant Client software, 519–520Oracle Client software, 518Oracle Internet Directory (OID), 537

installing Oracle Database 11g, 414–422disk storage requirements, 392downloading Oracle software, 391, 414,

415–416final checklist, 413–414

DISPLAY variable, 414kernel parameters, 413swap space, 413temporary space, 413X Window System emulation, 414

installing on multihomed computer, 398installing Oracle software, 414–416, 420–422

creating response files, 421installation types, 417kernel parameters, 418operating system requirements, 418Oracle Universal Installer, 416–420restarting installation process, 418runInstaller script, 416using response files, 421–422using response files in silent mode,

421, 422using response files in suppressed mode,

421, 422using staging directory, 416

introduction, 391logging in as oracle not root, 414

memory requirements, 393OFA-compliant directory structure, 399Optimal Flexible Architecture, 393–400Oracle Enterprise Edition CDs, 414–415Oracle home directory, 396Oracle Installation Guide, 392post-installation tasks, 422–425

Oracle owner tasks, 424–425system administrator tasks, 423–424

preinstallation tasks, 400–413checking preinstallation requirements,

400–401Oracle owner tasks, 410–413system administrator tasks, 401–410

products installed with 11.1 release, 401README files, 392Release Notes and Addendums, 392reviewing documentation, 392uninstalling Oracle, 425–426

instance attribute, USERENV namespace, 580Instance Efficiency section, AWR reports, 969instance failure, benefits of archivelog

mode, 726instance mode, ADDM, 882instance performance

analyzing instance performance, 1164–1181analyzing waits with Active Session

History, 1169collecting wait event information, 1174–1175Compare Periods Report, 1206Database Control examining, 1195–1201database hit ratios, 1161–1162database load affecting, 1205database wait statistics, 1162–1163eliminating wait event contention, 1208long-running transactions affecting, 1202measuring instance performance, 1161–1194memory affecting, 1205objects with highest waits, 1170obtaining wait information, 1167–1168redo logs affecting, 1205segment-level statistics, 1173SQL statements affecting, 1194using V$ tables for wait information,

1165–1166V$ACTIVE_SESSION_HISTORY view, 1169V$SESSION_WAIT_HISTORY view, 1168wait classes and wait events, 1163wait classes and wait-related views, 1171wait events affecting, 1206

instance recoveryOracle recovery process, 804–805

instance tuning, 1129–1130, 1194–1209see also instance performance

INSTANCE_NAME parameter, 452automatic service registration, 521database instance names, 514

INSTANCE_NUMBER parameter, ADDM, 883

Page 74: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1294 ■IN D E X

instances, 173see also instance performancealtering properties of, 262creating OMF-based instance, 251database consistency on restart, 184database instance names, 514faster instance startup, 805memory allocation, 187object-oriented database model, 39specifying database or ASM instance, 452starting Oracle instance, 477–480

INSTANCE_TYPE parameter, 452ASM, 905

Instant Client software, 518, 519–520instant protection mode, Oracle Data

Guard, 800INSTR function, SQL, 1228integrated systems management, OEM, 139integrity, 306–310

control files, 175integrity constraint states, 308–309integrity constraints, 306–310integrity rules, enforcing, 465interactive mode, Data Pump, 687–688,

701–705interactive mode, UNIX, 54interinstance locking, 186internal locks, 351INTERNAL_XYZ resource plans, 559International Oracle Users Group (IOUG), 13interrupts, 80intersection operation, 21INTERSECTION operator, SQL, 1228INTERVAL clause, CREATE TABLE, 283INTERVAL keyword

collecting operating system statistics, 1061jobs, Oracle Scheduler, 999

INTERVAL parameter, AWR snapshots, 961, 964, 965

interval partitioning, 282–283interval-list partitioning, 289interval-range partitioning, 290INTO TABLE clause, SQL*Loader, 629invalid objects

manual database upgrade process, 439upgrading with DBUA, 431

INVENTORIES tableinterpreting EXPLAIN PLAN output, 1093

Inventory Contents tab, Oracle Universal Installer, 426

inverse percentile functions, SQL, 1231INVISIBLE clause, CREATE INDEX, 304invisible indexes, 303–304, 463invited addresses, securing network, 614invoker’s rights, stored procedures, 573I/O see input/output (I/O)IOSEEKTIM statistic, 1061iostat utility, UNIX, 82, 1159IOTFRSPEED statistic, 1061

IOTs (index-organized tables), 265, 278–280Flashback Transaction Query, 371, 374

IOWAIT_TICKS system usage statistic, 1182IP (Internet Protocol) address, 47, 78ip_address attribute, USERENV

namespace, 580IPS (incident packaging service), 211IPS CREATE PACKAGE command, 1027is_grant parameter, CREATE_ACL

procedure, 616ISO transaction standard, 342isolation levels, transactions, 342–346isolation property, transactions, 340%ISOPEN attribute, PL/SQL, 1246Ixora, 14

■JJava, Oracle and, 1252–1254Java Database Connectivity see JDBCJava pool, 187, 193, 1148Java programs, error handling, 540Java stored procedures, 1252java.lang class, 538JAVA_POOL_SIZE parameter, 193, 195JDBC (Java Database Connectivity),

537–542, 1253JDBC drivers, 538JDBC Supplement, Instant Client packages, 520Job Activity page, Grid Control, 159job classes, Oracle Scheduler, 996, 1011–1013job commands, RMAN, 757–758job coordinator, Oracle Scheduler, 997job queue coordination (CJQO) process,

181, 185job scheduling, 77, 554job table, Oracle Scheduler, 997job worker processes, Oracle Scheduler, 997JOB_ACTION attribute

CREATE_JOB procedure, 999embedding jobs in chains, 1010Scheduler managing external jobs, 1002Scheduler managing programs, 1006

JOB_CLASS_NAME attribute, CREATE_JOB, 1012

JOB_NAME attribute, CREATE_JOB, 999JOB_NAME parameter, Data Pump, 699,

705, 708JOB_QUEUE_PROCESSES parameter, 673, 1056jobs, Data Pump viewing, 713, 714jobs, Oracle Scheduler, 994

administering, 1000assigning job priority levels, 996belonging to job classes, 1011CREATE_JOB procedure, 1005creating, 998–999creating event-based jobs, 1010default scheduler jobs, 1019embedding jobs in chains, 1010frequency (FREQ keyword), 999

Page 75: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1295■I N D E X

grouping sets of jobs, 996managing, 998–1000managing external jobs, 1002–1006monitoring Scheduler jobs, 1017–1019prioritizing jobs, 1016–1017purging job logs, 1019repeat interval (INTERVAL keyword), 999resource plans and windows, 1013specifying repeat interval, 999–1000types of Scheduler jobs, 995–996

JOB_TYPE attributeCREATE_JOB procedure, 999embedding jobs in chains, 1010Scheduler managing external jobs, 1002Scheduler managing programs, 1006

join command, UNIX/Linux, 67join operations, 21

heuristic strategies for query processing, 1046

using correct joins in WHERE clauses, 1066join views, 313joins, 1233–1234

bitmap join indexes (BJI), 1069Cartesian joins, 1068, 1232CBO choosing join method, 1052CBO choosing join order, 1053equi joins, 1066, 1233EXPLAIN PLAN tool examples, 1094guidelines for creating indexes, 297hash join, 1052, 1068indexing strategy, 1071inner join, 1234lossless-join dependency, 34MERGE join, 1068natural join, 1233nested loop join, 1052outer join, 1234selecting best join method, 1068selecting best join order, 1070self join, 1233sort-merge join, 1052

JVM (Java Virtual Machine), 1252

■Kkeep buffer pool, 189, 1146, 1147KEEP clause, ALTER TABLESPACE, 231, 232keep pool, 457KEEP procedure, DBMS_SHARED_POOL, 1138KEEP XYZ clauses, BACKUP command, RMAN,

780, 781kernel, UNIX, 45

preinstallation, 401, 402, 404–406, 413key-compressed indexes, 301keys, 26

indexes compared, 297multivalued/composite keys, 31tables, 20

keyword variables see shell variables, UNIXkill command, UNIX/Linux, 75, 620

KILL SESSION command, 620KILL_JOB command, Data Pump, 686, 703,

704, 713KILL_SESSION switch group, 555, 561, 565ksh (Korn shell), 45

see also shells, UNIX

■L-L option (no-prompt logon), SQL*Plus, 115label-based security policy, 586large objects, ORDBMS model, 40large pool, 187, 193, 1148LARGE_POOL_SIZE parameter, 193, 195, 459LAST_DDL_TIME value, 329latch contention

eliminating contention, 1208, 1209parsing, 1141reducing parse-time CPU usage, 1175soft parsing, 1141tuning shared pool, 1133wait events, 1206

latch free wait events, 1179–1180latch hit ratio, 1179latch rate, 1183latches, 343, 351, 1179

library cache latch, 1180shared pool latch, 1180tuning shared pool, 1133V$LATCH view, 1168

LDAP (Lightweight Directory Access Protocol), 512, 534, 602, 603

LDAP_DIRECTORY_SYSAUTH parameter, 451, 615

LD_LIBRARY_PATH variable, 446, 475leaf blocks, B-tree index, 298least recently used (LRU) algorithm, 181, 188Legato Single Server Version (LSSV), 746LENGTH function, SQL, 1228LGWR see log writerlibrary cache, 191

aging out SQL statements, 1134avoiding ad hoc SQL, 1141measuring library cache efficiency, 1137–1138optimizing library cache, 1138–1142pinning objects in shared pool, 1142–1143tuning shared pool, 1133–1134

library cache hit ratio, 1137library cache latch, 1180LICENSE_MAX_XYZ parameters, 461licensing, 149, 948Lightweight Directory Access Protocol see LDAPlightweight jobs, Oracle Scheduler, 996,

1000–1002LIKE operator, SQL, 1224, 1227limited analysis mode, Segment Advisor, 930limits.conf file, 406LINESIZE variable, SQL*Plus, 108linking files, UNIX, 57–58links see database links

Page 76: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1296 ■IN D E X

Linux, 43, 44, 45see also UNIX

Linux commands see UNIX commandsLIST ARCHIVELOG ALL command, RMAN, 761LIST BACKUP command, RMAN, 760, 810LIST CHAINED ROWS clause, 279LIST command, RMAN, 810LIST command, SQL*Plus, 128LIST COPY command, RMAN, 760, 810LIST FAILURE command, Data Recovery

Advisor, 830LIST GLOBAL SCRIPT NAMES command,

RMAN, 761LIST INCARNATION command, RMAN, 823list partitioning, 284, 288–289LIST SCRIPT NAMES command, RMAN,

750, 761listener commands, 522–523listener.ora file, 206, 520, 521, 523

ADMIN_RESTRICTIONS parameter, 614cloning databases with RMAN, 835dynamic service registration and, 183post-upgrade actions, 441removing EXTPROC functionality, 614

listeners, 524automatic service registration, 521–522BLOCKED status, 522connecting to Oracle, 206default password, 524described, 513dynamic service registration, 183establishing Oracle connectivity, 517failed attempt to stop, 524lsnrctl checking listener status, 521lsnrctl commands, 521–523multiple listeners, 523Oracle networking and, 520QUEUESIZE parameter, 523READY status, 522script to start and stop, 500securing, 614setting password for, 524–525setting queue size, 523UNKNOWN status, 522upgrading with DBUA, 432

listing commands, RMAN, 760–761listing files, UNIX, 58LIVE workspace, 387ln command, UNIX/Linux, 58load balancing, ASM, 901LOAD DATA keywords, SQL*Loader, 629LOAD parameter, SQL*Loader, 634Load Profile section, AWR reports, 969, 1205LOAD WHEN clause, 648loading data see ETL (extraction,

transformation, loading)LOAD_PLANS_FROM_CURSOR_CACHE

function, 1082LOAD_PLANS_FROM_SQLSET function, 1081

loads column, V$SQL view, 1109load-then-transform method, ETL process, 626LOBs (large objects)

data block sizes and tablespaces, 171transportable tablespaces, 716treating large objects as SecureFiles, 472

local commands, SQL*Plus, 103LOCAL extent management, 219, 220local external jobs, 1002local naming method, connections, 525–529local partitioned indexes, 1073local servers, copying files from/to, 254LOCAL value, extent management, 221localconfig command, 904locally managed tablespaces, 172

AUTOALLOCATE option, 219automatic segment space management, 219managing storage extents, 222MAXEXTENTS parameter, 221migrating from dictionary-managed, 217proactive space alerts, 226specifying default storage parameters, 220using bigfile tablespaces, 237

locally partitioned indexes, 302, 303LOCATION parameter, external table layer, 648location transparency

Oracle Net Services features, 511using synonyms, 325

lock (LCKn) process, 186lock conversion, 348lock escalation, 347, 348LOCK TABLE statement, 263, 350, 351locking

committing transactions, 339data concurrency, 199, 341database authentication, 597, 598exclusive lock mode, 199explicit locking in Oracle, 351–352explicit table locking, 350–351how Oracle processes transactions, 197interinstance locking, 186locking issues, 1189locking-related views, 353optimistic locking methods, 347Oracle locking, 347, 348page-level locking, 348pessimistic locking methods, 347queries, 349SELECT statement, 349serializable isolation level, 344, 346share lock mode, 199temporary tables, 278

locksblocking locks, 351–352data dictionary locks, 351Database Control managing session locks,

354–355DDL locks, 350deadlocks, 352

Page 77: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1297■I N D E X

distributed locks, 351DML locks, 349–350exclusive locks, 349granularity, 348identifying sessions holding locks, 353identifying source of lock, 354internal locks, 351latches, 351locks on suspended operations, 385managing long transactions, 386managing Oracle locks, 353, 355Oracle lock types, 348–350Oracle locks, 347releasing locks, 348row exclusive locks, 349row-level locks, 349table-level locks, 349using SQL to analyze locks, 353–354views analyzing locks, 354

log buffer space wait event, 1180LOG FILE parameter, 648log file switch wait event, 1180log file sync wait event, 1181log files

alert log file, 16, 177archiving redo log files, SQL*Plus, 135create materialized view log, 318Data Pump utilities, 681flashback database logs, 854managing logging of redo data, 227Pre-Upgrade Information Tool, 428RMAN redirecting output to, 747SQL*Loader utility, 638–639

LOG parameterRMAN redirecting output to log files, 747SQL*Loader control file, 635

log sequence-based recoveryFlashback Database example, 860incomplete recovery using RMAN, 821log%t_%s_%r format, archived redo logs, 823

log writer (LGWR), 180, 182–183background process, 982committing transactions, 198, 199group commits, 199how Oracle processes transactions, 197redo log buffer, 192starting Oracle instance, 479

LOG_ARCHIVE_DEST parameter, 738LOG_ARCHIVE_DEST_n parameter, 459,

485, 492flash recovery, 735, 736, 738, 739Oracle Managed Files (OMF), 250, 925Oracle Streams, 673

LOG_ARCHIVE_DUPLEX_DEST parameter, 738LOG_ARCHIVE_FORMAT parameter, 460,

492, 823LOG_ARCHIVE_MAX_PROCESSES

parameter, 184LOG_ARCHIVE_MIN_SUCCEED_DEST

parameter, 729

LOG_ARCHIVE_START parameter, 493LOG_BUFFER parameter, 192, 196, 1180Logfile parallel write wait event, 1204LOGFILE parameter, Data Pump, 690, 706LOG_FILE_NAME_CONVERT parameter,

RMAN, 834, 836logging

default Oracle logging, 588Flashback Transaction Query, 374supplemental logging, 842

LOGGING clause, CREATE TABLE, 227logging in/out, Oracle

enabling/disabling password case sensitivity, 465

FAILED_LOGIN_ATTEMPTS parameter, 550, 599

locking accounts, 598performance-related issues, 1142sec_max_failed_login_attempts

parameter, 615security when logging in as different

user, 620settings from CREATE PROFILE

statement, 548Single Sign-On feature, 603specifying maximum number of attempts

at, 465logging in/out, UNIX, 46, 48

remote login (Rlogin), 78running processes after logging out, 75

logging in, SQL*Plus, 103, 115LOGGING_LEVEL attribute, 1012, 1019LOGGING_XYZ values, DBMS_

SCHEDULER, 1012LOG_HISTORY attribute, 1012logical backups, 728logical change record (LCR), Oracle

Streams, 671logical database design, 24–34

converting into physical design, 34, 35entity-relationship (ER) modeling, 24–26ER modeling tools, 34normal forms, 29–34normalization, 28–29transforming ER diagrams into relational

tables, 35logical database structures, 165–172

data blocks, 166–169extents, 166, 169links to datafiles, 174schema, 165segments, 166, 169tablespaces, 166, 170–172

logical DBA, 8LOGICAL keyword, RMAN, 756logical operators, SQL, 1227logical reads, 1144

finding inefficient SQL, 1109logical standby databases, 799logical time stamp, 199

Page 78: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1298 ■IN D E X

logical unit number (LUN), 901Logical Volume Manager (LVM), 88, 170, 900logical volume stripe sizes, disk I/O, 1159logical volumes, UNIX, 88LOGICAL_READS_PER_XYZ parameters,

549, 553.login file, UNIX, 54, 55, 406login screen, Database Control, 142login scripts, changing preinstallation, 406login.sql file, 110–111, 114, 119LogMiner utility, 207, 841–847

analyzing redo logs, 845–847archived redo logs, 184correcting human error, 802description, 808extracting data dictionary, 843LogMiner session, 844–845naming transactions, 340precision recovery using, 841supplemental logging, 842–843undoing SQL statements, 373

logon/logoff triggers, 591Logout page, Grid Control, 159logs see log filesLONG variable, SQL*Plus, 108long-term backups, RMAN, 780lookup tables, 35LOOP/END LOOP statements, PL/SQL, 1243looping, PL/SQL, 1243–1244looping, UNIX, 72–73lossless-join dependency, 5NF, 34lost-update problem, 341, 345LOWER function, SQL, 302, 1228LOW_GROUP resource consumer group,

558, 565LPAD function, SQL, 1228lread column, sar command, 83LRU (least recently used) algorithm, 181, 188ls command, UNIX/Linux, 58, 59LSNRCTL STATUS command, ASM, 906lsnrctl utility, Oracle listener, 516, 520

checking listener status, 521listener commands, 522–523set password clause, 524

LUN (logical unit number), 901LVM (Logical Volume Manager), 88, 170, 900lwrit column, sar command, 83

■M-M option (markup), SQL*Plus, 115M:M (many-to-many) relationship, 26machine name, UNIX, 47mail program, UNIX, 71main memory, 186–187maintenance, 1019–1022

quiescing databases, 505man command, UNIX/Linux, 48, 50Manage Policy Library page, Database

Control, 151

MANAGE SCHEDULER privilege, 997, 1013, 1015

manageability monitor see MMONmanageability monitor light (MMNL), 181,

185, 971managed files

Oracle Managed Files (OMF), 247–253management advisors see advisorsmanagement advisory framework see advisory

frameworkManagement Agent, OEM, 154, 156Management Options window

Database Upgrade Assistant, 432DBCA creating database, 487

Management Pack Access page, Database Control, 149

Management Packs, licensing, 149Management Repository, OEM, 154, 157, 159Management Service (OMS), 154, 157Management System page, Grid Control, 159manager_policy security policy, 585managing resources see resource managementmanaging users, 544, 619, 620manual database creation, 474–486

creating data dictionary objects, 485creating database, 480–485init.ora file, 475–477privileges, 475quick way to create database, 485–486setting OS variables, 474–475starting Oracle instance, 477–480

manual database upgrade process, 427, 434–441

backing up database, 437catdwgrd.sql script, 434, 442catupgrd.sql script, 434, 438, 440catuppst.sql script, 438, 439checking for invalid objects, 439copying init.ora (parameter) file, 437creating spool file, 434ending spool file, 441list of steps for upgrading, 434ORACLE_HOME variable, 437password file, 437Post-Upgrade Status tool, 440–441Pre-Upgrade Information Tool, 435–437recompiling and validating invalidated

objects, 439restarting instance, 438restarting new database, 441running post upgrade actions script, 439running upgrade actions script, 438starting up new database, 437–438STARTUP UPGRADE command, 437Sysaux tablespace, 438upgrade and downgrade scripts, 434upgrade.log spool file, 435utlrp.sql script, 434, 439, 440utlu111i.sql script, 434, 435

Page 79: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1299■I N D E X

utlu111s.sql script, 434, 440utluppset.sql script, 434

manual management mode, PGA memory, 195manual optimizer statistics collection, 900MANUAL parameter, segment space

management, 217manual PGA memory management, 894manual segment shrinking, 928–929manual shared memory management, 894manually cloning databases, 839–840many-to-many (M:M) relationship, 26MAP_ALL procedure, 994mapping data, Data Pump, 693, 709–711mapping files, 993–994mapping structures, 993MARKUP command, SQL*Plus, 134markup option (-M), SQL*Plus, 115master encryption key, 607master process, Data Pump, 685–686master tables

Data Pump, 685, 686materialized views, 314

materialized views, 314–320aggregations, 315creating, 317–320data manipulation statements, 314DBA_MVIEWS view, 333dropping, 320EXPLAIN_XYZ procedures, 317improving SQL processing, 1077indexes, 314optimizer statistics, 320optimizing, 315privileges, 571query rewriting, 315refresh modes/options, 316refreshing, 314, 316–317rewrite integrity, 316REWRITE_OR_ERROR hint, 315SQL Access Advisor, 320–324TUNE_MVIEW procedure, 317using DBMS_MVIEW package, 317view resolution, 314

MAX function, SQL, 1229MAX_AUTO_SQL_PROFILES parameter, 1118MAX_DUMP_FILE_SIZE parameter, 958, 1101MAX_ESTIMATED_EXEC_TIME directive, 943MAXEXTENTS parameter, 221MAX_IDLE_BLOCKER_TIME parameter,

560, 561MAX_IDLE_TIME parameter, 560, 561maximum availability mode, Oracle Data

Guard, 800maximum extents errors, 383maximum performance mode, Oracle Data

Guard, 800maximum protection mode, Oracle Data

Guard, 800MAX_LIFETIME_PER_SESSION parameter, 532

MAXSETSIZE parameter, RMAN backups, 781MAX_SIZE parameter, DRCP, 533MAXSIZE parameter, tablespaces, 224MAX_SQL_PROFILES_PER_EXEC

parameter, 1117MAX_THINK_TIME parameter, DRCP, 533MAXTHR statistic, 1061MAX_USES parameter, Scheduler, 1003MAX_USES_PER_SESSION parameter,

DRCP, 532MBRC statistic, 1061MCP (Master Control Process), 685–686md_backup/md_restore commands, 911,

912, 913media corruption, detecting, 795media failures, 802, 803media families, Oracle Secure Backup, 789Media Management Layer, (MML), 742,

744, 745media management solutions, 745, 746media managers

Oracle Secure Backup, 785RMAN, 743

media recovery, 806–808block media recovery (BMR), 808, 864–865data repair, 804

media recovery scenarioscontrol file recovery, 824–828datafile recovery, 818–820

without backup, 828–829incomplete recovery, 820–824tablespace recovery, 817–818whole database recovery, 814–817

media server, 786medium transport element (mte), 789memory

see also bufferscost of disk I/O, 186creating SPFILE or PFILE from, 497in memory metrics, 951instance performance, 1205least recently used (LRU) algorithm, 188measuring process memory usage, 1190–1191memory allocation, 187modifying data, 181operating system physical memory, 1158program global area, 187, 193–196SHOW SGA command, 117system global area (SGA), 187, 187–193tuning buffer cache, 1144–1148tuning Java pool, 1148tuning large pool, 1148tuning Oracle memory, 1132–1152

hard parsing and soft parsing, 1135–1143tuning PGA memory, 1148–1152tuning shared pool, 1133–1135tuning streams pool, 1148understanding main memory, 186–187virtual memory, 1158

Page 80: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1300 ■IN D E X

Memory Access Mode, 1198Memory Advisor, 976, 1132, 1145, 1178memory allocation, 194, 457memory allocation parameters, 456–459memory buffers, 187, 188

CLEAR BUFFER command, SQL*Plus, 115writing data to disk, 183

memory managementautomatic, 456, 195–196, 894–897

PGA memory management, 1148–1149operating system, 1186

memory management, UNIX, 81, 82memory manager (MMAN), 181, 185memory requirements

ensuring sufficient memory allocation, 445estimating, preinstallation, 400installing Oracle Database 11g, 393

memory structures see Oracle memory structures

Memory window, DBCA, 488MEMORY_MAX_TARGET parameter, 456, 895,

896, 897MEMORY_REPORT function, 1123MEMORY_TARGET parameter, 195, 457

adjusting memory allocation, 1132automatic memory management, 456, 895,

896, 897defining maximum value of, 456ensuring sufficient memory allocation, 446managing result cache, 1120managing/monitoring database, 214sizing shared pool, 1142system global area (SGA), 187

MERGE join, 1068MERGE PARTITION command, 291MERGE statement, 263, 656, 658–660

upserts, 626, 658workspaces, 388

mergingsort-merge join, 1052

messagesobject-oriented database model, 39Oracle Streams Advanced Queuing, 670sending message to screen, SQL*Plus, 121

metadatadata dictionary, 203, 204DBMS_METADATA package, 294, 680exporting dictionary metadata for

tablespaces, 718exporting using Data Pump, 721exporting using external tables, 653importing from dump file, 719importing using Data Pump, 723RMAN, 744, 766

metadata filtering, 692METADATA_ONLY value, Data Pump, 691,

692, 695

MetaLinkdatabase security, 617DBA training, 15linking Database Control to, 150

METHOD_OPT attribute, 1055, 1086methods

object-oriented database model, 39ORDBMS model, 40

metric groups, 950metrics, 950–952

baseline metrics, 953–959data dictionary views, 958

midrange servers, 45migrating databases to ASM, 919–921Millsap, Cary, 1145, 1161MIN function, SQL, 1229MINEXTENTS parameter, 221, 957MINIMIZE XYZ options, RMAN, 777MIN_SIZE parameter DRCP, 533MINUS operator, SQL, 1228mirroring

ASM mirroring, 901, 909, 914fast mirror resync feature, ASM, 908–909mirroring vs. multiplexing, 982RAID 0+1: striping and mirroring, 90RAID 1: mirroring, 89

MIXED_WORKLOAD_PLAN resource plan, 558mkdir command, UNIX/Linux, 62mkstore command, creating Oracle Wallet,

241, 609MML (Media Management Layer), RMAN, 742,

744, 745MMNL (manageability monitor light), 181,

185, 971MMON (manageability monitor), 181, 185

ABP process, 1022AWR statistics, 959database metrics, 950in memory metrics, 951managing ADDM, 881proactive tablespace alerts, 956running ADDM, 885saved metrics, 952tablespace space alerts, 226

MODE parameter, LOCK TABLE statement, 351MODEL clause, transforming data, 656,

667–670modeling, entity-relationship (ER), 24–26modes

archivelog mode, 184, 459normal mode, 502OPTIMIZER_MODE parameter, 462restricted database mode, 501

MODIFY_SNAPSHOT_SETTINGS procedure, 882

monitoring, 138DBA role, 5, 15efficient monitoring, 213–214system monitor (SMON) process, 184

Page 81: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1301■I N D E X

MONITORING USAGE clause, 305more command, UNIX/Linux, 52, 58MOUNT option, STARTUP command

configuring Flashback Database, 855starting ASM instances, 907starting up database from SQL*Plus, 498

mount points, 86, 394creating databases, 174creating, preinstallation, 404OFA guidelines, 394, 396, 399, 404

mounting database, 482, 492MOVE command, 273, 275MOVE TABLESPACE option, 935moving-window aggregate functions, SQL, 1231MREADTIM statistic, 1061msps column, iostat command, 82mte (medium transport element), 789MTTR (mean time to recover), 805MTTR Advisor, 976, 981, 1132multicolumn statistics, 1058multidimensional arrays, 668multiplexing

backup guidelines, 729Connection Manager feature, 512flash recovery area, 735mirroring vs. multiplexing, 982online redo logs, 982redo log files, 176, 182, 184, 444, 729session multiplexing, 180shared server architecture, 512

multitable inserts, 626, 660–662MULTITHREADING parameter,

SQL*Loader, 641multivalued dependency, 4NF, 34multiversion concurrency control system, 347manual upgrade process, 429mv command, UNIX/Linux, 59

■NNAME parameter, ALTER SESSION, 385NAMES parameter,

TRANSACTION_BACKOUT, 379naming connections, 525

directory naming method, 534–537easy connect naming method, 529–530external naming method, 533–534local naming method, 525–529

naming context, 536NAS (Networked Attached Storage), 94natural join, SQL, 21, 1233NCA Configuration Assistant), 516, 528–529NDMP (Network Data Management

Protocol), 788nested loop (NL) method, 1068nested loop join, 1052nested subquery, 263nested table, abstract data types, 1240Net Configuration Assistant see NCA

Net Service Name Configuration page, 528net service names, 100, 525Net Services see Oracle Net Servicesnetca.rsp response file template, 422netstat utility, UNIX, 85network administration files, 173Network Configuration window, DBUA, 432Network Data Management Protocol

(NDMP), 788network directory, ORACLE_HOME, 395network export, Data Pump initiating, 698Network Information Service (NIS), 533, 534network mode, Data Pump, 679network monitoring, UNIX, 85network performance, 1160Network wait class, 1163, 1164Networked Attached Storage (NAS), 94NetWorker, 745networking see Oracle networkingNETWORK_LINK parameter, 698, 711–713, 717networks

fine-grained network access control, 615–618

problems affecting performance, 1203securing, 614

NEVER option, materialized views, 317NEWFILE procedure, DBMS_LOGMNR, 844NEW_LINE procedure, UTL_FILE, 257NEWPAGE variable, SQL*Plus, 108NEXT_EXTENT storage parameter, 221, 222nextval pseudo-column, sequences, 327NFS file systems, 394NI column, top command, 84NIS (Network Information Service), 533, 534NLS_DATE_FORMAT parameter, 453NLS_TERRITORY parameter, 453NO LOGGING option, backup guidelines, 729NO SALT option, ENCRYPT keyword, 608no workload mode, 1061noarchivelog mode, 176, 491, 492

see also archivelog modepartial database backups, 794reasons for using, 726whole database backups, 790

NOAUDIT keyword, 589nobody, verifying unprivileged user exists, 408nocascade/nocascade_force options, 869noclobber shell variable, 57noconflict_only option, 869nodes, B-tree index, 298NOFILENAMECHECK option, RMAN, 835nohup option, shell programs, 75NOLOG option, connectionless SQL*Plus, 101NOLOGFILE parameter, Data Pump, 691, 706NOLOGGING clause

CREATE TABLESPACE statement, 227CREATE TABLE AS SELECT command, 273deriving data from existing tables, 657SQL*Loader utility, 644

Page 82: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1302 ■IN D E X

nologging option, redo log buffer, 193NOMOUNT option, STARTUP command, 477

starting ASM instances, 907starting up database from SQL*Plus, 498

NONE value, AUDIT_TRAIL parameter, 587nonprefixed indexes, 1073nonrepeatable (fuzzy) read problem

data concurrency, 342isolation levels, 344, 345, 346

nonunique indexes, 297no-prompt logon option (-L), SQL*Plus, 115NO_RESULT_CACHE hint, 1122, 1125normal forms, 29–34

Boyce-Codd normal form (BCNF), 33Fifth Normal Form (5NF), 34First Normal Form (1NF), 30–31Fourth Normal Form (4NF), 34Second Normal Form (2NF), 31–33Third Normal Form (3NF), 33

normal mode, Oracle optimizer, 1111NORMAL option, SHUTDOWN command, 502normal program conclusion, 338normal redundancy level, ASM, 909, 914normalization, 28–29

attribute dependence on primary key, 31, 33denormalization, 34functional dependencies, 33lossless-join dependency, 34multivalued dependencies, 34non-normalized data, 30partial dependencies, 31performance issues, 36repeating groups, 30

NOT EXISTS operator, subqueries, SQL, 1237NOT NULL constraint, 306, 307%NOTFOUND attribute, PL/SQL, 1246Notification Methods page, Database

Control, 148notification rules, setting, 955NOWAIT option, 339, 351NOWORKLOAD keyword, 1061null values, 269, 306NULLIF parameter, SQL*Loader, 642NUMBER data type, 1222number functions, SQL, 1229numberofxids parameter, 869NUM_CPUS system usage statistic, 1181numeric data types, 1222NUMTXNS parameter, 379NUMWIDTH variable, SQL*Plus, 108NVL function, SQL, 1230

■Oob host, Oracle Secure Backup, 788object database management system

(ODBMS), 38, 39object privileges, 570–573object tables, 265, 1239object transparency, 325

object types see abstract data typesobject-level audit, 587object_name parameter, 594object-oriented databases, 39–40object-oriented programming, 1239object-relational database management system

see ORDBMSobject-relational database model, 38, 39–40objects, 329

see also database objectsaliases for objects see synonymsobject-oriented database model, 39

object_schema parameter, 594observiced process, 788obsolete files, 758, 759, 762obtar command-line tool, 790obtool command-line interface, 788OCA (Oracle Certified Associate), 10, 12OCI_RESULT_CACHE_MAX_XYZ

parameters, 1126OCM (Oracle Certified Master), 10, 12OCP (Oracle Certified Professional), 10, 12octal numbers method, 60, 61ODBC Supplement, Instant Client packages, 520ODBMS (object database management

system), 38, 39ODS user, granting privileges, 572OE (order entry) schema, 1221OEM (Oracle Enterprise Manager),

136–161, 206accessing key performance data, 207accessing UNIX system, 46administering Database Resource Manager,

566–567Application Server Control, 139benefits of RMAN, 743benefits of using OEM, 137–139database management, 137description, 516installing OID, 537managing undo data, 365–366performance, 206Resource Plan Wizard, 556running SQL Tuning Advisor, 1115security, 138setting tablespace alert thresholds, 227using OEM to collect optimizer statistics,

1064–1065versions, 137, 139viewing ADDM reports, 885viewing explain statements, 1090

OEM Database Control see Database ControlOEM Grid Control see Grid ControlOEM Management Agent, 154, 156OEM Management Repository, 154, 157, 159OEM Management Service, Grid Control, 159OFA (Optimal Flexible Architecture), 393–400

locating files, database creation, 445OFA-compliant directory structure, 399

Page 83: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1303■I N D E X

OFA guidelines, 393–394administrative files, 397ADR (Automatic Diagnostic Repository), 396database files, 398–400datafiles, 396directories, 394, 395, 396flash recovery area, 396, 400installing on multihomed computer, 398mount points, 394, 404naming conventions, 393, 398product files, 397

OFF option, SPOOL command, SQL*Plus, 120OFFLINE clauses, tablespaces, 228, 229OFFLINE IMMEDIATE clause, media

failures, 803OID (Oracle Internet Directory), 534–535

enterprise user security, 611installing, 537making database connections, 535–536organization of, 536–537

OID option, Data Pump Import, 711oinstall (default name), 407, 408OL$/OL$HINTS/OL$NODES tables, 1078OLTP databases

block sizes and tablespaces, 172DB_BLOCK_SIZE parameter, 466DML statements, 263indexing strategy, 1071program global area (PGA), 193system global area (SGA), 187table compression, 275, 1076using indexes, 296write ahead protocol, 199

OMF (Oracle Managed Files), 247–253accidentally dropping datafiles, 248adding tablespaces, 927adding tablespaces and datafiles, 253benefits of using, 248, 922bigfile tablespaces (BFTs), 236control files, 250, 251, 252, 924creating database, 250–253, 924–927creating OMF files, 248–249, 251, 922–923creating OMF-based instance, 251creating Sysaux tablespace, 239, 252creating/locating tablespaces, 252datafiles, 250, 924deleting unwanted files, 734description, 174file management, 922–927file types, 250, 924flash recovery area, 738init.ora file, 250initialization parameters, 248–249, 454–455,

922–923limitations, 248locating OMF files, 926–927naming conventions, 922, 923naming files, 248, 249operating system files, 248

redo log files, 250, 252, 924setting up file location parameters, 250, 924small and test databases, 248specifying default location for OMF files, 455starting database instance, 925

OMF parametersDB_CREATE_FILE_DEST parameter, 247,

249, 250, 923DB_CREATE_ONLINE_LOG_DEST_n

parameter, 247, 249, 250, 923DB_RECOVERY_FILE_DEST parameter, 247,

249, 250, 923OMS (Oracle Management Service), 154, 157ON clause, BREAK command, SQL*Plus, 122ON COMMIT DELETE/PRESERVE ROWS

options, 278ON COMMIT mode, refreshing materialized

views, 316, 319ON DEMAND mode, refreshing materialized

views, 316ON PREBUILT TABLE clause, 319one-pass sort, 1149one-to-many (1:M) relationship, 26one-to-one (1:1) relationship, 26online backups, RMAN, 742, 775online capabilities, Oracle Database 11g,

933–945data redefinition, 935–941data reorganization, 933–935database quiescing for online maintenance,

944–945dynamic resource management, 941–943online database block-size changes, 943–944suspending database, 945

online redo log files, 175, 868, 981–985creating database, 481creating/locating OMF files, 926flash recovery area, 735making whole closed backups, 791OMF file-naming conventions, 249, 923

online segment shrinking, 927–928online table redefinition, 935, 936–941

activity during redefinition process, 939checking for errors, 940completing redefinition process, 940–941copying dependent objects, 939creating temporary tables, 937errors occurring during, 941redefining temporary tables, 938synchronizing interim and source tables, 940verifying eligibility of tables, 937

ONLY keyword, encrypting RMAN backups, 782open account, database authentication, 597open backups, 726, 728, 792–793OPEN clause, explicit cursors, PL/SQL, 1245OPEN option, STARTUP command, 499open recovery, 807OPEN_CURSORS parameter, 194, 456OPEN_WINDOW procedure, 1015

Page 84: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1304 ■IN D E X

operating system authentication, 601connecting to RMAN, 746database security, 612Oracle Net, 602

operating system copies, RMAN, 752operating system files

extents, 220opening operating system file, 257Oracle Managed Files (OMF), 248tablespaces, 215UTL_FILE package, 256–259

Operating System Statistics section, AWR reports, 970

operating systemsapplying OS packages, 403audit parameters, 450, 451automatic database startup on OS restart, 499bigfile tablespaces, 237checking memory and physical space, 403checking OS packages, 403checking version, 402collecting statistics, 1060–1062, 1086creating additional accounts, 424creating groups, 406–408disk I/O performance, 1158manual collection of statistics, 1054memory management, 1186

evaluating performance, 1158Oracle installation requirements, 418preinstallation checks, 401saving output to, 120setting permissions, 613setting upper limit for OS processes, 455UNIX/Linux for DBA, 43–95usage of commands from SQL*Plus, 105,

115, 119verifying software, 402–403

operationsgrouping SQL operations, 1234–1236resumable database operations, 383, 385table operations, 267

operator class, Oracle Secure Backup, 788operators

set operators, 263SQL/XML operators, 1249

operators, SQL, 1227–1228LIKE operator, 1224, 1227

OPS$ prefix, authenticated usernames, 472OPS$ORACLE database account, 602opt parameter, COPY command, SQL*Plus, 133optimal mode operation, 194optimal sort, 1149optimistic locking methods, 347optimization

see also query optimizationCBO (Cost-Based Optimizer), 1047–1053cost-based query optimization, 1044–1046materialized views, 315PLSQL_OPTIMIZE_LEVEL parameter, 468

optimization phasequery processing, 1043–1046SQL processing steps, 1133

optimizer see CBO (Cost-Based Optimizer)optimizer hints, 1051optimizer statistics

automated tasks feature, 211automatic collection, 209, 212, 213, 897–899default values, 1050description, 1049dynamic collection of, 1050extended optimizer statistics, 1058–1060manual collection, 900materialized views, 320Oracle recommendation, 898providing statistics to optimizer, 1047–1049using OEM to collect optimizer statistics,

1064–1065when manual collection is required, 1054

OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES parameter, 462, 1081

OPTIMIZER_DYNAMIC_SAMPLING parameter, 463, 1063

OPTIMIZER_FEATURES_ENABLE parameter, 315, 463, 1078, 1080, 1218, 1219

OPTIMIZER_MODE parameter, 462, 1049–1050, 1051, 1068

OPTIMIZER_USE_INVISIBLE_INDEXES parameter, 463

OPTIMIZER_USE_PENDING_STATISTICS parameter, 463, 1057

OPTIMIZER_USE_SQL_PLAN_BASELINES parameter, 464, 1082

OPTIM_PEEK_USER_BINDS parameter, 1087OPTIONS attribute,

GATHER_DATABASE_STAT, 1055OPTIONS clause, SQL*Loader, 633OPTIONS parameter,

TRANSACTION_BACKOUT, 380, 869OR REPLACE clause, 313ORA$AUTOTASK_HIGH_SUB__PLAN resource

plan, 559ORA$AUTOTASK_SUB__PLAN resource

plan, 558Oracle

dual table, necessity for, 102Java and, 1252–1254product_user_profile table, 103, 104setting environment for SQL*Plus, 98

Oracle administrative files see administrative filesOracle Advanced Security, 535, 603, 618Oracle advisors see advisorsOracle Application Express, 401Oracle Application Server Single Sign-On, 535Oracle Backup Solutions Program (BSP), 745Oracle Backup Web Interface, 785, 788Oracle base directory, 395, 399, 409Oracle blocks see data blocks

Page 85: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1305■I N D E X

Oracle by Example (OBE), 14Oracle Certification Program, 11Oracle Certified Associate (OCA), 10, 12Oracle Certified Master (OCM), 10, 12Oracle Certified Professional (OCP), 10, 12Oracle Change Management Pack, 149, 949oracle class, Oracle Secure Backup, 788Oracle Client, 391, 517–519Oracle Cluster Synchronization Service (CSS),

902–904Oracle Collaboration Suite, 535Oracle Configuration Management Pack,

149, 949Oracle Configuration Manager, 401, 1029Oracle Connection Manager, 512Oracle connectivity see connectivityOracle context, 536Oracle data dictionary see data dictionaryOracle Data Guard

see also standby databasesavoiding data center disasters, 802DB_LOST_WRITE_PROTECT parameter, 470creating Oracle Wallet, 241data protection modes, 800high-availability systems, 798standby databases and, 799–800

Oracle Data Guard Broker, 799Oracle Data Migration Assistant, 427Oracle Data Pump utility see Data Pump utilities

(Export, Import)Oracle data types, 1222–1223Oracle database, 173

connecting to, 205connecting using CONNECT command, 100efficient managing and monitoring, 213–214ensuring database compatibility, 452preparing database for upgrading, 430providing name for database service, 452remotely connecting to, 98script to start and stop, 500setting database name, 451setting environment for SQL*Plus, 98starting SQL*Plus session from command

line, 98–100Oracle Database 11g

downgrading from, 441downloading Oracle software, 415–416initialization parameters, 449–473

viewing current values, 473–474installing Oracle software, 416–420OFA-compliant directory structure, 399Oracle Enterprise Edition CDs, 414–415sample schemas, 1221–1222SGA and PGA memory allocations, 456

Oracle Database 11g architecture, 165–214automated tasks feature, 211automatic database management, 208–209common manageability infrastructure,

210–213

communicating with database, 205–207efficient managing and monitoring, 213–214

Oracle Database 11g CD/Client CD, 414Oracle Database 11g installation see installing

Oracle Database 11gOracle Database 11g upgrade see upgrading to

Oracle Database 11gOracle Database Two-Day DBA course, 14Oracle Database Configuration Assistant

see DBCAOracle database connectivity see connectivityOracle database files see database filesOracle Database Resource Manager see

Database Resource ManagerOracle database structures, 165–178

alert log file, 177backup files, 178control files, 173, 174–175data blocks, 166–169datafiles, 173–174extents, 166, 169initialization files, 173logical database structures, 165–172network administration files, 173password file, 177physical database structures, 173–176redo log files, 173, 175–176segments, 166, 169SPFILE (server parameter file), 177tablespaces, 166, 170–172trace files, 178

Oracle database transactions see transactionsOracle database upgrade see upgrading to

Oracle Database 11gOracle Database Vault, 401, 430Oracle datafiles see datafilesOracle DBA see DBA (database administrator)Oracle Diagnostic Pack, 149, 949Oracle Directory Manager, 516, 535Oracle directory replication server, 535Oracle directory server, 535Oracle Enterprise Edition CDs, 414Oracle Enterprise Manager see OEMOracle Enterprise Manager CD, 414Oracle FAQ, 14Oracle home directory, 395–396, 399, 410, 417Oracle iLearning, 11Oracle indexes see indexes, OracleOracle installation see installing Oracle

Database 11gOracle installer see Oracle Universal InstallerOracle instance see instancesOracle Internet Directory see OIDOracle Inventory directory, 396, 409Oracle Inventory group, 407Oracle Label Security feature, 586Oracle licensing parameters, 461Oracle listener see listenersOracle LogMiner utility see LogMiner utility

Page 86: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1306 ■IN D E X

Oracle Managed Files see OMFOracle Management Service (OMS), 154, 157Oracle memory see memoryOracle memory structures, 186–196

automatic memory management, 195–196database buffer cache, 187, 188–189Java pool, 187, 193large pool, 187, 193memory management configuration

options, 196multiple database block sizes and buffer

cache, 189–190program global area (PGA), 187, 193–196redo log buffer, 187, 192–193shared pool, 187, 191–192Streams pool, 187, 193system global area (SGA), 187, 187–193understanding main memory, 186–187

Oracle MetaLink, 15Oracle Names, OID and, 535Oracle Net, 511, 513, 516

connecting to Oracle, 205copying files between databases, 253operating system authentication, 602

Oracle Net Configuration Assistant (NCA), 516, 528–529

Oracle Net configuration files, 412Oracle Net Listener see listenersOracle Net Manager, 516, 537Oracle Net Services, 206, 511–512, 513

configuring, post-installation, 425Oracle components using OID, 535Oracle home directory, 395tools, 516

Oracle Network Foundation Layer, 513Oracle networking, 513–516

see also connectivityLDAP-compliant directory server, 512listener and, 520

Oracle online learning program, 11Oracle optimizer see CBO (Cost-Based

Optimizer)Oracle owner

post-installation tasks, 424–425preinstallation tasks, 410–413

Oracle performance statistics see performance statistics, Oracle

Oracle PMON process, 521Oracle Policy Manager, 586Oracle processes, 179–186

archiver, 184ASM background (ASMB), 185ASM rebalance (ARBn), 185background processes, 179, 180–186change-tracking writer (CTWR), 185checkpoint (CKPT), 183continuous processes, 179database writer (DBWn), 181–182flashback data archiver (FBDA), 186job queue coordination (CJQO), 185

lock (LCKn), 186log writer (LGWR), 182–183manageability monitor (MMON), 185manageability monitor light (MMNL), 185memory manager (MMAN), 185process monitor (PMON), 183rebalance master (RBAL) process, 185recoverer (RECO), 185recovery writer (RVWR) process, 185result cache background (RCBG), 186server processes, 179–180system monitor (SMON), 184user and server process interaction, 179user processes, 179

Oracle Protocol Support, 513Oracle Real Application Clusters see RACsOracle recovery process see recoveryOracle Resource Manager, 147, 996Oracle Scheduler see SchedulerOracle schemas see schemas, OracleOracle Secure Backup, 202, 785–790Oracle sequences see sequencesOracle server software, installing, 416–420Oracle SQL Developer, 136, 401Oracle Storage Compatibility Program

(OSCP), 95Oracle Streams, 671–675

avoiding data center disasters, 802description, 193high-availability systems, 798

Oracle synonyms see synonymsOracle tables see tables, OracleOracle tablespaces see tablespacesOracle Technology Network (OTN), 13Oracle tools, 213–214Oracle transaction management, 337Oracle transactions see transactionsOracle triggers see triggersOracle Tuning Pack, 149, 949Oracle Universal Installer

choosing Basic/Advanced Installation, 416End of Installation window, 420Install window, 420installing Grid Control, 155installing OEM Management Agent, 156installing OID, 537installing Oracle server software, 415installing Oracle software, 416–420installing Oracle software using response

files, 421–422invoking with runInstaller script, 416prerequisite checks, 418restarting installation process, 418Select Configuration Options window, 419Select Installation Type window, 417Specify Home Details window, 417Summary window, 419uninstalling Oracle, 426Welcome window, 416, 417

Oracle University, 11

Page 87: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1307■I N D E X

Oracle upgrade see upgrading to Oracle Database 11g

oracle usercreating Oracle software owner, 408installing Oracle Database 11g, 414privileges, 409setting environment variables, 413tasks, post-installation, 424

Oracle views see viewsOracle Wallet

creating, 241–242creating encrypted tablespaces, 242–243creating with OWM, 605–606creating, tablespace encryption, 609data encryption, 604ENCRYPTION_WALLET_LOCATION

parameter, 241opening and closing, 606

Oracle Wallet Manager (OWM), 241, 605–606Oracle Warehouse Builder (OWB), 401, 627Oracle Web Conference (OWC), 15Oracle XML DB, 1248–1252Oracle-Base, 14ORACLE_BASE variable, 71, 395, 396

setting OS environment variables, 446setting preinstallation, 409, 411

ORACLE_DATAPUMP access driver, 627, 648, 650, 651

ORACLE_HOME directory, 177, 401, 447ORACLE_HOME variable

creating database using SQL*Plus, 475manual database upgrade process, 437Oracle home directory, 395remotely connecting to Oracle database, 98setting environment for SQL*Plus, 98setting environment variables,

preinstallation, 411, 413setting OS environment variables, 446upgrading with DBUA, 430

ORACLE_HOSTNAME variable, 398ORACLE_LOADER access driver, 627, 648ORACLE_PATH variable, 125OracleSchedulerExecutionAgent service, 1005ORACLE_SID variable, 71, 412

creating database using SQL*Plus, 475DB_NAME parameter, 451registering database in recovery catalog, 769setting for ASM instances, 906setting OS environment variables, 446specifying database name at STARTUP, 499starting session from command line, 98starting SQL*Plus sessions, 99

oradebug utility, 1174oraenv script, 424, 425ORAENV_ASK variable, 412oraInst.loc file, 421orainstRoot.sh script, 155, 156, 420OraInventory (Oracle Inventory directory),

396, 409

ORAINVENTORY group, 407, 408ORAKILL utility, 621OraPub, 14orapwd command, 600oratab file, 411, 423, 424, 425, 430ORDBMS (object-relational database

management system), 19, 38, 39–40ORDER BY clause, 193, 297, 1071, 1226ORDER BY command, 263ORDERED hint, 1067orderid_refconstraint constraint, 285O_RELEASE variable, SQL*Plus, 128ORGANIZATION EXTERNAL clause, 647ORGANIZATION INDEX clause, 279OS value, AUDIT_TRAIL parameter, 587, 588OSASM group, 407, 902OS_AUTHENT_PREFIX parameter, 472,

601, 612OSCP (Oracle Storage Compatibility

Program), 95OSDBA group, 407, 408OSOPER group, 407, 408OS_USER attribute, USERENV namespace,

579, 580Other wait class, 1163OTHER_GROUPS resource consumer group,

558, 562out-of-space errors, 383OUT option, SPOOL command, SQL*Plus, 120outer join, SQL, 1234outlines, stored, 1077–1080OUTLN account, 490, 596OUTLN user, stored outlines, 1078out-of-space alerts, 226output see input/output (I/O)O_VERSION variable, SQL*Plus, 128overwriting, protecting files from, 57OWB (Oracle Warehouse Builder), 401, 627OWM (Oracle Wallet Manager), 241, 605–606ownership

creating Oracle software owner user, 408–409

■Ppackage privileges, 571packages

applying/checking OS packages, 403executing, SQL*Plus, 121GlancePlus package, 84PL/SQL, 1247

packsServer Manageability Packs, 459

PACK_STGTAB_SQLSET procedure, 1218page command, UNIX/Linux, 53page ins/outs, memory management, 81page-level locking, 348pages

analyzing page performance, Grid Control, 160

swapping data, 1158

Page 88: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1308 ■IN D E X

PAGESIZE variable, SQL*Plus, 108paging, 1188, 1205PARALLEL parameter, Data Pump, 703, 713parallel degree limit method, 555parallel execution, 662, 1085PARALLEL option, 273, 657PARALLEL parameter

Data Pump, 678, 700–705, 708populating external tables, 652SQL*Loader control file, 635

parallel processes, setting number of, 467parallel recovery feature, 807PARALLEL_DEGREE_LIMIT_MTH

parameter, 560parallelism

changing degree of parallelism, 700creating plan directives, 560Data Pump technology, 677degree of parallelism parameters,

RMAN, 765production database problems, 554

PARALLEL_MAX_SERVERS parameter, 467parameter files

Data Pump Export utility, 687, 690, 704database creation, 446–474initialization parameter file (PFILE), 447–448

parametersData Pump Export parameters, 689–704Data Pump Import parameters, 705–713dynamic parameters, 448hidden Oracle parameters, 177setting security-related initialization

parameters, 615SHOW PARAMETERS command, 117static parameters, 448

parent nodes, B-tree index, 298PARFILE parameter

Data Pump, 687, 690, 706SQL*Loader utility, 637

parity, RAID, 90Parse column, TKPROF utility, 1104parse information, 1135–1136parse tree, 1043, 1133parsing

application scalability, 1141–1142bind peeking technique, 1087deriving parse information, 1135hard parsing, 191, 1135, 1139

converting to soft parsing, 1141latch contention, 1141parse-time CPU usage, 1156–1157soft parsing, 191, 1135stages of SQL processing, 343using parsed statement, 1134

parsing stagebind variables, 1075query processing, 1043SQL processing steps, 1133

partial database backups, 727, 794

partial dependencies, 2NF, 31partial execution of SQL statements

Automatic Tuning Optimizer (ATO), 1112partial mode, ADDM, 882PARTIAL option, DURATION clause,

RMAN, 777PARTITION BY HASH clause, 283, 303PARTITION BY LIST clause, 284PARTITION BY RANGE clause, 282PARTITION BY REFERENCE clause, 285partition pruning, 280PARTITIONED BY SYSTEM clause, 287partitioned indexes, 302–303, 1073partitioned tables, 266, 280–292

adding partitions, 291archiving data, 281coalescing partitions, 292creating, 281DBA_PART_TABLES view, 331DBA_TAB_PARTITIONS view, 292, 330dropping partitions, 291exchanging partitions, 291improving SQL processing, 1076merging partitions, 291partition independence, 281partition maintenance operations, 290–292performance, 280, 281renaming partitions, 291splitting partitions, 291

partitioning, 280composite partitioning, 281, 287–290disk partitioning, 87hash partitioning, 283–284interval partitioning, 282–283interval-list partitioning, 289interval-range partitioning, 290list partitioning, 284range partitioning, 281–282, 285range-hash partitioning, 288range-list partitioning, 288–289reference partitioning, 284–286system partitioning, 287transition point, 282VALUES LESS THAN clause, 281virtual column-based partitioning, 286

partitioning keys, 281partitions

MODEL clause creating multidimensional arrays, 668, 670

passwd command, UNIX/Linux, 49passwd file, UNIX, 67PASSWORD command, SQL*Plus, 547PASSWORD FILE option, RMAN, 835password management function, 552password protection features, 552PASSWORD value, Data Pump, 695, 696password verification function, 552password-based encryption, 763

encrypting RMAN backups, 782

Page 89: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1309■I N D E X

password-related parameters, user profiles, 549, 550

passwordssee also authentication; securitycase sensitivity, 465, 491, 597–598changing another user’s password

temporarily, 620changing passwords, 611changing user’s password, 547database security, 611DBCA changing passwords for default users,

490–491default values, 490encrypted passwords, 601ENCRYPTION_PASSWORD parameter, Data

Pump, 696expiration, 599hard-coding user passwords, 611managing, 596–597password aging and expiration policies, 612password authentication, 602password file, 177

backup guidelines, 729database authentication, 599–600manual database upgrade process, 437orapwd command, 600

REMOTE_LOGIN_PASSWORDFILE parameter, 472, 599

requirements for strong passwords, 552resetting passwords, post-upgrade, 441secure password support, 598setting password for listener, 524–525SYS user default password, 475SYSTEM account default password, 475

PASSWORD_GRACE_TIME parameter, 550, 599PASSWORD_XYZ parameters, 550paste command, UNIX/Linux, 67Patch Advisor, database management, 148patches

ACCEPT_SQL_PATCH procedure, 1038applying manually, 151applying patch sets, 1131applying, post-installation, 424checking for latest security patches, 617Critical Patch Updates, 617DBA_SQL_PATCHES view, 1038DROP_SQL_PATCH procedure, 1038Grid Control, 159linking to MetaLink, 150preinstallation checks, 401

Patching Setup page, Database Control, 148, 151

PATH shell variable, UNIX, 54PATH variable, setting, 411, 446paths, UNIX, 47, 125pattern matching, SQL*Plus, 129pattern matching, UNIX, 65pattern-recognition, grep command, UNIX, 49PAUSE command, SQL*Plus, 121

PAUSE variable, SQL*Plus, 108PCTFREE parameter, 217, 222, 1176PCTSPACE option, Data Pump Import, 711PCTTHRESHOLD clause, 279, 280PCTUSED parameter, 217, 222pending area, Database Resource Manager,

556, 562pending statistics, making public, 1057percent full alert, 226percent sign (%) character, SQL, 1224percentage of maximum thresholds, 954performance

see also indexes; instance performance; optimization; system performance; tuning

abnormal increase in process size, 1190–1191

analyzing performance using ADDM, 1183–1184

ASH analyzing recent session activity, 1186ASM disk groups, 914, 916Automatic Database Diagnostic Monitor

(ADDM), 209avoiding ad hoc SQL, 1141AWR statistics for SQL statements, 1184benefits of tablespaces, 171bind variables, 1134buffer cache sizing, 188cache misses affecting, 192collecting trace statistics, 1100confusing symptoms and causes, 1183cost of disk I/O, 186Data Pump technology, 678Database Control examining, 1195–1201database design, 36database hangs, 1186–1194database hit ratios, 1161–1162database wait statistics, 1162–1163delays due to shared pool problems, 1191disk configuration strategies, 87dynamic performance (V$) views, 204dynamic performance tables, 204extent sizing, 216extents, 220inline stored functions, 1074–1075isolation levels, 344licensing performance tools, 948locking issues, 1189logging on and off affecting, 1142measuring I/O performance, 1159–1161measuring process memory usage,

1190–1191minimizing downtime, 6monitoring host with Grid Control, 160monitoring system with Grid Control, 160network performance, 1160operating system memory

management, 1186Oracle Enterprise Manager (OEM), 206

Page 90: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1310 ■IN D E X

paging affecting, 1205partitioned tables, 280, 281preserving database performance, 1080problems due to bad statistics, 1191RAID systems, 88reclaiming unused space, 1090reducing I/O contention, 1160SAME guidelines for optimal disk

usage, 1160scalability, 1141segment space management, 218severe contention for resources, 1188SQL Performance Analyzer, 213, 1216–1220swapping affecting, 1205system global area (SGA), 187system usage problems, 1188temporary tables, 277timing conversion to new version, 1131tracing entire instance, 1107wait classes and wait events, 1163writing efficient SQL, 1065–1075

performance advisors, ADDM, 881Performance Analysis section, Database

Control, 1197performance- and diagnostics-related

parameters, 461–468Performance Data Report page, Database

Control, 1201–1202performance monitoring, UNIX, 80–85

analyzing read/write operations, 83bandwidth, 81CPU usage, 80disk storage, 81GlancePlus, 84iostat command, 82memory management, 81memory use, 82monitoring network with netstat utility, 85monitoring performance with top

command, 84monitoring system with GlancePlus, 84netstat utility, 85sar command, 83top command, 84viewing input/output statistics, 82vmstat utility, 82

Performance page, Database Control, 145–146performance statistics, 959

AWR, 210, 877, 878, 960performance statistics, Oracle, 948–952performance tuning, 1041–1043

see also tuningadaptive cursor sharing, 1087–1090ADDM and, 877avoiding improper use of views, 1075CBO (Cost-Based Optimizer), 1047–1053database design, 1042DBA improving SQL processing, 1075–1080DBA role, 5, 1086–1087

description, 1130end-to-end tracing, 1105–1107identifying inefficiency in SQL

statements, 1127indexing strategy, 1070–1073instance tuning, 1129–1130, 1194–1209

see also instance performancequery optimization, 1047–1065query processing optimization, 1043–1046reactive performance tuning, 1042removing unnecessary indexes, 1073SQL Plan Management (SPM), 1080–1087tuning-related advisors, 976using result cache, 1120–1126

performance tuning tools, SQL, 1090–1105Autotrace facility, 1095–1099EXPLAIN PLAN tool, 1090–1095SQL Trace utility, 1099–1102TKPROF utility, 1102–1105

period (.) character, regular expressions, SQL, 1238

period-over-period comparison functions, SQL, 1231

permanent files, flash recovery area, 735permanent tablespaces, 172

creating database, 482default permanent tablespaces, 235–236description, 215

permissions, UNIX files, 59–62setting, database security, 613setting, preinstallation, 409

pessimistic locking methods, 347PFILE (initialization parameter file), 446, 447–448

see also init.ora file; initialization files; SPFILEchanging parameter values, 493changing parameters dynamically, 447comments in init.ora file, 496creating init.ora file, 475–477

from SPFILE, 495creating SPFILE from, 494creating SPFILE or PFILE from memory, 497init.ora file not saved in default location, 478modifying, 495Oracle looking for correct initialization

file, 494quick way to create database, 485reading init.ora file, 473setting archivelog-related parameters, 491using init.ora file as well as SPFILE, 495

pfile directory, 397PGA (program global area), 187, 193–196

automatic memory management, 195–196, 894, 896

automatic PGA memory management, 194, 894

managing/monitoring database, 214manual PGA memory management, 894MEMORY_TARGET parameter, 457total memory allocated to, 1190

Page 91: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1311■I N D E X

PGA memory, 1148–1152, 1205PGA_AGGREGATE_TARGET parameter,

194, 195automatic memory management, 896,

897, 1148db file sequential read wait event, 1178setting value of, 1149–1152

PGA_TARGET parameter, 895, 1150, 1205phantom reads problem, 341, 344, 345, 346physical database backups, 725, 728physical database design, 34–37physical database structures, 173–176

control files, 173, 174–175datafiles, 173–174redo log files, 173, 175–176

physical reads, 1144physical standby databases, 799PID (process ID), UNIX, 74PID column, top command, 84ping command, Oracle connectivity, 516pinhits, determining number of, 1137pinned buffers, 188pinning objects in shared pool, 1142–1143pipe (|) command, UNIX/Linux, 52, 57pipelining, table functions, 662, 666plan directives see resource plan directivesplan stability feature, 1077PLAN_LIST attribute, 1083PLAN_RETENTION_WEEKS parameter,

SMB, 1085plans see execution plansPLAN_TABLE table, 1090, 1091, 1095PL/SQL, 97, 1241–1248

blocks, 1241conditional control, 1243creating cacheable function, 1124cursors, 1245–1247declaring variables, 1241displaying output on screen, 109ending SQL and PL/SQL commands, 103error handling, 1242explicit cursors, 1245functions, 1247implicit cursors, 1245libraries, 464, 468looping constructs, 1243–1244packages, 1247procedures, 1247records, 1244%ROWTYPE attribute, 1242show errors command, 111terminating PL/SQL block, 102%TYPE attribute, 1242writing executable statements, 1242

PL/SQL execution elapsed time, 1206PL/SQL Function Result Cache, 1124–1125PL/SQL statements

BEGIN, 1241, 1242COMMIT, 1242DECLARE, 1241

DELETE, 1242DML statements, 1242END, 1241EXCEPTION, 1241, 1243FETCH, 1245FOR LOOP, 1244IF-THEN, 1243INSERT, 1242LOOP/END LOOP, 1243RAISE, 1243SELECT, 1242UPDATE, 1242WHILE LOOP, 1244

PLSQL_CODE_TYPE parameter, 464PLSQL_OPTIMIZE_LEVEL parameter, 468PLUSTRACE role, 1096plustrace.sql script, 1096PM (product media) schema, 1221PMON (process monitor), 181, 183, 479, 521PMON timer idle event, 1181point-in-time recovery (PITR), 802, 823, 853

tablespace point-in-time recovery (TSPITR), 808, 840–841

policy-based configuration framework, Database Control, 151

policy functions, 582–585policy groups, 586Policy Violations page, Database Control, 151policy_name parameter, ADD_POLICY, 594POLICY_TYPE parameter, ADD_POLICY, 584polymorphism, 39pooling see connection poolingport number, connect descriptors, 515port parameter, easy connect naming

method, 529portlist.ini file, 157ports, 140, 614POSITION clause, SQL*Loader, 632post upgrade actions script, 439post-installation tasks, Oracle Database 11g,

422–425Oracle owner tasks, 424–425system administrator tasks, 423–424

Post-Upgrade Status tool, 429, 440–441POWER clause, REBUILD command, 916predefined variables, SQL*Plus, 127predicate columns, 1071predicates, 583Preferences page, Grid Control, 159preferred mirror read feature, ASM, 909prefixed indexes, 1073preinstallation tasks, Oracle Database 11g,

400–413checking preinstallation requirements,

400–401final checklist, 413–414Oracle owner tasks, 410–413system administrator tasks see system

administratorPreparedStatement object, 539

Page 92: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1312 ■IN D E X

PREPARE_REPLAY procedure, 1214Pre-Upgrade Information Tool, 428–429,

435–437PREVIEW option, RESTORE command,

RMAN, 811PRI column, top command, 84primary indexes, 297, 1070primary key constraints, 300, 306primary key method, 936primary keys, 26, 31, 33, 35, 36

distinguished names (DNs), 536guidelines for creating indexes, 297

principal parameter, CREATE_ACL, 616PRINT parameter, TKPROF utility, 1102PRINT SCRIPT command, RMAN, 750, 751PRINT_PRETTY_SQL procedure, 846private data, 1190private database links, 985–986private SQL area, PGA memory, 194private synonyms, 324, 326PRIVATE_SGA parameter, 549privilege parameter, CREATE_ACL, 616PRIVILEGE variable, SQL*Plus, 119, 128privileged connections, SQL*Plus, 99privileged users, 599privilege-level audit, 587privileges, 567

CHECK_PRIVILEGE function, 617controlling database access, 567–574CREATE ANY TABLE, 268CREATE SESSION, 545CREATE TABLE, 268CREATE VIEW, 312creating materialized views, 317creating users, 545Data Pump privileges, 685DBA views managing, 577directory privileges, 571function privileges, 571granting object privileges, 367granting privileges, 567

database security, 612through roles, 618to PUBLIC, 569to roles, 575to users, 135, 257

how Oracle processes transactions, 197manual database creation, 475materialized view privileges, 571object privileges, 570–573package privileges, 571procedure privileges, 571sequence privileges, 571showing privileges in prompt, 119SQL*Plus security and Oracle, 103SYSASM privilege, 570SYSDBA privilege, 475, 570SYSOPER privilege, 570system privileges, 567–570

table privileges, 571UNLIMITED TABLESPACE, 268view privileges, 571views and stored procedures managing, 577

privileges script, 420proactive tuning, 1042problem findings, ADDM, 880procedure privileges, 571procedures

see also stored proceduresexecuting, SQL*Plus, 121Java stored procedures, 1252PL/SQL functions compared, 1247

process monitor (PMON), 181, 183, 479, 521process number, deriving, 621process-related parameters, 455PROCESS_CAPTURE procedure, 1211processes, 179

abnormal increase in process size, 1190–1191

components of Oracle process, 1190CPU units used by processes, 1154freeing up resources from dead

processes, 183measuring process memory usage,

1190–1191setting number of parallel processes, 467specifying number of writer processes, 455system usage problems, 1188

PROCESSES parameter, 455processes, Oracle see Oracle processesprocesses, UNIX see UNIX processesproduct files, 394, 397production databases, 9, 554product_user_profile table, 103, 104, 105, 493

disabling role using, 576enabling role using, 577restricting SQL*Plus usage, 618

.profile file, UNIX, 54, 55, 406profiles see user profilesprogram global area see PGAPROGRAM_ACTION attribute, 1002, 1006programs, Oracle Scheduler, 995, 1006–1007PROGRAM_TYPE attribute, 1002, 1006projection operations, 21, 1046, 1223PROMPT command, SQL*Plus, 121prompts, SQL*Plus, 99, 115, 118, 119prompts, UNIX, 51properties

ACID properties, transactions, 340object-oriented database model, 39showing properties of columns,

SQL*Plus, 123protocol address, connect descriptors, 515protocols

communication protocol, 515Lightweight Directory Access Protocol, 534write ahead protocol, 182, 199

Provisioning Software Library, 148

Page 93: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1313■I N D E X

proxy authentication, 602proxy copies, RMAN, 753prvtsch.plb script, 1003, 1006ps command, UNIX/Linux, 74, 75, 81, 903PS1 environment variable, 51pseudo-columns, Flashback Versions

Query, 370public database links, creating, 986–987Public Key Infrastructure (PKI) credentials, 535PUBLIC role, 613public synonyms, 324, 325PUBLIC user group, 569, 576, 615PUBLISH_PENDING_STATS procedure, 1057pupbld.sql script, 103, 493PURGE INDEX command, 852PURGE option, ALTER TABLE, 244PURGE option, DROP TABLE, 276, 850, 852–853PURGE RECYCLEBIN command, 853PURGE TABLE command, 852PURGE TABLESPACE command, 852PURGE_LOG procedure, 1012put command, UNIX/Linux, 80PUT procedure, 257PUT_FILE procedure, 253, 254, 992PUT_LINE procedure, 109, 258pwd command, UNIX/Linux, 49

■Qqueries

executing SQL statements, JDBC, 539Flashback Query, 366, 367–368Flashback Transaction Query, 366, 372–375Flashback Versions Query, 366, 369–372hierarchical SQL queries, 1232locking, 349optimizing, 205resumable database operations, 383

query optimization, 1043, 1047–1065see also CBO (Cost-Based Optimizer)adaptive search strategy, 1053choosing access path, 1052choosing join method, 1052choosing join order, 1053choosing optimization mode, 1047deferring publishing of statistics, 1056–1057effect when statistics not collected, 1063extended optimizer statistics, 1058–1060how CBO optimizes queries, 1051–1053multicolumn statistics, 1058OEM collecting optimizer statistics,

1064–1065providing statistics to CBO, 1053–1056providing statistics to optimizer, 1047–1049setting optimizer level, 1050–1051setting optimizer mode, 1049–1050specifying optimization type, 462SQL transformation, 1051

QUERY parameter, Data Pump, 694, 704, 708query processing, 1043–1046

query rewrite phase, optimizing processing, 1044

QUERY REWRITE privilege, 317query rewriting, 315, 465, 578QUERY_REWRITE_ENABLED parameter, 315,

465, 1078QUERY_REWRITE_INTEGRITY parameter,

316, 465queue size, setting in listener.ora, 523QUEUEING_MTH parameter, 560queues

ALERT_QUE queue, 954operation queuing, 942system usage problems, 1188

QUEUESIZE parameter, listener, 523QUEUE_SPEC attribute, 1011QUICK_TUNE procedure, 320, 324quiescing databases, 505, 944–945QUIT command, SQL*Plus, 102, 134QUOTA clause, ALTER USER, 545QUOTA clause, CREATE USER, 546quotas, tablespaces, 226, 545, 546

■R-R option (restrict), SQL*Plus, 115RACs (Real Application Clusters), 173

associating multiple instances to DB_NAME, 452, 514

avoiding database failures, 802configuring ADDM under RAC, 882creating SPFILE or PFILE from memory, 497disk configuration strategies, 85high-availability systems, 798

RAID (redundant array of independent disk), 88–93

backup guidelines, 729disk I/O performance, 1158file mapping, 993HARD initiative, 798reducing vulnerability to recoveries, 809

RAISE statement, PL/SQL, 1243RAISE_APPLICATION_ERROR exception, 258RAM (random access memory), 186, 403range partitioning, 281–282

interval-range partitioning, 290range-hash partitioning, 288range-list partitioning, 288–289rank functions, SQL, 1231, 1232RATIO method, creating resource plans,

560, 561rationale components, ADDM, 881ratio-to-report comparison functions,

SQL, 1231raw devices, disk I/O performance, 1158RBAL (rebalance master) process, 185, 907rc scripts, 423rcache column, sar command, 83RC_BACKUP_SET view, 744, 760rcp command, UNIX/Linux, 79

Page 94: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1314 ■IN D E X

RDBMS (relational database management system), 19, 452

RDBMS compatibility level, ASM disk groups, 910

rdbms ipc message idle event, 1181reactive performance tuning, 1042read consistency, 199, 345, 356, 359READ ONLY clause, ALTER TABLE, 273READ ONLY clause, CREATE VIEW, 312read permission, UNIX files, 59READ WRITE clause, ALTER TABLE, 274read/write operations, UNIX, 83read-committed isolation level, 344, 345, 346reader class, Oracle Secure Backup, 788README files, Oracle Database 11g, 392read-only mode, 273–274, 502read-only tablespaces, 172, 229read-uncommitted isolation level, 344READY status, Oracle listener, 522Real Application Clusters see RACsReal Application Testing, 148, 1209

analyzing after-upgrade SQL workload, 1219analyzing prechange SQL workload, 1218capturing production SQL workload, 1217capturing production workload, 1210–1211creating SQL Tuning Set, 1217Database Replay tool, 1209–1216loading SQL Tuning Set, 1217making system change, 1211preprocessing workload, 1211replaying captured workload, 1211setting up replay clients, 1212SQL Performance Analyzer, 1216–1220transporting SQL Tuning Set, 1218

real dictionary tables, 1063REBALANCE command, ASM disk groups, 916rebalance master (RBAL) process, 185, 907rebalancing disk groups, ASM, 916REBUILD command

ALTER INDEX statement, 303, 305POWER clause, 916rebuilding indexes/tables regularly, 1089

rebuilding indexes online, 934, 935RECNUM column specification,

SQL*Loader, 636Recommendation Options/Types, SQL Access

Advisor, 322recommendations, ADDM, 878, 880–881

ADDM reports, 888, 891, 892recommendations, Segment Advisor, 932Recompile Invalid Objects window, DBUA, 431RECORD parameter, TKPROF utility, 1102RECORD_FORMAT_INFO clause, 647records, PL/SQL, 1244RECOVER command, RMAN, 812, 813, 820RECOVER command, SQL*Plus, 134RECOVER BLOCK command, BMR, 864RECOVER COPY command, 733, 778

RECOVER DATABASE command, 815, 816, 861RECOVER DATAFILE command, RMAN, 819RECOVER TABLESPACE command, RMAN, 818recoverer (RECO), 185, 479recovery

see also backups; flash recovery areacache recovery, 804cancel-based recovery, 824change-based SCN recovery, 820, 824checkpoint data in control files, 175cloning databases, 833–840closed recovery, 807complete recovery, 807control files, 174crash and instance recovery, 804–805Data Recovery Advisor, 211, 829–833database failures, 801–804errors, 866–870Flashback Data Archive, 870–874flashback recovery techniques, 202Flashback techniques and, 847–861granular recovery techniques, 840–847incomplete recovery, 807instance recovery, 468log sequence-based recovery, 821media recovery, 806–808media recovery scenarios, 814–829media vs. nonmedia recoveries, 808open recovery, 807Oracle recovery process, 804–809parameters, 468–470redo log files, 175reducing vulnerability to recoveries, 809repairing data corruption, 864–865restore points, 861–864restoring vs. recovering datafiles, 806SHOW RECYCLEBIN command, 116Simplified Recovery Through Resetlogs

feature, 823SQL*Plus, 134time-based recovery, 820, 824traditional recovery techniques, 848transaction recovery, 804trial recovery, 865–866

recovery catalog, RMAN, 744backing up recovery catalog, 769base recovery catalog, 772benefits of RMAN, 743cataloging backups, 770connecting to, 746connecting to RMAN, 767–768creating recovery catalog, 768creating recovery catalog schema, 767dropping recovery catalog, 772getting rid of invalid entries, 760granting roles, 767importing recovery catalog, 771maintaining, 769–772moving recovery catalog, 772

Page 95: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1315■I N D E X

performing PITR, 766recovering recovery catalog, 770recovery catalog schema, 743registering database, 768–769resynchronizing recovery catalog, 769upgrading recovery catalog, 771working with, 766–769

Recovery Configuration window, 432, 487recovery errors, 866–870recovery files, OFA guidelines, 399Recovery Manager see RMANrecovery scenarios, 814–829

control file recovery, 824–828datafile recovery, 818–820

recovering datafiles without backup, 828–829

incomplete recovery, 820–824performing hot restore with RMAN, 816tablespace recovery, 817–818whole database recovery, 814–817

RECOVERY WINDOW option, RMAN, 762recovery writer (RVWR) process, 185RECOVERY_CATALOG_OWNER role, 773recovery-related parameters, 468–470recursive CPU usage, 1157recursive relationships, 28Recycle Bin, 850–851

DBA_RECYCLEBIN view, 850DROP TABLE PURGE command, 116Flashback Drop feature, 376, 849, 850–851free space, 244Oracle removing items from, 850permanently removing objects from, 853PURGE RECYCLEBIN command, 853recovering dropped table/user objects, 548removing items from, 852removing tables without using, 852removing tablespace without using, 853security, 852SHOW RECYCLEBIN command, 116, 850USER_RECYCLEBIN view, 850

recycle buffer pool, 189, 1146recycle pool, 457, 458RECYCLEBIN parameter, Flashback Drop, 849redirection, UNIX, 56–57redo data, 227, 460redo entries, SQL*Loader, 640redo log buffer, 176, 187, 192–193

committing transactions, 182, 198how Oracle processes transactions, 197transferring contents to disk, 182

redo log files, 173, 175–176see also online redo log filesADD LOGFILE GROUP syntax, 983after-image records, 176applying redo logs during recovery, 867arch directory containing, 397archivelog mode, 176, 726, 775

archiver process, 1187archiving, 135, 176, 184, 459backup and recovery architecture, 201backup guidelines, 729benefits of temporary tables, 277committing transactions, 198, 338, 339creating database, 481data consistency, 176database creation log, 484database files, 398defining filename format for archived, 460flash recovery area, 738increasing size of, 445instance performance, 1205LogMiner utility analyzing, 845–847making whole closed backups, 791monitoring, 984multiplexing, 176, 182, 184, 444, 455, 729names and locations of, 174naming conventions, 398noarchivelog mode, 176, 726optimizing size over time, 445Oracle Managed Files (OMF), 250, 252,

455, 924Oracle recommendations, 445organization of, 982Pre-Upgrade Information Tool, 428renaming redo logs, 983RESETLOGS option, 822rolling back transactions, 198sizing for database creation, 444whole open backups, 792write ahead protocol, 199

redo log groups, 176, 184, 982, 983, 984redo log space requests, 1181redo logs see redo log filesredo records, 176, 182, 339redundancy, 729, 901, 914REDUNDANCY attribute, ASM, 910, 915redundancy levels, ASM, 909REDUNDANCY option, RMAN, 762redundancy set, 730–731, 809REENABLE clause, SQL*Loader, 642REF CURSOR type, PL/SQL, 664, 666, 1247reference partitioning, 284–286REFERENCES clause, CREATE TABLE, 285referential integrity, 36referential integrity constraints, 225, 308, 716Reflections X-Client, 46refresh options, materialized views, 316, 319REGEXP_XYZ functions, SQL, 1238REGISTER DATABASE command, RMAN, 769registerDriver method, JDBC drivers, 538registration, dynamic service, 183regular expressions, SQL, 1237–1239regular expressions, UNIX, 65Related Links section, Database Control, 150relational algebra, 21–22

Page 96: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1316 ■IN D E X

relational database life cycle, 23–37logical database design, 24–34physical database design, 34–37requirements gathering, 23–24

relational database management system (RDBMS), 19, 452

relational database model, 20–22, 38object-relational database model, 39–40transforming ER diagrams into relational

tables, 35relational databases, 19–37relational tables, 265relationships, ER modeling, 25

building entity-relationship diagram, 28cardinality of (1:1, 1:M, M:M), 26recursive relationships, 28

relative distinguished names, 536relative path, UNIX, 47, 62Release Notes and Addendums, Oracle

Database 11g, 392releases

ensuring database compatibility, 452upgrade paths to Oracle Database 11g, 426variable naming release number, 128

releasing-space phase, segment shrinking, 929Reliaty backup software, Oracle Secure

Backup, 785RELIES ON clause, result cache, 1124reload command, lsnrctl utility, 523reloads, determining number of, 1137RELY constraints, 310REMAP_CONNECTION procedure, 1214REMAP_DATA parameter, Data Pump, 693, 710REMAP_DATAFILE parameter, Data Pump, 709REMAP_SCHEMA parameter, Data Pump,

679, 709REMAP_TABLE parameter, Data Pump, 709REMAP_TABLESPACE parameter, Data

Pump, 710REMAP_XYZ parameters, Data Pump, 679REMARK command, SQL*Plus, 128, 132remote access to UNIX server, 78remote client authentication, 615remote external jobs, 1002remote login (rlogin), 78, 79remote servers, copying files to/from, 254REMOTE_LOGIN_PASSWORDFILE parameter,

472, 599REMOTE_OS_AUTHENT parameter, 612, 615removing files, UNIX, 59RENAME command, ALTER TABLE, 272RENAME PARTITION command, 291REPAIR XYZ commands, Data Recovery

Advisor, 832, 833repeat interval, jobs, Oracle Scheduler,

999–1000repeatable-read isolation level, 344repeating groups, 1NF, 30repeating-baseline templates, AWR, 966

REPEAT_INTERVAL attribute, 999, 1014REPFOOTER/REPHEADER commands,

SQL*Plus, 123REPLACE clause, SQL*Loader, 629REPLACE function, SQL, 1228REPLACE option, SQL*Plus, 116, 120, 124REPLACE SCRIPT command, RMAN, 752REPLACE_USER_SQL_PROFILES

parameter, 1117replay driver, Database Replay, 1212–1216REPLAY_REPORT function, 1215REPORT SCHEMA command, RMAN, 759, 769REPORT XYZ commands, RMAN, 759REPORT_ANALYSIS_TASK function, 1219REPORT_AUTO_TUNING_TASK function, 1119REPORT_DIAGNOSTIC_TASK function, 1037reporting commands, RMAN, 758–760reports, AWR, 966–971REPORT_TUNING_TASK procedure, 1114repository

Management Repository, Grid Control, 154RMAN, 743, 744

requirements gathering, 23–24RES column, top command, 84RESETLOGS option, 821, 822, 823

Flashback Database limitations, 861user-managed control file recovery, 827

resident connection pooling, DRCP, 180RESIZE clause, tablespaces, 223, 238RESIZE command, 219, 364RESOLVE privilege, 616resource allocation, 554, 555resource consumer groups

Database Resource Manager, 554, 555, 556, 557–559

assigning users to, 562–565automatic assignment to session, 564automatic group switching method,

555, 560create_consumer_group procedure, 557default Oracle database groups, 558default Oracle resource plans, 558enforcing per-session CPU and I/O limits,

564–565groups granted to users or roles, 566OEM administering, 567sessions currently assigned to, 566verifying user membership, 563

Oracle Scheduler, 1011, 1016–1017SET_CONSUMER_GROUP_MAPPING

procedure, 564SET_CONSUMER_MAPPING_PRI

procedure, 564SET_INITIAL_CONSUMER_GROUP

procedure, 563V$RSRC_CONSUMER_GROUP view, 566

resource managementDatabase Resource Manager, 554–567dynamic resource management, 941–943

Page 97: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1317■I N D E X

Resource Manager, Oracle, 147, 996Resource Monitors page, OEM, 566resource parameters, 549, 553resource plan directives, Database Resource

Manager, 555, 556, 560–562, 942Resource Plan Wizard, OEM, 556resource plans

Database Resource Manager, 554, 555, 556, 559–560

CREATE_PLAN procedure, 560CREATE_PLAN_DIRECTIVE procedure,

561, 565determining status of, 562OEM administering, 567showing plans, 566

resource allocation for automated tasks, 1022

Scheduler, 997, 1013–1017RESOURCE role, 574RESOURCE_CONSUMER_GROUP

attribute, 1012RESOURCE_LIMIT parameter, 552RESOURCE_MANAGER_PLAN parameter, 565RESOURCE_PLAN attribute, 1014resources

ALTER RESOURCE COST statement, 549controlling user’s use of, 548, 549Database Resource Manager, 208DBA resources, 13–14freeing up resources from dead

processes, 183Grid Control, 159hard parsing, 1138inefficient SQL using most resources,

1109–1110query optimization, 1043severe contention for, 1188SQL Trace tool showing usage of, 1100system usage problems, 1188

response action, alerts, 954response directory, 421response files, 421–422RESTORE command, RMAN, 811, 812, 820RESTORE CONTROLFILE command,

RMAN, 825RESTORE DATABASE command, RMAN,

814, 815RESTORE DATAFILE command, RMAN, 819restore optimization, RMAN, 810RESTORE POINT clause, RMAN, 780restore points, 861–864RESTORE TABLESPACE command, RMAN, 817restore utilities, UNIX, 76–77RESTORE_DEFAULTS procedure, 533restoring database

performing hot restore with RMAN, 816restoring vs. recovering datafiles, 806

restoring pre-upgrade database, DBUA, 433RESTRICT command, SQL*Plus, 105

restrict option (-R), SQL*Plus, 115RESTRICT option, STARTUP command, 908restricted database mode, 501

quiescing database, 505RESTRICTED SESSION privilege, 570result cache, 192, 1120–1126

Client Query Result Cache, 1125–1126Function Result Cache, 1124–1125managing, 1120, 1123–1124RESULT_CACHE_MODE parameter,

1121–1122result cache background (RCBG) process, 186Result Cache Memory, 1120result code, finding, 69RESULT_CACHE hint, 1121, 1122, 1125RESULT_CACHE_MAX_RESULT parameter,

464, 1121RESULT_CACHE_MAX_SIZE parameter,

464, 1120RESULT_CACHE_MODE parameter, 192, 464,

1121–1122, 1125RESULT_CACHE_REMOTE_EXPIRATION

parameter, 1121Results for Task page, SQL Access Advisor, 323ResultSet object, JDBC, 539RESUMABLE parameter, SQL*Loader, 635Resumable Space Allocation, 382–386

enabling/disabling, 470expanding tablespaces, 224user-quota-exceeded errors, 226

RESUMABLE_NAME parameter, SQL*Loader, 636

RESUMABLE_TIMEOUT parameter, 384, 470, 636

RESYNC CATALOG command, RMAN, 769, 770RETENTION GUARANTEE clause, 363, 367, 460

Flashback Query, 374RETENTION NOGUARANTEE clause, 363RETENTION parameter, 964, 965retention period, Oracle Secure Backup, 789RETENTION POLICY parameter, RMAN, 762return codes, SQL*Loader utility, 639REUSE parameter, 828REUSE_DATAFILES parameter, Data

Pump, 707REUSE_DUMPFILE parameter, Data Pump, 691reverse engineering, databases, 38reverse key indexes, 301, 1072Review page, SQL Access Advisor, 323REVOKE CATALOG command, RMAN, 774REVOKE CREATE SESSION statement, 548REVOKE statement, 568, 569revoking object privileges, 573rewrite integrity, materialized views, 316REWRITE_OR_ERROR hint, 315Risk Matrix, 618rlogin command, UNIX/Linux, 78, 79rm command, UNIX/Linux, 59, 62

Page 98: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1318 ■IN D E X

RMAN (Recovery Manager), 741–784, 809–814advantages of, 810architecture, 743–744benefits of, 742–743block media recovery (BMR), 808, 864catalog reports, 759change-tracking, 185channels, 753, 764cloning databases, 834–838connecting to recovery catalog, 746connecting to RMAN, 745–746, 767–768control file recovery, 825–826converting datafiles to match endian

format, 721data block corruption, 167datafile recovery, 819ending RMAN session, 745identifying necessary files for recovery, 812image copies, 752–753incomplete recovery, 820–823large pool, 193making RMAN output visible, 747managing/monitoring database, 213Media Management Layer (MML), 744, 745migrating databases to ASM, 919–920monitoring/verifying RMAN jobs,

782–784, 813Oracle media recovery process, 807performing hot restore with, 816proxy copies, 753recovering datafiles without backup,

828–829recovery catalog, 744, 766–772recovery with RMAN, 809–814redirecting output to log file, 747registering database, 768–769restore optimization, 810scripting with RMAN, 747–752starting database using, 814storing metadata, 744tablespace point-in-time recovery (TSPITR),

840–841tablespace recovery, 817–818terminology, 752–753user-managed recovery procedures, 813–814virtual private catalogs, 772–774whole database recovery, 814–816

RMAN backupsarchival (long-term) backups, 780–782archived logs, 775backing up entire database, 774backing up online with scripts, 775backup and recovery architecture, 201backup formats, 753backup guidelines, 730backup pieces, 735, 752backup retention policy parameters,

762–763

backup sets, 752backup tags, 753block-change tracking, 779compressed backups, 780compressing, 780checking if backup possible, 811control file, 765–766, 776, 784–785cross-checking backups made with

RMAN, 783cumulative backup, 756, 757datafiles, 777detecting physical/logical corruption, 783differential backup, 756, 757encrypting RMAN backups, 781examples of, 774–777fast incremental backups, 779file locations, 755files, 178image copy backups, 756incremental backups, 756–757, 778, 812limiting maximum size of, 781logical check of backup files, 756making copies of, 754monitoring and verifying RMAN jobs,

782–784open backups, 792optimization parameters, 765Oracle Secure Backup intermediary, 789performing backup and recovery tasks, 813physical database backups, 725restarting RMAN backup, 777specifying limits for backup duration,

777–778tablespaces, 777user-managed backups as alternative, 790

RMAN client, 743rman command, 745RMAN commands, 755–761

ALLOCATE CHANNEL, 757BACKUP, 769, 755–757BACKUP ARCHIVELOG ALL, 775BACKUP AS COMPRESSED

BACKUPSET, 780BACKUP AS COPY, 756, 757BACKUP CONTROLFILE, 785BACKUP CURRENT CONTROLFILE, 776BACKUP DATABASE, 774, 775BACKUP DATAFILE, 777BACKUP INCREMENTAL LEVEL,

756–757, 778BACKUP TABLESPACE USERS, 777BACKUP VALIDATE, 783, 784BLOCKRECOVER, 864CATALOG, 759, 760, 770CHECKSYNTAX parameter, 749CONFIGURE, 753, 761–766CONNECT CATALOG, 767COPY, 758, 769CREATE CATALOG, 768

Page 99: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1319■I N D E X

CREATE GLOBAL SCRIPT, 750CREATE SCRIPT, 748, 750CROSSCHECK, 758, 761, 783DELETE, 758, 759DELETE SCRIPT, 750DROP CATALOG, 768, 772DUPLICATE, 810, 834–837EXECUTE SCRIPT, 749exit, 745FLASHBACK DATABASE, 854IMPORT CATALOG, 771, 772job commands, 757–758LIST, 760–761, 810LIST INCARNATION, 823LIST SCRIPT NAMES, 750, 761operating system file executing, 749PRINT SCRIPT, 750, 751RECOVER COPY, 778RECOVER DATABASE, 815REGISTER DATABASE, 769REPLACE SCRIPT, 752REPORT, 758–760REPORT SCHEMA, 759, 769RESTORE, 811RESTORE DATABASE, 814, 815RESYNC CATALOG, 769, 770RUN, 749, 757SET NEWNAME, 815SHOW ALL, 761SWITCH, 757SWITCH DATABASE, 816UPGRADE CATALOG, 771USING clause, 747, 750, 751VALIDATE, 761, 783–784VALIDATE BACKUP, 810–811VALIDATE BACKUPSET, 761, 811

RMAN configuration parameters, 761–766archivelog deletion policy, 766backup optimization, 765backup retention policy, 762–763channel configuration, 764compression, 764CONFIGURE command, 762control file backups, 765–766default device type, 763default values, 761

viewing parameters changed from, 762degree of parallelism, 765encryption, 763, 764optimization parameters, 765RETENTION POLICY configuration, 762

RMAN executable, 743RMAN repository, 743, 744rmdir command, UNIX/Linux, 62ROLE_ROLE_PRIVS view, 577roles, 574–577

as alternative to granting privileges, 612CONNECT role, 574Create Role Properties page, 150

creating, 575creating Database Control roles, 150Data Pump Export/Import utility, 703DBA role, 574DBA views managing, 577default role, 574DELETE_CATALOG_ROLE, 569disabling, 576, 618dropping, 577enabling, 577EXECUTE_CATALOG_ROLE, 569EXP_FULL_DATABASE role, 574granting privileges through roles, 618granting privileges to roles, 575granting role to another user, 576granting role WITH ADMIN OPTION, 576granting roles, recovery catalog, 767IMP_FULL_DATABASE role, 574IMPORT_FULL_DATABASE role, 705predefined roles, 574PUBLIC role, 613PUBLIC user group and roles, 576RESOURCE role, 574role authorization, 575–576secure application roles, 618SELECT_CATALOG_ROLE, 569

ROLE_SYS_PRIVS view, 577ROLE_TAB_PRIVS view, 577ROLLBACK command, 198, 200

exiting SQL*Plus session, 102rollback method, conn, JDBC, 540rollback phase, automatic checkpoint

tuning, 932rollback segments

database creation log, 484SET TRANSACTION USER … statement, 365undo management, 921using CTAS with large tables, 132using traditional rollback segments, 356

ROLLBACK statement, 263, 338, 339–340roll-forward phase, automatic checkpoint

tuning, 932rolling back transactions, 196, 197, 198, 804, 806rolling forward see cache recoveryROLLUP operator, GROUP BY clause, SQL, 1235root directory, UNIX, 47, 57, 63, 399root user, Oracle Database 11g, 414root.sh script

backing up, post-installation, 424installing Grid Control, 154, 155installing Oracle software, 420, 422

ROUND function, SQL, 1229ROUND_ROBIN method, resource consumer

groups, 557row data section, data blocks, 167row exclusive locks, 349%ROWCOUNT attribute, PL/SQL, 1246ROWID, B-tree index, 298ROWID method, online data redefinition, 936

Page 100: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1320 ■IN D E X

ROWID table access, query optimization, 1052row-level access, VPD, 578row-level Flashback techniques, 848row-level locks, 347, 348, 349row-level security, 583, 584, 585rows

identifying changed row versions, 375INSERT/DELETE/UPDATE statements, 263row expiry time/SCN, 371storing table rows, 267

ROWS parameter, SQL*Loader, 634, 641%ROWTYPE attribute, PL/SQL, 1242, 1244RPAD function, SQL, 1228rule-based optimization, 1047RULES keyword, 668–670RUN command, RMAN, 749, 757RUN command, SQL*Plus, 125, 126run queue length, 1153RUN_CHAIN procedure, 1010RUN_CHECK procedure, 1033runInstaller script, 415, 416, 418RUN_JOB procedure, 1000runnable process, UNIX, 80runtime area, PGA memory, 194runtime option, installing Oracle Client, 518RUN_TO_COMPLETION method, 557RVWR (recovery writer), 857rwx group, file permissions, UNIX, 60, 61

■S-S option (silent), SQL*Plus, 115salt, encryption algorithms, 608SAM tool, 408SAME (stripe-and-mirror-everything),

399, 1160sample data, performance statistics, 948SAMPLE parameter, Data Pump, 694sampling data dynamically, 463SANs (Storage Area Networks), 93sar command, UNIX, 83, 1153, 1159, 1177SAVE command, SQL*Plus, 106, 124saved metrics, 952SAVEPOINT statement, 263, 339savepoints, rolling back transactions, 198scalability, 1141–1142

OEM, 139Oracle Net Services features, 512

Schedule page, SQL Access Advisor, 323Scheduler, 208, 994–1019

architecture, 997attribute management, 1017automated maintenance tasks, 1020automatic optimizer statistics collection,

898–899calendaring expression, 999chain jobs, 996chains, 995, 1008–1010components, 994–995, 996–997

managing, 998–1000, 1011–1017

CREATE JOB privilege, 997database jobs, 995database management, 147, 211DBMS_JOB package compared, 996default operation windows, 899detached jobs, 996events, 995, 1010–1011EXECUTE privileges, 997external jobs, 996gathering statistics, 1047GATHER_STATS_JOB, 898–899job classes, 996, 1011–1013job table, 997jobs, 994

administering, 1000creating, 998–999default scheduler jobs, 1019managing, 998–1000managing external jobs, 1002–1006monitoring scheduler jobs, 1017–1019specifying repeat interval, 999–1000

lightweight jobs, 996, 1000–1002linking to Resource Manager, 996MANAGE SCHEDULER privilege, 997,

1013, 1015managing Scheduler attributes, 1017managing/monitoring database, 213object naming, 997privileges, 997–998programs, 995, 1006–1007purging job logs, 1019resource consumer groups, 1011SCHEDULER_ADMIN role, 997schedules, 995, 1007–1008slaves, 997types of Scheduler jobs, 995–996window groups, 997, 1017windows, 996, 1013–1017

Scheduler Agentcreating/enabling remote external jobs,

1005–1006installing/configuring, 1004–1005managing external jobs, 1002setting registration password for, 1003

Scheduler wait class, 1163SCHEDULER_ADMIN role, 997schedules, Oracle Scheduler, 995, 1007–1008

creating event-based schedules, 1011windows compared, 1013

schedulinglarge jobs, Oracle, 554performing backups with Oracle Secure

Backup, 789serializable schedules, 342specifying limits for backup duration, 777UNIX jobs, 77

schema mode, Data Pump Export, 688, 705schema owner, 264

granting object privileges, 572

Page 101: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1321■I N D E X

Schema page, Database Control, 147schema-independent users, 603schemas

database schemas, 20logical database structures, 165Oracle Database 11g sample schemas,

1221–1222SET SCHEMA statement, 327shared schemas, LDAP, 603

SCHEMAS parameter, Data Pump, 688, 705, 708schemas, Oracle, 264–265, 327SCN (system change number), 199

committing transactions, 198consistent database backups, 727control files, 174converting between time stamps and

SCNs, 847ENABLE_AT_SYSTEM_CHANGE_NUMBER

procedure, 369Flashback Database, 859, 860Flashback Versions Query, 372incomplete recovery using RMAN, 820, 822TO SCN clause, FLASHBACK TABLE, 378undo records, 356user-managed incomplete recovery, 824VERSIONS_STARTSCN pseudo-column, 371

SCNHINT parameter, 380, 869SCN_TO_TIMESTAMP function, 847scope, SPFILE dynamic parameter changes, 496SCOPE clause, ALTER SYSTEM, 496scp command, UNIX/Linux, 79scripting with RMAN, 747–752scripts

see also SQL scriptscoraenv script, 424dbshut.sh script, 423dbstart.sh script, 423oraenv script, 424post upgrade actions script, 439updating shutdown/start up scripts, 423upgrade actions script, 438upgrade script, 438

SDK Instant Client packages, 520se (storage element), Oracle Secure Backup, 789SEC_CASE_SENSITIVE_LOGON parameter,

465, 491, 597, 615SEC_MAX_FAILED_LOGIN_ATTEMPTS

parameter, 465, 615Second Normal Form (2NF), 31–33secondary indexes, 297, 1070, 1071second-generation database management

systems see RDBMSsec_protocal_error_xyz_action parameters, 615SEC_RELEVANT_COLS parameter, 585SECTION SIZE parameter, RMAN, 781, 784secure application roles, 618secure configuration, automatic, 611SecureFiles, 472

securitysee also authentication; passwordsaccess control lists, 616, 617Advanced Security option, 618alerts, 617altering profiles, 619application security, 618aspects of database security, 543auditing database usage, 586–596authenticating users, 596–602automatic secure configuration, 611centralized user authorization, 602checking for latest security patches, 617column-level security, 312controlling database access, 567–586Critical Patch Updates, 617data encryption, 603–608database auditing, 612database management, 147DBA role, 3, 4DBA views managing users/roles/

privileges, 577default auditing, 611determining user’s currently executing

SQL, 619directory naming method, 534disabling roles, 618enhancing database security, 611–622enterprise user security, 603–611fine-grained data access, 578–586granting privileges, 612granting privileges through roles, 618implementing physical database design, 37killing user’s session, 620listing user information, 619logging in as different user, 620managing users, 619MetaLink, 617multiple DBAs, 613OEM, 138OID (Oracle Internet Directory), 611operating system authentication, 612Oracle Advanced Security, 535Oracle Backup Web Interface tool, 788password-related parameters, user profiles,

549, 550password-specific security settings, 611Peter Finnegan’s Oracle security web site, 614privileges, 567–574protecting data dictionary, 613PURGE option, DROP TABLE command, 852RAID systems, 88recovery catalog, 770restricting SQL*Plus usage, 618Risk Matrix, 618roles, 574–577schemas, 165securing listener, 614

Page 102: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1322 ■IN D E X

securing network, 614setting security-related initialization

parameters, 615setting UNIX permissions, 613stored procedures, 577tablespace encryption, 608–610underlying objective, 543user accounts, 611value-based security, 312views, 312, 577

security policies, 583–585Security Settings window, DBCA, 488security, SQL*Plus see SQL*Plus securitysecurity-related parameters, 472Segment Advisor, 212

advice levels, 930automatic performance tuning

features, 1132Automatic Segment Advisor, 212, 931choosing candidate objects for

shrinking, 930Database Control Segment Advisor page, 931description, 977managing/monitoring database, 214modes, 930segment shrinking using, 930, 935using, 980

Segment Advisor Recommendations page, 932, 980

SEGMENT ATTRIBUTES option, Data Pump, 711

segment-level statistics, 1173segment shrinking, 927–930segment space management, 217–218, 219, 221segments, 166, 169

analyzing segment growth, 268DBA_SEGMENTS view, 244extent allocation/deallocation, 220segment growth, 219tablespace space alerts, 226tablespaces, 166, 170types of, 220unable to extend segment error, 385

Segments by Physical Reads section, AWR, 971sel clause, COPY command, SQL*Plus, 133Select a Product to Install window, Grid

Control, 155SELECT ANY DICTIONARY privilege, 569Select Configuration Options window, 419Select Installation Type window, 417SELECT statement

AS OF clause, 367–368CTAS command, 273DML statements, 263locking, 349VERSIONS BETWEEN clause, 370

SELECT statement, PL/SQL, 1242SELECT statement, SQL, 1223–1224, 1226SELECT_CATALOG_ROLE, 569, 570

SELECT_CURSOR_CACHE procedure, 1217Selecting Database Instance window,

DBUA, 431selection operations, 21, 1046selectivity, 1065self join, SQL, 1233self-managing database, 877semantic data models, 25Semantic Web, The, 25semaphores, 404semi-structured data models, 40SEMMNS kernel parameter, 413SEQUEL (structured English query

language), 22SEQUENCE function, SQL*Loader, 637SEQUENCE option, SET UNTIL command, 821sequence privileges, 571sequences, 327–328, 329

SQL*Loader utility, 643SEQUENTIAL_ORDER, rules, 670serializable isolation level, 344, 346serializable schedules, data concurrency, 342server configurations, 180server error triggers, 591server file, 493Server Generated Alerts, 386Server Manageability Packs, 459Server page, Database Control, 146–147server parameter file see SPFILEserver processes, 179–180, 197

see also Oracle processesserver processes, RMAN, 744server software, installing, 416–420server-executed commands, SQL, 103server-generated alerts, 211, 952–953SERVEROUTPUT variable, SQL*Plus, 108,

109–110servers, 45, 47server-side access controls, securing

network, 614service level agreements see SLAsservice metrics, 951Service Name Configuration page, 528service names, database, 514service registration, dynamic, 183SERVICE_NAME parameter, 452, 529SERVICE_NAMES parameter, 514, 521services command, lsnrctl utility, 522Services Summary, checking listener status, 522SERV_MOD_ACT_TRACE_ENABLE

procedure, 1106session metrics, 951session multiplexing, 180session-related parameters, 456session sample data, 948session switching, 561session variables, SQL*Plus, 126SESSION_CACHED_CURSORS parameter,

1140, 1141

Page 103: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1323■I N D E X

session-control statements, SQL, 262SESSION_PRIVS/ROLES views, 577sessions

Active Session History (ASH), 210, 971–975ACTIVE_SESSION_POOL parameter, 560ACTIVE_SESS_POOL_MTH parameter, 560altering properties of user sessions, 262audit by session, 587creating plan directives, 560creating session temporary table, 278determining session-level CPU usage, 1155killing user sessions, 620LICENSE_MAX_SESSIONS parameter, 461LogMiner utility, 844–845QUEUEING_MTH parameter, 560specifying maximum number of, 461sys_context discovering session

information, 579terminating database sessions, 75Top Sessions page, 1200UNIX session, 47using Database Control to manage session

locks, 354–355V$ACTIVE_SESSION_HISTORY view, 1169viewing Data Pump sessions, 714

SESSIONS parameter, 455sessions, SQL*Plus see SQL*Plus sessionsSESSIONS_PER_USER parameter, 549SESSION_TRACE_ENABLE procedure, 1175SESSION_USER attribute, USERENV

namespace, 579, 580SET command, SQL*Plus, 106–107

ALTER SESSION command, 262controlling security via SET ROLE

command, 105getting list of environment variables, 107SET ERRORLOGGING command, 111SET SERVEROUTPUT command, 109–110SET SQLPROMPT command, 118

SET NEWNAME command, RMAN, 815set operations, 21set operators, 263, 1227set password clause, lsnrctl utility, 524SET ROLE command, 105, 618SET SCHEMA statement, 327SET TRANSACTION statement, 263

Automatic Undo Management (AUM), 357USER ROLLBACK SEGMENT clause, 365

SET UNTIL command, 820, 821, 822SET UNUSED command, 271SET_ATTRIBUTE procedure, 1005, 1008, 1018SET_ATTRIBUTE_NULL procedure, 1017SET_ATTRIBUTES procedure, 1016setAutoCommit method, conn, JDBC, 540SET_CONSUMER_GROUP_MAPPING

procedure, 564SET_CONSUMER_MAPPING_PRI

procedure, 564

SET_DEFAULT_TASK procedure, 890SET_DEFAULT_TASK_PARAMETER procedure,

884, 890setenv command, UNIX/Linux, 54SET_EV procedure, 1175SET_IDENTIFIER procedure, 1106SET_INITIAL_CONSUMER_GROUP

procedure, 563set-oriented relational model, 20SET_SCHEDULER_ATTRIBUTE procedure, 1017SET_SESSION_LONGOPS procedure, 943SET_SESSION_TIMEOUT procedure, 385, 386SET_SQL_TRACE procedure, 1101SET_SQL_TRACE_IN_SESSION procedure, 1102SET_TABLE_PREFS function, 1057SET_TASK_PARAMETER procedure, 324, 978SET_THRESHOLD procedure, 955settings, SQL*Plus, 115SET_TUNING_TASK_PARAMETERS procedure,

1037, 1117SET_TUNING_TASK_PARAMETERS view, 1117SETUID files, 613Setup page

Database Control, 148–149Grid Control, 159

Setup Privileges window, Grid Control, 156setupinfo file, connecting to Grid Control, 157SEVIS (Student and Exchange Visitor

Information System), 1193SGA (system global area), 187–193

ASM Cache component, 906automatic memory management, 195–196,

894, 896components, 187database buffer cache, 187, 188–189, 190Java pool, 187, 193large pool, 187, 193managing/monitoring database, 214memory allocation, 194memory management, 894memory-configuration parameters, 456MEMORY_TARGET parameter, 457multiple database block sizes, 189–190PRIVATE_SGA parameter, 549redo log buffer, 187, 192–193Result Cache Memory, 1120shared pool, 187, 191–192SHOW SGA command, 117sizing buffer cache, 1144Streams pool, 187, 193tuning shared pool, 1133

SGA_TARGET parameter, 195, 196automatic memory management, 895,

896, 897db file scattered read wait event, 1177managing result cache, 1120setting size of, 1142

sh (Bourne shell), 45see also shells, UNIX

Page 104: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1324 ■IN D E X

SH (sales history) schema, 1222shadow process, Data Pump, 686Shallahamer, Craig A., 1148share lock mode, 199shared context sensitive security policy, 584shared database objects, 987–991

comparing data, 987–989converging data, 990–991

shared libraries, 1190shared memory, 894, 1190shared pool, 187, 191–192

components, 1133delays due to shared pool problems, 1191dictionary cache, 1134–1135flushing, 1135how Oracle processes transactions, 197LARGE_POOL_SIZE parameter freeing

memory in, 459library cache, 191, 1133–1134Oracle’s guidelines, 456pinning objects in, 1142–1143reducing parse-time CPU usage, 1157sizing, 1142tuning, 1133–1135

shared pool latch, 1180shared schemas, LDAP, 603shared server architecture, 512shared server configuration, 180shared static security policy, 584SHARED_POOL_SIZE parameter, 195shell scripts, UNIX, 45, 68–74

evaluating expressions, 69executing with arguments, 70flow control structures, 71–74making variables available to, 54

shells, UNIX, 45–46changing shell limits, preinstallation, 406changing shell prompt, 51customizing environment, 55running programs with nohup option, 75shell prompts, 47shell variables, 53, 54, 55, 69

ship.db.cpio.gz file, 415SHMMAX kernel parameter, 413SHOW ALL command, RMAN, 761SHOW command, SQL*Plus, 116–118SHOW ERRORS command, SQL*Plus, 111SHOW HM_RUN command, 1034SHOW INCIDENT command, 1026SHOW PARAMETER command, 474SHOW PARAMETER UNDO command, 364SHOW RECYCLEBIN command, 850SHRINK SPACE clause

ALTER TABLE command, 929ALTER TABLESPACE command, 231–232

shrinking segments, online, 927–928SHUTDOWN ABORT command, 503

crash and instance recovery, 804system change number (SCN), 200

SHUTDOWN command, ASM instances, 908, 910, 911

SHUTDOWN command, SQL*Plus, 502–505SHUTDOWN IMMEDIATE command, 492, 503SHUTDOWN NORMAL command, 502shutdown scripts, updating post-

installation, 423SHUTDOWN TRANSACTIONAL command, 503shutting down database from SQL*Plus,

502–505SID see ORACLE_SID variablesignificance level thresholds, 954SIGTERM signal, 76silent mode, DBUA, 430silent mode, Oracle Universal Installer, 421, 422silent option (-S), SQL*Plus, 115SILENT parameter, SQL*Loader, 635Simplified Recovery Through Resetlogs

feature, 823simulated backups and restores, RMAN, 743Single Sign-On feature, 603single-baseline templates, AWR, 965single-pass operation, 194single-row functions, SQL, 1228site profile file, SQL*Plus, 110SIZE clause, 216, 230Sizing tab, DBCA, 488sizing, database, 37SKIP parameters, SQL*Loader, 636, 641, 642SLAs (service level agreements), 468, 731–732slash asterisk notation (/* ... */), SQL*Plus, 128slaves, Oracle Scheduler, 997SLAVETHR statistic, 1061SMALLFILE keyword, 237smallfile tablespaces, 172, 236, 238SMB (SQL Management Base), 1085system monitor (SMON) process, 181, 184

automatic checkpoint tuning, 932starting Oracle instance, 479

SMON timer idle event, 1181snapshot backup techniques, 730snapshot variables, AWR, 882snapshot-too-old error, 209, 356, 359, 360,

364, 959snapshots see AWR snapshotssoft parsing, 191, 343, 1135, 1136

latch contention, 1141Software and Support page, Database

Control, 148sort command, UNIX/Linux, 68SORT parameter, TKPROF utility, 1102sort segment, temporary tablespaces, 230SORT_AREA_SIZE parameter, 194SORTED_INDEXES parameter, SQL*Loader,

641, 642sorting data

by multiple columns, 1227guidelines for creating indexes, 297one-pass sort, 1149

Page 105: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1325■I N D E X

optimal sort, 1149ORDER BY clause, 263, 1226

sort-merge join, 1052source command, UNIX/Linux, 55space

DBMS_SPACE package, 298–299preinstallation checks, 401user’s space quota errors, 383

space alerts, 226–227space management

ADDM recommendations, 881automatic checkpoint tuning, 932–933automatic Segment Advisor job, 931Automatic Segment Space Management, 928automatic space management, 921–933Automatic Undo Management (AUM), 921Data Pump Export estimating, 696, 697Data Pump technology, 679DBA_FREE_SPACE view, 243DBMS_SPACE package, 255–256, 268deallocating unused space, 268, 928estimating space requirements, 268file management with OMF, 922–927finding unused space in segments, 928fragmentation, 928free space, 255–256managing flash recovery area, 740manual segment shrinking, 928–929monitoring resumable operations, 386online segment shrinking, 927–928preinstallation tasks, 400reclaiming unused space, 1090recursive CPU usage, 1158removing objects from Recycle Bin, 850Resumable Space Allocation, 382–386segment shrinking using Segment

Advisor, 930segment space management, 217–218temporary tablespace groups, 233

Space Summary, Performance page, Database Control, 145

SPACE_BUDGET_PERCENT parameter, SMB, 1085

SPACE_USAGE procedure, 255, 268specifiers of time interval, Scheduler jobs, 999Specify File Locations window, 155Specify Home Details window, 417sperrorlog table, SQL*Plus, 111SPFILE (server parameter file), 177, 446,

493–497see also initialization files; PFILEautomatic service registration, 521backup guidelines, 729cloning databases with RMAN, 836, 837DB_WRITER_PROCESSES parameter, 182making changes permanent, 447OMF control files, 250post-upgrade actions, 441reading SPFILE, 473

setting archivelog-related parameters, 491setting initialization parameters,

post-installation, 424spindles, disk I/O, 1159SPLIT PARTITION command, 291SPM (SQL Plan Management), 1080–1087

parallel execution, 1085SQL Management Base (SMB), 1085SQL plan baselines, 1080–1085

SPOOL command, SQL*Plus, 120, 121restriction levels, 106

spool files, manual upgrade process, 434, 441spool files, SQL*Plus, 120sps column, iostat command, 82SQL (structured query language)

see also PL/SQLanalyzing locks, 353–354cursors, 1245–1247determining user’s currently executing

SQL, 619efficient SQL, 1065–1075

avoiding improper use of views, 1075avoiding unnecessary full table scans, 1075bind variables, 1075bitmap join indexes (BJI), 1069indexing strategy, 1070–1073inline stored functions, 1074–1075monitoring index usage, 1073removing unnecessary indexes, 1073selecting best join method, 1068selecting best join order, 1070using hints to influence execution plans,

1067–1068using similar SQL statements, 1074WHERE clauses, 1065–1067

ending SQL and PL/SQL commands, 103grouping operations, 1234–1236hierarchical retrieval of data, 1232inefficient SQL, 1108–1110introduction, 22MODEL clause, 667–670operators, 1227optimal mode operation, 194Oracle SQL Developer, 136performing online data reorganization,

934–935regular expressions, 1237–1239selecting data from multiple tables,

1232–1234server-executed commands, 103single-pass operation, 194transforming data, 658–667using SQL to generate SQL, 135–136wildcard characters, 1224writing subqueries, 1236–1237XML and SQL, 261

SQL Access Advisor, 212, 320–324, 977automatic performance tuning features, 1132creating materialized views, 317

Page 106: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1326 ■IN D E X

evaluation mode, 321index recommendations, 303invoking through Database Control, 320–323invoking through DBMS_ADVISOR, 323managing/monitoring database, 214QUICK_TUNE procedure invoking, 324tuning SQL statements, 1127

SQL Access Mode, 1198SQL buffers, 125, 128SQL Developer, 401SQL files, Data Pump utilities, 681SQL functions, 1228–1232

aggregate functions, 1229, 1232analytical functions, 1231–1232conditional functions, 1230date functions, 1229general functions, 1230histograms, 1232hypothetical ranks and distributions, 1232inline stored functions for efficient SQL,

1074–1075inverse percentiles, 1231moving-window aggregates, 1231number functions, 1229period-over-period comparisons, 1231ranking functions, 1231ratio-to-report comparisons, 1231single-row functions, 1228statistical functions, 1231

SQL functions, list ofAVG, 1229CASE, 1230COALESCE, 1230CONCAT, 1228COUNT, 1229DECODE, 1230INSTR, 1228LENGTH, 1228LOWER, 1228LPAD, 1228MAX, 1229MIN, 1229NVL, 1230RANK, 1231REPLACE, 1228ROUND, 1229RPAD, 1228SUBSTR, 1228SUM, 1229SYSDATE, 1229TO_CHAR, 1230TO_DATE, 1229TO_NUMBER, 1230TO_TIMESTAMP, 1229TRIM, 1228TRUNC, 1229

SQL hash value, 343SQL Management Base (SMB), 1085SQL MERGE command, 269

SQL Net Services see Oracle Net ServicesSQL Ordered by Elapsed Time section, AWR, 970SQL Performance Analyzer, 213, 1216–1220

change management, 7database management, 148database upgrade management, 1081

SQL performance tuning tools, 1090–1105Autotrace utility, 1095–1099EXPLAIN PLAN tool, 1090–1095SQL Trace utility, 1099–1102TKPROF utility, 1102–1105

SQL plan baselines, 1081–1085SQL Plan Management see SPMSQL plans

OPTIMIZER_XYZ_BASELINES parameters, 462, 464

SQL processing, improving, 1075–1080materialized views, 1077partitioned tables, 1076stored outlines, 1077–1080table compression, 1076

SQL Profile feature, 1068SQL profiles, 1112, 1115, 1116, 1117SQL queries see query optimizationSQL Query Result Cache, 1124SQL Repair Advisor, 1023, 1035–1038SQL Response Time chart, Database

Control, 1196SQL scripts

@@commandfile notation, 129catdwgrd.sql, 434, 442catupgrd.sql, 434, 438, 439catuppset.sql, 438, 439caution when using /, 126, 128create directory containing, 397executing command scripts

consecutively, 129executing in SQL*Plus, 124–126utlrp.sql, 434utlu111i/utlu111s.sql scripts, 429, 434utluppset.sql, 434viewing script before executing, 128

SQL statements, 261–264, 1223–1226Automatic Tuning Optimizer (ATO), 1113AWR performance statistics for, 1184comparing performance of, 1127creating stored outlines for, 1079DDL statements, 264deadlocks, 340DELETE statement, 1225–1226DML statements, 263embedded SQL statements, 262executing, JDBC, 539–540identical statements, 1134identifying inefficiency in, 1127identifying problem statements, 1127identifying SQL with highest waits, 1171INSERT statement, 1225instance performance, 1194

Page 107: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1327■I N D E X

object privileges, 570performance tuning, 1042processing steps, 1133processing through JDBC, 538–540query processing stages, 1043–1046SELECT statement, 1223–1224session-control statements, 262stages of SQL processing, 343statement-level rollback, 340system-control statements, 262terminating in SQL*Plus, 101terminating, 130TKPROF utility information on, 1103transaction control statements, 263transactions, 196tuning, 1126–1127types of, 262undoing data changes, 374UPDATE statement, 1226using similar SQL statements, 1074wait events, 1162

SQL Test Case Builder, 211, 1023, 1038SQL Trace utility, 1099–1102

interpreting trace files with TKPROF, 1102–1103

monitoring index usage, 304providing parse information, 1135–1136tracing SQL statements, 1107tuning SQL, 1105turning on/off, 467

SQL transformation, CBO optimizing queries, 1051

SQL tuningconfiguring automatic tuning, 1117–1119GUI-based tools, 1120identifying inefficient SQL statements, 1127interpreting automatic tuning reports, 1119managing automatic tuning, 1118–1119managing tuning categories, 1115using dictionary views for, 1108, 1110views managing automatic tuning, 1114

SQL Tuning Advisor, 212, 976, 1111–1115automatic performance tuning

features, 1132Automatic SQL Tuning Advisor, 209, 212,

1115–1120Database Control, 1200DBMS_SQLTUNE package, 1113–1115evolving SQL plan baselines, 1083managing SQL profiles, 1115managing/monitoring database, 214OEM running, 1115performing automatic SQL tuning,

1113–1114superior SQL plan baselines, 1085

SQL Tuning Sets (STS), 1115, 1217, 1218SQL*Loader control file, 628–636

APPEND clause, 629BAD parameter, 635

BEGINDATA clause, 628, 630bind array, 634BINDSIZE parameter, 634command-line parameters, 633–636CONCATENATE clause, 630CONTINUEIF clause, 630CONTROL parameter, 633DATA parameter, 634data transformation parameters, 633data types, 632datafile specification, 630delimiters, 632DIRECT parameter, 634DISCARD parameter, 635DISCARDMAX parameter, 635ENCLOSED BY clause, 632ERRORS parameter, 634field list, 629fixed record format, 631INFILE parameter, 628, 630input file field location, 632INSERT clause, 629INTO TABLE clause, 629LOAD DATA keywords, 629LOAD parameter, 634LOG parameter, 635logical records, 630OPTIONS clause, 633PARALLEL parameter, 635physical records, 630POSITION clause, 632record format specification, 631REPLACE clause, 629RESUMABLE parameters, 635, 636ROWS parameter, 634SILENT parameter, 635SKIP parameter, 636stream record format, 631table column name specification, 631TERMINATED BY clause, 632USERID parameter, 633variable record format, 631

SQL*Loader utility, 207, 625, 627–645COLUMNARRAYROWS parameter, 641CONSTANT parameter, 636control file, 628–636conventional data loading, 639data-loading techniques, 642–645DATA_CACHE parameter, 641datafiles, 628DEFAULTIF parameter, 642DIRECT clause, 641direct-path loading, 639–642disabling constraints, 308dropping indexes before bulk data loads, 644external tables compared, 646EXPRESSION parameter, 636EXTERNAL_TABLE parameter, 653generating data during data load, 636

Page 108: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1328 ■IN D E X

generating external table creation statements, 653–656

invoking, 637–638loading data from table into ASCII file, 643loading into multiple tables, 644loading large data fields into a table, 643loading sequence number into a table, 643loading username into a table, 643loading XML data into Oracle XML

database, 645log files, 638–639MULTITHREADING parameter, 641NOLOGGING option, 644NULLIF parameter, 642optimizing use of, 642PARFILE parameter, 637password security, 638RECNUM column specification, 636redo entries, 640REENABLE clause, 642resumable database operations, 383return codes, 639ROWS parameter, 641SEQUENCE function, 637SKIP_INDEX_MAINTENANCE clause,

641, 642SKIP_UNUSABLE_INDEXES clause, 641, 642SORTED_INDEXES clause, 641, 642steps when using, 628STREAMSIZE parameter, 641sysdate variable, 637trapping error codes, 645types of data loading using, 627UNRECOVERABLE parameter, 640, 641, 642user pseudo-variable, 643viewing available parameters, 629WHEN clause, 642

SQL*Net message from client idle event, 1181SQL*Plus, 207

& prefixing variable names, 126actions following commands, 123adding comments to scripts, 132archiving redo log files, 135calculating statistics, 123caution when using / command, 126, 128continuation characters, 102copying tables, 132–133creating command files, 124–129creating reports, 122, 123–124creating web pages using, 134creating Windows batch script, 126creating/deleting session variables, 126displaying environment variable values, 116editing within SQL*Plus, 129–134error logging, 111–112establishing Oracle connectivity, 517executing contents of SQL*Plus buffer, 125executing packages/procedures, 121executing previous command entered, 128

executing SQL command scripts consecutively, 129

executing SQL scripts in, 124–126formatting output, 122Instant Client packages, 520listing SQL commands, 128listing table columns and specifications, 119making DML changes permanent, 133Oracle SQL*Plus interface, 97predefined variables, 118, 127preserving environment settings, 115printing report footer text, 123printing report header text, 123privileged connections, 99prompts, 99reasons for using, 97recovering database/files/tablespaces, 134removing current settings, 115restricting usage of, 618rollback command, 102saving output to operating system, 120saving SQL buffer contents to file, 124saving user input in variable, 121sending messages to screen, 121setting default editor’s name, 124setting environment, 106–107showing database instance name in

prompt, 118showing help topics, 106showing properties of columns, 123shutting down database from, 502–505specifying where formatting changes

occurs, 122starting database from, 497–499substitution variables, 126terminating SQL statements, 101, 132turning off messages after code

execution, 108using comments in, 128using operating system commands from, 119using SQL to generate SQL, 135–136viewing details about archive logs, 135viewing output screen by screen, 121viewing previous command, 128viewing SQL script before executing, 128

SQL*Plus command files, 124–129SQL*Plus command-line options, 113–115SQL*Plus commands

administrative/management commands, 115–118

database administration commands, 134–135

disabling commands, 105doing commands, 118–122ending SQL*Plus commands, 103formatting commands, 118, 122–124list of available commands, 106local commands, 103restriction levels for, 106

Page 109: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1329■I N D E X

running commands sequentially, 124–129show errors command, 111terminating SQL*Plus commands, 102types of commands, 103working commands, 118–122

SQL*Plus commands, list ofACCEPT, 121APPEND, 131ARCHIVE LOG, 135BREAK, 122BTITLE, 123CHANGE, 129CLEAR, 115COLUMN, 123COMPUTE, 123CONNECT, 100COPY, 132–133DEFINE, 126DEL, 131DESCRIBE, 119ed, 130EDIT, 106EXECUTE, 121EXIT, 102GET, 106, 128GRANT, 136HELP INDEX, 106HOST, 105, 106, 119INPUT, 130LIST, 128MARKUP, 134PASSWORD, 547PAUSE, 121PROMPT, 121QUIT, 102RECOVER, 134REMARK, 128, 132REPFOOTER/REPHEADER, 123RESTRICT, 105RUN, 125, 126SAVE, 106, 124SET, 106–107SET ERRORLOGGING, 111SET SERVEROUTPUT, 109–110SHOW, 116SHUTDOWN, 502–505SPOOL, 106, 120, 121SQLPROMPT, 118START, 106STARTUP, 497–499STORE, 106, 115TTITLE, 123UNDEFINE, 126

SQL*Plus environment variables, 107–108AUTOCOMMIT, 133BLOCKTERMINATOR, 132changing, 109creating/deleting session variables, 126displaying all values, 116

execution order of glogin.sql and login.sql file, 111

predefined variables, 127preserving environment settings, 115SERVEROUTPUT, 108, 109–110setting SQL*Plus environment, 106–107SHOW ALL command, 116specifying global preferences, 110specifying individual preferences, 110–111SQLTERMINATOR, 132

SQL*Plus Instant Client, 98SQL*Plus security, 103–106SQL*Plus sessions

connecting through Windows GUI, 101connecting using CONNECT command, 100connectionless SQL*Plus session, 101customizing session, 113exiting session, 102NOLOG option, 101overriding environment variables

within, 111preferred session settings, 108privileged connections using AS clause, 99rollback command, 102setting Oracle environment for, 98starting session from command line, 98–100starting session, 97–101

SQLException method, Java error handling, 540SQLFILE parameter, Data Pump, 681, 706–707SQL_HANDLE attribute, 1083SQLJ, 1253SQLLDR command, SQL*Loader, 637–638sqlnet.ora file

backup guidelines, 729external naming method, 534local naming method, connections, 526OID making database connections, 535securing network, 614

SQLPLUS commandreceiving FAN events, 101

sqlplus commandeasy connect naming method, 529starting SQL*Plus session from command

line, 98sqlplus.sql file, 116SQLPLUS_RELEASE variable, 128SQLPROMPT command, 118SQLPROMPT variable, 108SQLTERMINATOR variable, 132SQL_TRACE parameter, 467, 1101SQLTUNE_CATEGORY parameter, 1115SQL/XML operators, 1249SREADTIM statistic, 1061ssh command, UNIX/Linux, 79staging directory, Oracle installation, 416staging element, Oracle Streams, 671STALE_TOLERATED mode, 316, 465standard auditing see auditingStandard Edition, 417

Page 110: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1330 ■IN D E X

standard error/input/output, UNIX, 56standard.rsp response file template, 422standby databases

see also Oracle Data Guardavoiding data center disasters, 802high-availability systems, 798Oracle Data Guard and, 799–800physical and logical, 799

start command, lsnrctl utility, 523START command, SQL*Plus, 106START keyword, 1061START WITH clause, SQL, 1232START_CAPTURE procedure, 1211START_DATE attribute, 999, 1014starting database from SQL*Plus, 497–499START_JOB parameter, Data Pump, 703,

704, 713START-POOL procedure, 532STAR_TRANSFORMATION_ENABLED

parameter, 1078START_REDEF_TABLE procedure, 938, 939START_REPLAY procedure, 1214START_TIME attribute, CREATE_WINDOW, 1015STARTUP command, ASM instances, 907, 908STARTUP command, SQL*Plus, 497–499STARTUP MOUNT command, 492, 498startup scripts, post-installation update, 423startup time, improving for instances, 805STARTUP UPGRADE command, 427, 437stateful/stateless alerts, 952Statement object, JDBC, 539statement timed out error, 384statement-level audit, 587statement-level read consistency, 345, 346, 356statements see SQL statementsstatement_types parameter, ADD_POLICY, 594static data dictionary views, 204static parameters, 448, 496static security policy, 584statistical functions, SQL, 1231statistics

see also Automatic Optimizer Statistics Collection

Active Session History (ASH), 971–975automated tasks feature, 211Automatic Tuning Optimizer (ATO), 1112Automatic Workload Repository (AWR), 210AUX_STATS$ table, 1060calculating, SQL*Plus, 123collecting fixed object statistics, 1062collecting operating system statistics, 1086,

1060–1062collecting optimizer statistics, 299collecting real dictionary table statistics, 1063collecting statistics for column groups,

1058, 1059collecting statistics on dictionary tables,

1062–1063COMPUTE STATISTICS option, 299

creating column groups, 1059database usage metrics, 151Database Usage Statistics property

sheet, 152database wait statistics, 1162–1163DBA_TAB_COL_STATISTICS view, 1049DBA_TAB_STATISTICS table, 1049DBMS_STATS package collecting, 1053–1056deferring publishing of statistics, 1056–1057determining publishing status of

statistics, 1056dynamically sampling data, 463effect when statistics not collected, 1063examining database feature-usage

statistics, 152expression statistics, 1059extended optimizer statistics, 1058–1060frequency of statistics collection, 1063GATHER_STATS_JOB, 1047–1049INDEX_STATS view, 334making pending statistics public, 1057manageability monitor (MMON)

process, 185managing/monitoring database, 213manual optimizer statistics collection, 900multicolumn statistics, 1058operating system statistics, 1061OPTIMIZER_USE_PENDING_STATISTICS

parameter, 463Oracle recommendation, 1065problems due to bad statistics, 1191providing statistics to CBO, 1053–1056refreshing statistics frequently, 1086sampling data, 1053segment-level statistics, 1173setting publishing status of statistics, 1057specifying level of statistics collected, 461specifying use of pending statistics, 463statistics retention period, AWR, 960system usage statistics, 1181time-model statistics, 879–880TIMED_STATISTICS parameter, 468turning on statistics collection, 1167using histograms, 1086–1087using OEM to collect optimizer statistics,

1064–1065V$CPOOL_CC_STATS view, 533V$CPOOL_STAT view, 533V$FILESTAT view, 246V$SESSSTAT view, 959V$SYSSTAT view, 959when manual collection is required, 1054

statistics collection job, 1132statistics management, 147STATISTICS_LEVEL parameter, 461

ADDM, 881, 883, 888automatic optimizer statistics collection,

898, 899creating/deleting snapshot baselines, 963

Page 111: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1331■I N D E X

server-generated alerts feature, 953setting trace initialization parameters, 1100

Statspack utility, 959status command, lsnrctl utility, 521STATUS command, Data Pump, 703, 704, 713STATUS function, DBMS_RESULT_CACHE, 1123status information, Grid Control, 159STATUS parameter, Data Pump, 699, 708status.sql script, 125stop command, lsnrctl utility, 523STOP keyword, operating system

statistics, 1061STOP_JOB command, Data Pump, 686, 702,

703, 704, 713STOP_JOB procedure, 1000STOP_ON_WINDOW_CLOSE attribute, 1016STOP_POOL procedure, 532storage, 729

ASM (Automatic Storage Management), 900–920

Storage Area Networks (SANs), 93storage element (se), Oracle Secure Backup, 789STORAGE option, Data Pump Import, 711Storage Options window, DBCA, 487storage parameters, 220–222storage, database

Automatic Storage Management (ASM), 209database management, 146disk storage requirements, 392flash recovery area, 734implementing physical database design, 37

storage, UNIX, 93–95STORAGE_CHANGE parameter, 978STORE command, SQL*Plus, 106, 115, 116STORE IN clause, CREATE TABLE, 283stored execution plan, 1112stored functions, inline, 1074–1075stored outlines, 1077–1080stored procedures

database security, 577definer’s rights, creating with, 573displaying output on screen, 109invoker’s rights, creating with, 573Java stored procedures, 1252

stored scripts, RMAN, 747stream record format, SQL*Loader, 631streaming, table functions, 662streams pool, 187, 193, 1148STREAMSIZE parameter, SQL*Loader, 641STREAMS_POOL_SIZE parameter, 193, 195, 673stretch cluster, ASM, 909stripe size, RAID systems, 88stripe sizes, logical volumes, 1159stripe-and-mirror-everything (SAME), 399, 1160striping

ASM, 901, 914disk striping, 88, 467RAID options, 89–90

STRIPING attribute, ASM, 910

strong authenticationldap_directory_sysauth parameter, 615

STS (SQL Tuning Sets), 1115, 1217, 1218subclasses, object-oriented database model, 39SUBMIT_PENDING_AREA procedure, 562SUBPARTITION BY HASH clause, 288SUBPARTITION BY LIST clause, 288SUBPARTITION BY RANGE clause, 289, 290SUB_PLAN parameter, resource plans, 560subqueries, SQL, 263, 1067, 1236–1237substitution variables, SQL*Plus, 126SUBSTR function, SQL, 663, 1228success code, SQL*Loader, 639SUM function, SQL, 1229summaries, materialized views, 314Summary window, Oracle Universal

Installer, 419super administrator account see SYSMANsupplemental logging

Flashback Transaction Backout feature, 868LogMiner utility, 842–843

Support Workbench, 211, 1022, 1028–1032invoking SQL Repair Advisor from, 1035

suppressed mode, Oracle Universal Installer, 421, 422

suspended operations, 385, 386suspending databases, 505, 945swap ins/outs, memory management, 81swap space

preinstallation checklist, 413preinstallation checks, 401, 403virtual memory, 1158

swappingaffecting performance, 1205system usage problems, 1188

SWITCH command, RMAN, 757using RMAN for TSPITR, 841

SWITCH DATABASE command, RMAN, 816SWITCH_FOR_CALL parameter, 561, 565SWITCH_GROUP parameter, 561SWITCH_IO_MEGABYTES parameter, 561SWITCH_IO_REQS parameter, 561SWITCH_XYZ parameters, plan directives, 942symbolic links, UNIX, 58

automatic database startup, 501symbolic names, UNIX, 47, 49symbolic notation, modifying permissions,

60, 61synchronization

ASM and Cluster Synchronization Service, 902–904

fast mirror resync feature, ASM, 908–909SYNCHRONIZATION parameter, 1214SYNC_INTERIM_TABLE procedure, 940synonyms, 265, 324–327

DBA_SYNONYMS view, 326, 329SYS parameter, TKPROF utility, 1102SYS schema, 569

Page 112: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1332 ■IN D E X

SYS userAUDIT_SYS_OPERATIONS parameter, 588creating database, 481data dictionary tables, 203default password, 475

SYS.AUD$ table, 588, 595, 596sys.fga_aud$ table, 595SYSASM privilege, 101, 570

OSASM group, 407revoking, 902

SYS_AUTO_SQL_TUNING_TASK procedure, 1118

SYSAUX clause, 239Sysaux tablespace, 172, 215, 238–240

AWR storage space requirement, 964creating database, 481creating, OMF, 926creating/locating OMF files, 252database creation log, 484manual database upgrade process, 438Pre-Upgrade Information Tool, 428removing tablespaces, 225, 240renaming tablespaces, 228, 240sizing for database creation, 444various user quotas in, 546

sys_context function, 579sysctl.conf file, 405SYSDATE function, SQL, 449, 1229sysdate variable, SQL*Loader, 637SYSDBA privilege, 570, 613

ASM instances, 904connecting using CONNECT command, 100creating databases, 475password file, 599starting SQL*Plus session from command

line, 99SYSDBA role, 451, 458, 451SYS_DEFAULT_CONNECTION_POOL, 532SYS_GROUP resource consumer group,

558, 563SYSMAN (super administrator account), 148,

157, 158SYSOPER privilege, 570

ASM instances, 904connecting using CONNECT command, 100password file, 599starting SQL*Plus session from command

line, 99SYSOPER role, 451, 458SYSTEM account, 475, 481System Activity Reporter see sar command, UNIXsystem administration, Oracle DBA, 12–13system administration, UNIX see UNIX system

administration, 76system administrator

post-installation tasks, 423–424creating additional operating system

accounts, 424updating shutdown/startup scripts, 423

preinstallation tasks, 401–410applying OS packages, 403changing login scripts, 406changing shell limits, 406checking kernel version, 402checking memory and physical space, 403checking operating system version, 402checking OS packages, 403creating database directories, 410creating directories, 409–410creating flash recovery area, 410creating groups, 406–408creating mount points, 404creating Oracle base directory, 409creating Oracle home directory, 410creating Oracle Inventory directory, 409creating Oracle software owner user,

408–409creating ORAINVENTORY group, 407creating OSASM/OSDBA/OSOPER

groups, 407reconfiguring kernel, 404–406setting file permissions, 409verifying operating system software,

402–403verifying unprivileged user exists, 408

system change number see SCNsystem configuration files, UNIX, 63system failures, 802system global area see SGASystem I/O wait class, 1164system management, DBA role, 5–7system metrics, 951system monitor process see SMONsystem monitoring

DBA role, 5, 15GlancePlus package, 84

system partitioning, 287system performance

application knowledge for diagnosis, 1182CPU usage, 1203database load affecting, 1205eliminating wait event contention, 1208evaluating system performance, 1152–1159

CPU performance, 1153–1158disk I/O, 1158–1159operating system physical memory, 1158

examining system performance, 1181–1182I/O activity affecting, 1204measuring I/O performance, 1159–1161measuring system performance, 1203memory affecting, 1205network-related problems, 1203Oracle wait events, 1175–1181reducing I/O contention, 1160SAME guidelines for optimal disk usage, 1160wait events affecting, 1206

system privileges, 567–570System Privileges page, Database Control, 150

Page 113: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1333■I N D E X

System tablespace, 172, 215creating database, 481creating, OMF, 926creating/locating OMF files, 252database creation log, 484default tablespace, need for, 544default temporary tablespaces, 232removing tablespaces, 225renaming tablespaces, 228sizing for database creation, 444storing undo data, 357Sysaux tablespace and, 238using multiple block size feature, 223

system usage statistic, 1181system-control statements, SQL, 262system-level triggers, 591–593systems management, OEM, 139systemstate dump, database hangs, 1193SYS_TICKS system usage statistic, 1182

■Ttable compression, 274–276, 1076table functions, 662–667

ETL components, 626table locks, explicit, 350–351table lookups, minimizing, 1067table mode, Data Pump Export, 688table operations, 267TABLE parameter, TKPROF utility, 1102table privileges, 571table scans, 467table types

table functions, 664user-defined data types, 264

table versioning, workspaces, 387TABLE_EXISTS_ACTION parameter, Data

Pump, 708table-level Flashback techniques, 848table-level locks, 349tables

ALTER TABLE command, 217avoiding unnecessary full table scans, 1075caching small tables in memory, 1090copying tables, SQL*Plus, 132–133creating tablespaces first, 215data dictionary tables, 203designing different types of, 35dictionary tables, 1062dropping tables, 224

recovering dropped table, 548restoring dropped tables, 851–852

dynamic performance tables, 203encrypting table columns, 607–608fixed dictionary tables, 1062Flashback Table, 366, 376–378full table scans, 1052heap-organized tables, 1072indexing strategy, 1070–1073keys, 20

listing columns and specifications of, 119locking issues, 1189multitable inserts, 660–662naming conventions, 36online table redefinition, 935, 936–941ordering of columns, 20partitioned tables improving SQL

processing, 1076permanently removing, 852–853real dictionary tables, 1063rebuilding tables regularly, 1089selecting data from multiple tables, SQL,

1232–1234separating table and index data, 170sizing for database creation, 444SQL moving tables online, 935table access by ROWID, 1052table structures, 36transforming ER diagrams into relational

tables, 35TABLES parameter, Data Pump, 688, 708tables, Oracle, 265–276

adding columns to, 271clustered tables, 266clusters, 295–296creating, 268–269, 273data dictionary views for managing, 292–295database integrity constraints, 306–310DBA_ALL_TABLES view, 330DBA_EXTERNAL_TABLES view, 330DBA_PART_TABLES view, 331DBA_TAB_COLUMNS view, 332DBA_TABLES view, 292, 330DBA_TAB_MODIFICATIONS view, 331DBA_TAB_PARTITIONS view, 330default values for columns, 270dropping columns from, 271dropping tables, 276dual table, 265estimating size before creating, 266, 268external tables, 280extracting DDL statements for, 294full table scans, 297getting details about tables, 292guidelines for creating indexes, 297heap-organized tables, 265index-organized tables, 265, 278–280inserting data from another table, 269moving tables between tablespaces, 273null value, 269object tables, 265organizing tables, 265partitioned tables, 266, 280–292read-only mode, 273–274relational tables, 265removing all data from, 272renaming columns, 272renaming tables, 272setting columns as unused, 271

Page 114: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1334 ■IN D E X

storing rows, 267table compression, 274–276temporary tables, 277–278views and, 312virtual columns, 270–271virtual tables see views

tablespace alerts, 956–958tablespace backups, 728, 794tablespace compression, 274tablespace encryption, 608–610TABLESPACE GROUP clause, 233tablespace metrics, 951tablespace mode, Data Pump Export, 688tablespace point-in-time recovery (TSPITR),

808, 840–841tablespace space usage alert, 952TABLESPACE_MIGRATE_TO_LOCAL

procedure, 218tablespaces, 170–172

adding tablespaces, OMF, 253, 927assigning tablespace quotas to new

users, 545backing up with RMAN, 777backup guidelines, 730bigfile tablespaces (BFTs), 172, 236–238block size, 167changing default tablespace type, 238CREATE TABLESPACE statement, 218creating database, 481, 482creating permanent tablespaces, 219creating tables or indexes, 215creating tablespaces, 218

clauses/options/parameters, 219–223determining extent sizing and allocation,

220–222NOLOGGING clause, 227with nonstandard block sizes, 223

data block sizes and, 171–172data dictionary views managing, 243–246datafiles, 170, 173, 219–220DBCA creating additional tablespaces, 489default permanent tablespaces, 235–236default tablespaces, 170description, 166, 170, 215encrypted tablespaces, 240–243enlarging, 174expanding tablespaces, 223–224extent sizing, 216free space, 255–256locally managed tablespaces, 172making tablespace offline, 228managing availability of, 228, 229mandatory tablespaces, 444migrating tablespaces, 217moving tables between, 273multiple database block sizes and buffer

cache, 190naming conventions, 398OFFLINE clauses, 228, 229

operating system files, 215Oracle Managed Files (OMF), 247–253permanent tablespaces, 172, 215Pre-Upgrade Information Tool, 428read-only tablespaces, 172, 229recovering tablespaces, 817–818recovering, SQL*Plus, 134removing tablespaces, 224–225renaming tablespaces, 228RESIZE clause, 219revoking tablespace quotas to users, 546segment space management, 221,

217–218, 219separating table and index data, 170, 171setting alert thresholds, 957sizing for database creation, 444smallfile tablespaces, 172, 236storage allocation to database objects, 222storage parameters, 220–222Sysaux tablespace, 172, 215, 238–240System tablespace, 172, 215tablespace quotas, 226tablespace space alerts, 226–227temporary tablespace groups, 233–235temporary tablespaces, 172, 215, 229–235transportable tablespaces, 171, 716–723undo tablespaces, 172, 215, 356UNDO_TABLESPACE parameter, 460UNLIMITED TABLESPACE privilege, 268unlimited tablespace usage rights, 546upgrading with DBUA, 430user tablespaces, 225users creating tablespaces, 546using multiple block size feature, 223viewing tablespace quotas, 546

TABLESPACES parameter, Data Pump, 688, 708TAG parameter, RMAN, 756tags, RMAN backup tags, 753tail command, UNIX/Linux, 65tape backups, 726, 729

RMAN (Recovery Manager), 742tape library components, Oracle Secure

Backup, 789tar command, UNIX/Linux, 76target database, RMAN, 743, 840Target Privileges, Database Control roles, 150Targets page, Grid Control, 159TCP/IP protocol, 517, 529TCP/IP Protocol page, 528TCP_INVITED_NODES parameter, 615TDE (Transparent Data Encryption), 240,

241, 608tee command, RMAN output, 747telnet, 46, 78temp files, OMF file-naming conventions,

249, 923TEMPFILE clause

tablespaces, 219, 230Oracle Managed Files (OMF), 247

Page 115: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1335■I N D E X

TEMPLATE.TNAME.XYZ attributes, ASM, 910templates

baseline templates, AWR, 965–971using templates with aliases, ASM, 917

TEMPORARY clause, CREATE TABLESPACE, 230

temporary directory, 413, 415temporary files, UNIX, 63temporary segments, 169, 184temporary space, 401, 413temporary tables, 277–278temporary tablespace groups, 233–235temporary tablespaces, 172, 215, 229–235

altering, 231AUTOALLOCATE clause, 233creating database, 482creating, 230–231creating/locating OMF files, 252, 927database creation log, 484DBA_TEMP_FILES view, 246default temporary tablespace, 232, 234DEFAULT TEMPORARY TABLESPACE

clause, 232dropping, 230encrypted tablespaces, 241extent sizing, 230failure to assign default space, 232managing users, 544Oracle size recommendation, 231shrinking, 231–232sizing for database creation, 444sort segment, 230V$TEMPFILE view, 246

TERMINAL attribute, USERENV namespace, 579, 580

terminal emulators, UNIX, 46TERMINATED BY clause, SQL*Loader, 632terminating database sessions, 75terminating processes with kill, UNIX, 75TERMOUT variable, SQL*Plus, 108test command, UNIX/Linux, 69, 71test databases, 9text editors, UNIX, 63–65text extraction utilities, UNIX, 65TEXT pages, Oracle process, 1190text scripts, RMAN, 747text, SQL*Plus, 130, 131theta-join operation, 21THINK_TIME_XYZ parameters, 1214Third Normal Form (3NF), 33threads

identifying user threads in Windows, 621log%t_%s_%r format, archived redo logs, 823PARALLEL parameter, Data Pump, 700

thresholdsadaptive thresholds, 954alert thresholds, 226–227, 953critical alert thresholds, 226, 952, 954, 956Database Control setting alert

thresholds, 954

Edit Thresholds page, 954, 955fixed values, 954percentage of maximum, 954proactive tablespace alerts, 956setting for metrics, 953significance level, 954threshold-based alerts, 952warning alert thresholds, 226, 952, 954, 956

timeCONNECT_TIME parameter, 549ENABLE_AT_TIME procedure, 368execution time limit resource allocation

method, 555idle time resource allocation method, 555IDLE_TIME parameter, 549logical time stamp, 199PASSWORD_XYZ_TIME parameters, 550Pre-Upgrade Information Tool, 428RESUMABLE_TIMEOUT parameter, 470

time-based recovery, RMAN, 821TIME column, top command, 84time-model statistics

ADDM, 879–880data collected by AWR, 960DB time metric, 878

Time Model Statistics section, AWR reports, 969Time Periods Comparison feature, 1206TIME variable, SQL*Plus, 108time zone data type, 430time-based recovery, 820, 824TIMED_STATISTICS parameter, 468, 1100TIMEHINT parameter, 379, 869TIMEOUT clause, ALTER SESSION, 384TIMESTAMP data type, 1223time-stamping methods, data concurrency, 347time stamps

Flashback Database example, 860TIMESTAMP_TO_SCN function, 847

timingCLEAR TIMING command, SQL*Plus, 115

TIMING variable, SQL*Plus, 108titles

placing title on page, SQL*Plus, 123TKPROF utility, SQL, 1099, 1101, 1102–1105

end-to-end tracing, 1107examining parse information, 1136reducing parse time CPU usage, 1157

/tmp directory, UNIX, 63, 403, 404TMPDIR variable, 413TNS_ADMIN variable, 412, 526tnsnames map file, 533tnsnames.ora file

backup guidelines, 729cloning databases with RMAN, 836connecting to database, 100connecting to Oracle, 206connecting to SQL*Plus through Windows

GUI, 101connecting using CONNECT command, 100directory naming method, 534

Page 116: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1336 ■IN D E X

easy connect naming method, 530external naming method, 533installing Oracle Client, 518local naming method, connections, 525, 526location of, 412modifying manually, 526–528modifying with NCA, 528–529remotely connecting to Oracle database, 98removing EXTPROC functionality, 614specifying DRCP connection, 532typical file, 526

TO SCN clause, FLASHBACK TABLE, 378TOAD software, SQL tuning, 1120TO_CHAR function, SQL, 1230TO_DATE function, SQL, 1229TO_NUMBER function, SQL, 1230tools, Oracle, 213–214Top 5 Timed Events section, AWR reports, 969Top Activity page, Database Control, 1200Top Background Events section, ASH

reports, 973Top Blocking Sessions section, ASH reports, 974top command, UNIX/Linux, 84, 1186Top Service/Module section, ASH reports, 973Top Sessions page, Database Control, 1200Top Sessions section, ASH reports, 974Top SQL Command Types section, ASH

reports, 974Top SQL statements, 1115Top SQL Statements section, ASH reports, 974Top SQL Using Literals section, ASH

reports, 974Top User Events section, ASH reports, 973Top-N analysis, SQL subqueries, 1236Total Recall, 1209TO_TIMESTAMP function, SQL, 1229touch command, UNIX/Linux, 63touch count, buffer cache, 1146, 1148TO_XYZ conversion functions, SQL, 1223trace directory, ADR, 178, 1024trace files, 178, 958tracing

collecting timed statistics during, 468creating trace in user dump directory, 1136DBMS_MONITOR package, 1175DBMS_SYSTEM package, 1175enabling, 1135end-to-end tracing, 1105–1107event 10046 tracing SQL code, 1174oradebug utility performing trace, 1174sec_protocal_error_trace_action

parameter, 615SQL Trace utility, 1099–1102SQL_TRACE parameter, 467TKPROF utility, SQL, 1102–1105

tracking block changes, RMAN, 779training, DBA, 10–11

Oracle by Example (OBE), 14Oracle Database Two-Day DBA course, 14

Oracle MetaLink, 15Oracle online learning program, 11Oracle Web Conference (OWC), 15resources, 13–14

Transaction Backout see Flashback Transaction Backout

transaction control statements, SQL, 263transaction identifier, 371transaction management, 337Transaction Playback page, Grid Control, 160transaction recovery, 804, 806TRANSACTION_BACKOUT procedure, 379,

868, 869transaction-level read consistency, 345, 346transactions, 196–197, 337–340

abnormal program failure, 338ACID properties, 340automatic checkpoint tuning, 932backing out transactions, 869–870COMMIT statement, 338–339COMMIT_LOGGING parameter, 339committing transactions, 196, 197–198, 340COMMIT_WAIT parameter, 339compensation transactions, 868creating transaction temporary table, 278data concurrency, 341–342, 347–355data consistency and, 196database consistency, 342DDL and DML statements, 338fast commit mechanism, 199Flashback error correction using undo data,

366–368Flashback Transaction, 366, 379–380Flashback Transaction Query, 366, 372–375how Oracle processes transactions, 196ISO transaction standard, 342isolation levels, 342–346limiting execution times, 942–943locking and, 350long-running transactions affecting

performance, 1202making permanent in database files, 181monitoring backout of, 380monitoring performance with Grid

Control, 160naming, 340normal program conclusion, 338processing, 196, 338redo log files, 176ROLLBACK statement, 338, 339–340rolling back transactions, 196, 198SAVEPOINT command, 339SHUTDOWN command, 503statement-level read consistency, 356system change number (SCN), 200undo data providing read consistency,

356–366

Page 117: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1337■I N D E X

undo management, 200, 921undo segment, 338

TRANSACTIONS parameter, 455transactions, Oracle

autonomous transactions, 380–382DBMS_TRANSACTION package, 380discrete transactions, 380managing long transactions, 386–388managing transactions, 380–382Resumable Space Allocation, 382–386Workspace Manager, 386–388

transaction-set consistent data, 199transfer rate, RAID systems, 88transform operator, SQL/XML, 1249TRANSFORM parameter, Data Pump, 710–711transformations, SQL, 1051transforming data, 626, 656–670

see also ETL (extraction, transformation, loading)

deriving data from existing tables, 657MERGE statement, 658–660MODEL clause, 667–670SQL*Loader/external tables compared, 646table functions, 662–667using SQL to transform data, 658–667

transform-then-load method, 626transform-while-loading method, 626

table functions, 662transient files, flash recovery area, 735transition point, partitioning, 282transparency, synonyms, 325Transparent Application Failover feature, 802Transparent Data Encryption (TDE), 240, 241,

604–608encrypting table columns, 607–608encryption algorithms, 608generating master encryption key, 607Oracle Wallet, 605–606

transparent encryption, 763TRANSPARENT value, Data Pump, 695, 696TRANSPORTABLE parameter, Data Pump,

694, 710transportable tablespaces, 171, 716–723

converting datafiles to match endian format, 721

copying export/tablespace files to target, 719copying files to target system, 722Data Pump Import importing metadata, 723determining endian format of platforms, 720ensuring tablespaces are self contained, 721ETL components, 626exporting dictionary metadata for, 718exporting metadata using Data Pump, 721generating transportable tablespace set,

717–719importing metadata from dump file, 719making tablespace read-only, 721performing tablespace import, 719–720referential integrity constraints, 716selecting tablespace to transport, 716

self-contained criteria, 716TRANSPORT_FULL_CHECK parameter, 691transporting tablespace across platforms,

720–723transporting tablespaces between databases,

716–720TRANSPORT_SET_CHECK procedure, 717uses for, 716

TRANSPORTABLE_TABLESPACES parameter, 705

TRANSPORT_DATAFILES parameter, 708TRANSPORT_FULL_CHECK parameter, 691,

708, 717, 721TRANSPORT_SET_CHECK procedure, 717, 721TRANSPORT_TABLESPACE parameter, 718TRANSPORT_TABLESPACES parameter,

688, 708trees, B-tree index, 298trial recovery, 864–866triggers, 328–329, 590–593

deriving data from existing tables, 657ensuring data validity, 37SQL*Loader direct-path loading, 641

TRIM function, SQL, 1228troubleshooting

alert log file, 178recovery errors, 866–870

TRUNC function, SQL, 1229TRUNCATE command, SQL, 272, 1226TRUSTED mode

QUERY_REWRITE_INTEGRITY parameter, 316, 465

try ... catch blocks, Java, 540TSPITR (tablespace point-in-time recovery),

808, 840–841TTITLE command, SQL*Plus, 123, 116, 124TTS_FULL_CHECK parameter, 718TUNE_MVIEW procedure, 317tuning

see also performance tuningautomatic checkpoint tuning, 932–933Automatic SQL Tuning Advisor, 209, 212,

1115–1120automatic undo retention tuning, 209buffer cache, 1144–1148hard parsing and soft parsing, 1135–1143instance tuning, 1129–1130, 1194–1209

see also instance performanceJava pool, 1148large pool, 1148Oracle memory, 1132–1152Oracle Tuning Pack, 149, 949PGA memory, 1148–1152proactive tuning, 1042self-tuning mechanism, AWR, 959shared pool, 1133–1135SQL Tuning Advisor, 212, 1111–1115streams pool, 1148tuning SQL statements, 1126–1127

tuning mode, Oracle optimizer, 1111

Page 118: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1338 ■IN D E X

tuning pack, Server Manageability Packs, 459tuples, 20, 21TWO_TASK environment variable, 519txnames parameter, 869%TYPE attribute, PL/SQL, 1242type inheritance, abstract data types, 1240TYPICAL value, STATISTICS_LEVEL

parameter, 461

■UUDUMP (default trace directory), 168umask command, 409UMASK variable, UNIX, 61, 613uname command, UNIX/Linux, 49unary operations, relational algebra, 21UNASSIGN_ACL procedure, 617UNCOMPRESS clause, ALTER TABLE, 275UNDEFINE command, SQL*Plus, 126underscore (_) character, SQL, 1224Undo Advisor, 977, 980–981

automatic performance tuning features, 1132

sizing undo tablespaces, 359, 362, 365undo data, 356–366

active/inactive, 359Automatic Undo Management (AUM),

356–362backup and recovery architecture, 201committed/uncommitted, 359committing transactions, 338determining default tablespace for, 460Flashback error correction using, 366–368Flashback Table, 376Flashback Transaction, 379Flashback Transaction Query, 373insufficient data to flash back, 377OEM managing, 365–366retaining in undo tablespace, 359RETENTION GUARANTEE clause, 367storing, 460storing in System tablespace, 357undo records, 356UNDO_RETENTION parameter, 373

Undo Generation and Tablespace Usage graph, 366

UNDO keyword, CREATE TABLESPACE, 358undo management, 200, 560

Automatic Undo Management (AUM), 921undo pool method, Database Resource

Manager, 555undo records see undo dataundo retention, 360

default, 361guaranteed undo retention, 362–365RETENTION GUARANTEE clause, 363

undo retention tuning, 209undo segments, 169

AUM, 200, 361, 357, 922AWR determining number of, 359

committing transactions, 198data consistency, 199fast ramping up of, 359managing undo information in, 359rolling back transactions, 198transactions, 338

undo spacemanaging automatically, 357managing undo space information, 364–365

undo tablespaces, 172, 215adding space to, 358auto-extensible undo tablespaces, 358

reason against auto-extensible, 362automatic undo retention, 361before-image records, 176, 197, 356changing and editing, 365CREATE UNDO TABLESPACE

statement, 218creating, 358creating database, 482creating, OMF, 927creating/locating OMF files, 252database creation log, 484default choice of, 358dropping, 364encrypted tablespaces, 241inserting new row, 197multiple undo tablespaces, 357, 358RETENTION GUARANTEE clause, 374rolling back transactions, 198setting up Oracle Streams, 672sizing, 358, 360, 362, 364

for database creation, 444OEM Undo Advisor assisting, 365

system activity and usage statistics, 365using Flashback features, 367

undocumented initialization parameters, 473UNDO_MANAGEMENT parameter, 200,

357, 460UNDO_POOL parameter, 365, 943undo-related parameters, 460–461UNDO_RETENTION parameter, 200,

359–362, 460automatic undo retention tuning, 209Flashback Query, 367Flashback Table, 377Flashback Transaction Query, 373Flashback Versions Query, 370guaranteed undo retention, 362, 367setting up Oracle Streams, 673snapshot-too-old error, 364

UNDO_TABLESPACE parameter, 357–359, 460UNDROP clause, ALTER DISKGROUP, 916UNIFORM extents option, 216, 221

using bigfile tablespaces, 237UNIFORM SIZE clause, creating tablespaces,

221, 230uninstalling Oracle, 425–426UNION operation, 21, 1071

Page 119: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1339■I N D E X

UNION operator, SQL, 1228uniq command, UNIX/Linux, 68UNIQUE constraint, 300, 307unique identifiers see primary keysunique indexes, 297, 299Universal Installer see Oracle Universal InstallerUNIX, 43

accessing UNIX system, 46–48archiving, 76backup and restore utilities, 76–77changing shell prompt, 51customizing environment, 55directory structure, 47disk availability, 87disk partitioning, 87disk performance, 87disk striping, 88displaying environment variables, 54Emacs text editor, 65file systems, creating, 87files, 62flow control structures, 71–74input/output redirection, 56–57kernel, 45Linux compared, 43, 45logical volumes, 88monitoring disk usage, 86operating system level permissions, 613redirection operators, 56remote access to UNIX server, 78scheduling jobs, 77session, 47shell scripting, 68–74starting SQL*Plus session from, 99vi text editor, 63–65Vim text editor, 65

UNIX boxes, 47UNIX commands, 48–57

basic commands, 48batch mode, 54bin directory, 48built-in commands, 48controlling output of commands, 52editing previous commands, 50interactive mode, 54passing output between commands, 52retrieving previous commands, 50

UNIX commands, list ofat, 78batch, 78case, 74cat, 52, 58cd, 48, 62chgrp, 62chmod, 60, 61, 70chsh, 46cp, 59cpio, 76, 77crontab, 77–78

cut, 66date, 48dd, 76df, 81, 86diff, 53du, 81, 86echo, 48egrep, 66env, 54exit, 48export, 51, 53, 54fgrep, 66find, 52ftp, 79get, 79, 80glance, 85gpm, 85grep, 49, 65head, 65history, 49iostat, 82join, 67kill, 75link, 57ln, 58ls, 58, 59man, 48, 50mkdir, 62more, 52, 58mv, 59netstat, 85nohup, 75page, 53passwd, 49paste, 67pipe (|), 52ps, 74, 81put, 80pwd, 49rcp, 79rlogin, 78, 79rm, 59, 62rman, 745rmdir, 62sar, 83scp, 79setenv, 54sort, 68source, 55ssh, 79tail, 65tar, 76telnet, 78test, 69, 71top, 84touch, 63uname, 49uniq, 68vmstat, 82

Page 120: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1340 ■IN D E X

whatis, 51whereis, 49which, 49who, 50whoami, 50

UNIX directories see directories, UNIXUNIX disk storage see disk storage, UNIXUNIX files see files, UNIXUNIX knowledge, DBA, 12UNIX processes, 74–76

runnable process, 80thread analogy, 179

UNIX shell scripts see shell scripts, UNIXUNIX shells see shells, UNIXUNIX system administration, 76

accessing remote computers, 78backup and restore utilities, 76–77crontab and automating scripts, 77–78Oracle DBA and, 76performance monitoring, 80–81performance monitoring tools, 81–85remote copying, 79remote login (Rlogin), 78scheduling database tasks, 77–78Secure Shell (SSH), 79sending and receiving files using FTP, 79telnet, 78

UNIX variables, 53, 54UNKEEP procedure, 1138UNKNOWN status, Oracle listener, 522UNLIMITED TABLESPACE privilege, 268, 546UNLIMITED value, default profile, 550, 551unloading data, populating external tables, 650UNPACK_STGTAB_SQLSET procedure, 1218unprivileged user, verifying existence of, 408unrecoverable datafiles, 759UNRECOVERABLE parameter

backup guidelines, 729SQL*Loader utility, 640, 641, 642

until-do-done loop, UNIX, 73unused block compression feature, RMAN, 742UNUSED_SPACE procedure, 255update anomaly, 29, 32, 33UPDATE GLOBAL INDEXES option, 302UPDATE statement, 263, 287, 1226, 1242UPDATE-ELSE-INSERT operation, 658updates

Critical Patch Updates, 617lost-update problem, 341RULES UPDATE specification, 669

upgrade actions script, 438UPGRADE CATALOG command, RMAN, 771Upgrade Results window, DBUA, 433upgrade script, 438Upgrade Summary window, DBUA, 432upgrade.log spool file, 435upgrading databases

see also manual database upgrade processpreserving database performance, 1080

upgrading to Oracle Database 11g, 426–441case sensitivity of passwords, 491Database Upgrade Assistant (DBUA), 428,

430–433ensuring database compatibility, 452manual database upgrade process, 427,

434–441methods and tools, 427–430post-upgrade actions, 441Post-Upgrade Status Tool, 429preparing database for upgrading, 430Pre-Upgrade Information Tool, 428–429resetting passwords, post-upgrade, 441retaining behavior of older software

release, 463upgrade paths, 426–427

upserts, 626, 658, 659, 669used_bytes attribute, CREATE_INDEX_COST, 299user accounts, database security, 611user authentication, 596–602user class, Oracle Secure Backup, 788user-created variables, UNIX, 53user-defined object types, 264user-defined variables, UNIX, 54user errors, 802, 803User I/O wait class, 1163, 1164user management, 544, 619, 620user processes, 179user profile file, 110–111user profiles, 548–553

altering, 552, 619FAILED_LOGIN_ATTEMPTS parameter, 612managing resources, 554

user pseudo-variable, SQL*Loader, 643user tablespaces, 225USER variable, SQL*Plus, 118, 119, 127USER views, 204useradd command, 408USER_ADVISOR_XYZ views, 324USER_DUMP_DEST parameter, 1101, 1102USERENV namespace, 579, 580USERID parameter, SQL*Loader, 633, 718user-managed backups, 790–795user-managed control file recovery, 826–828user-managed copies, RMAN, 752user-managed datafile recovery, 819–820user-managed incomplete recovery, 824user-managed recovery without backup, 829user-managed tablespace recovery, 818user-managed whole database recovery,

816–817USER_RECYCLEBIN view, 850users

altering properties of user’s session, 262altering users, 547assigning users to consumer groups, 562centralized user authorization, 602changing another user’s password

temporarily, 620

Page 121: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1341■I N D E X

changing user’s password, 547configuring, Oracle Secure Backup, 788controlling use of resources, 548

COMPOSITE_LIMIT parameter, 549creating Oracle software owner user, 408–409creating users, 544–547

assigning tablespace quotas, 545privileges, 545temporary tablespace groups, 234

current system users, 50DBA views managing, 577DBCA changing passwords for default users,

490–491denying access to database, 548dropping users, 547–548enterprise user security, 603–611granting privileges to users with UTL_FILE

package, 257granting role to another user, 576identifying high CPU users, 1154LICENSE_MAX_USERS parameter, 461listing user information, 619managing users, 544, 619, 620password management function, 552privileged users, 599profiles see user profilesprogram global area (PGA), 193resource consumer groups, 557revoking tablespace quotas, 546saving user input in variable, 121schema-independent users, 603SHOW USER command, 117specifying maximum number of, 461unlimited tablespace usage rights, 546users creating tablespaces, 546users with most waits, 1170verifying existence of nobody, 408whoami command, 50

USERS tablespaces, 484USER_TABLESPACES view, 238USER_TICKS system usage statistic, 1181USE_STORED_OUTLINES parameter, 1079USING clause, RMAN commands, 747, 750, 751USING clause, role authorization, 575utilities, Oracle, 207–208utl_dir directory, 257UTL_FILE package, 256–259

setting permissions, 613specifying directory for processing I/O, 454

UTL_FILE_DIR parameter, 257, 454, 613utllockt.sql script, 353, 355utlpwdmg.sql script, 552UTL_RECOMP package, 439utlrp.sql script, 432, 434, 439, 440utlu111i.sql script, 429, 434, 435utlu111s.sql script, 429, 434, 440utluppset.sql script, 434utlxplan.sql script, 1091, 1092, 1095UTL_XYZ packages, 615

■VV$ tables

using V$ tables for wait information, 1165–1166

V$ viewssee also dynamic performance viewsV$ACTIVE_SESSION_HISTORY, 971, 972,

1169, 1170, 1171, 1186V$ADVISOR_PROGRESS, 978V$ALERT_TYPES, 958V$ARCHIVE, 1187V$ARCHIVED_LOG, 795, 813, 844V$ASM_DISK, 909V$BACKUP, 795V$BACKUP_CORRUPTION, 782, 864V$BACKUP_DATAFILE, 779V$BACKUP_FILES, 760, 780V$BACKUP_SET, 744V$BGPROCESS, 971V$BLOCK_CHANGE_TRACKING, 779V$BUFFER_POOL_STATISTICS view, 1145V$CONTROLFILE, 175V$COPY_CORRUPTION, 782, 864V$CPOOL_CC_STATS, 533V$CPOOL_STAT, 533V$DATABASE, 507, 854V$DATABASE_BLOCK_CORRUPTION, 865V$DATAFILE, 246, 795, 812, 900, 993V$DB_CACHE_ADVICE, 189, 1145V$DIAG_INFO, 1023, 1026V$ENCRYPTED_TABLESPACES, 243V$ENQUEUE_STAT, 1179V$EVENT_NAME, 1175V$FILESTAT, 246, 1177V$FLASHBACK_DATABASE_XYZ views, 858V$FLASH_RECOVERY_AREA_USAGE, 740V$HM_CHECK, 1032V$HM_XYZ views, 1033V$INSTANCE, 507V$INSTANCE_RECOVERY, 805, 1205V$LATCH, 1168V$LIBRARYCACHE, 1137, 1138V$LIBRARY_CACHE_MEMORY, 1138V$LOCK_XYZ views, 354V$LOG, 795, 985V$LOGFILE, 900, 984V$LOG_HISTORY, 795, 823V$LOGMNR_CONTENTS, 842, 845, 847V$MAP_XYZ views, 994V$MEMORY_XYZ views, 896V$METRICNAME, 958V$OBJECT_USAGE, 305, 1073V$OSSTAT, 1181V$PARAMETER, 473, 494V$PGASTAT, 1149, 1150V$PGA_TARGET_ADVICE, 1149V$PROCESS, 1152V$PROCESS_MEMORY, 1151V$PWFILE_USERS, 600

Page 122: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1342 ■IN D E X

V$RECOVERY_FILE_DEST, 740V$RECOVERY_LOG, 813V$RESTORE_POINT, 863V$RESULT_CACHE_XYZ views, 1123V$RMAN_COMPRESSION_ALGORITHM, 764V$RMAN_CONFIGURATION, 762V$RMAN_ENCRYPTION_ALGORITHM, 763V$RMAN_OUTPUT, 764, 782, 813V$RMAN_STATUS, 782, 813V$ROLLSTAT, 365V$RSRC_CONSUMER_GROUP, 566V$RSRC_PLAN, 566, 1013V$SEGMENT_NAME, 1173V$SEGMENT_STATISTICS, 1173, 1206V$SEGSTAT_XYZ views, 1173V$SERVICEMETRIC_XYZ views, 951V$SESSION, 352, 354, 566, 621, 960, 972,

1106, 1166, 1168, 1169, 1189, 1195V$SESSION_EVENT, 1162, 1165, 1203V$SESSION_FIX_CONTROL, 1036V$SESSION_LONGOPS, 714, 783, 943V$SESSION_WAIT, 386, 960, 1163, 1165,

1169, 1171, 1176, 1195, 1203V$SESSION_WAIT_CLASS, 1172V$SESSION_WAIT_HISTORY, 1168V$SESSSTAT, 959, 1156, 1203V$SESS_TIME_MODEL, 880, 1206V$SGA_TARGET_ADVICE, 1145V$SHARED_POOL_ADVICE, 1138V$SORT_SEGMENT, 230V$SORT_USAGE, 230V$SPPARAMETER, 177, 494V$SQL, 1089, 1108–1110V$SQLAREA, 1109, 1168, 1204V$SQL_CS_XYZ views, 1089V$SQL_PLAN, 1110, 1127, 1202V$SQL_PLAN_STATISTICS, 1110V$SQL_WORKAREA_HISTOGRAM, 1150V$SYSAUX_OCCUPANTS, 225V$SYSMETRIC_XYZ views, 951, 1164V$SYSSTAT, 959, 1141, 1156, 1181V$SYSTEM_EVENT, 1162, 1165, 1166, 1167,

1173, 1204V$SYSTEM_WAIT_CLASS, 1172V$SYS_TIME_MODEL, 879, 1206V$TABLESPACE, 238, 246, 812, 993V$TEMPFILE, 230, 231, 246V$TRANSACTION, 340, 365V$UNDOSTAT, 360, 365V$WAITCLASSMETRIC, 1173V$WAITSTAT, 1167

VALIDATE BACKUP command, RMAN, 810–811VALIDATE BACKUPSET command, RMAN, 761VALIDATE BACKUPSET command, RMAN,

783, 811VALIDATE clause, 309VALIDATE command, RMAN, 783–784VALIDATE option, RMAN, 811VALIDATE STRUCTURE clause, 934VALIDATE_PENDING_AREA procedure, 562

validating objects online, SQL, 934validating operator, SQL/XML, 1249validation commands, RMAN, 761validation methods, data concurrency, 347VALID_TABLE_LIST parameter, 978value-based security, 312values

default values for columns, 270null value, 269

VALUES LESS THAN clause, CREATE TABLE, 281VARCHAR2 data type, 1222VARIABLE clause, 647variable record format, SQL*Loader, 631variables, SQL*Plus see SQL*Plus environment

variablesvariables, UNIX, 53, 54VARRAY type, 1240VERIFY variable, SQL*Plus, 108verify_function_11g function, 552versions, 394

checking kernel version, 402checking operating system version, 402fixing bugs, 1131Flashback Versions Query, 366, 369–372identifying changed row versions, 375locating product files, 397multiple names for same version, 395preinstallation checks, 401Pre-Upgrade Information Tool, 428retaining behavior of previous versions, 463retrieving version of UNIX command, 49table versioning and workspaces, 387timing conversion to new version, 1131variable naming Oracle database version, 128

VERSIONS BETWEEN clause, 370, 372VERSIONS BETWEEN TIMESTAMP clause, 874vi text editor, UNIX, 63–65view privileges, 571view resolution, 314views, 312–314

see also data dictionary viewsavoiding improper use of, 1075database security, 577getting part/full text of views, 332managing database objects, 329materialized views, 314–320, 1077

Vim text editor, UNIX, 65virtual columns, 270–271

partitioning, 286VIRTUAL keyword, 270virtual memory, 1158virtual private catalogs, RMAN, 772–774virtual private database see VPDvirtual tables see viewsvmstat utility, UNIX, 82, 1153, 1181, 1186VNC (Virtual Network Computing), 46volume identification sequence, 789VPD (virtual private database), 578

column-level VPD, 585–586

Page 123: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1343■I N D E X

■Wwait classes, 1163, 1171

analyzing instance performance, 1164breakdown of waits by, 1172determining total waits and percentage waits

by, 1164metric values of, 1173time spent in each type, 1172

Wait Event History, Database Control, 1200wait event views, 1163wait events, 1163

analysis-based performance approach, 1183ASH reports, 975buffer busy wait events, 1175–1177checkpoint completed wait event, 1177collecting wait event information, 1174–1175complete listing of, 1175database wait statistics, 1162db file scattered read wait event, 1177db file sequential read wait event, 1178DBMS_MONITOR package, 1175DBMS_SYSTEM package, 1175direct path read/write wait events, 1178eliminating contention, 1208enqueue waits event, 1179event 10046 tracing SQL code, 1174free buffer waits event, 1178idle wait events, 1181ignoring the unimportant, 1183instance-wide wait event status, 1167latch free wait events, 1179–1180log buffer space wait event, 1180log file switch wait event, 1180log file sync wait event, 1181most important recent wait events, 1170Oracle wait events, 1175–1181oradebug utility performing trace, 1174system performance, 1206V$SESSION_WAIT view, 1195V$SESSION_WAIT_HISTORY view, 1168

wait informationanalyzing with Active Session History, 1169key dynamic performance tables

showing, 1165obtaining, 1167–1168using V$ tables for, 1165–1166

WAIT optioncommitting transactions, 339MODE parameter, LOCK TABLE, 351

wait statisticsdata collected by AWR, 960dynamic performance views containing, 1163identifying SQL with highest waits, 1171measuring instance performance, 1162–1163not relying on, 1182objects with highest waits, 1170segment-level statistics, 1173users with most waits, 1170

waitsinvestigating waits, 145tuning shared pool, 1133

WAITS parameter, TKPROF utility, 1102wallet directory, 241wallet-based encryption, RMAN backups, 782Warehouse Builder, 401WAREHOUSES table, 1093warm backups, 728warning alert thresholds, 226, 952, 954, 956warning code, SQL*Loader, 639warnings

out-of-space warnings, 741warning_value attribute, 227%wcache column, sar command, 83web applications

connecting to Oracle, 513monitoring with Grid Control, 160

web based management, OEM, 138web pages, SQL*Plus generating, 115, 134web services data, 666whatis command, UNIX/Linux, 51WHEN clause, SQL*Loader, 642WHEN MATCHED THEN ... clauses, 659WHENEVER [NOT] SUCCESSFUL auditing

option, 587WHERE clauses

Cartesian product, 1068, 1232conditions used in, 1224efficient SQL, 1065–1067filtering data, 1226guidelines for creating indexes, 297LIKE condition, 1224subqueries, 263using instead of HAVING clause, 1067using SQL functions in, 1066

whereis command, UNIX/Linux, 49which command, UNIX/Linux, 49WHICH_LOG attribute, PURGE_LOG, 1012WHILE LOOP statement, PL/SQL, 1244while-do-done loop, UNIX, 72who command, UNIX/Linux, 50whoami command, UNIX/Linux, 50whole closed backups, 790–791whole database backups, 727, 728whole database recovery, 814–817whole disk configuration, 88whole open backups, 792–793wildcard characters, SQL, 1224window groups, Oracle Scheduler, 997, 1017WINDOW_PRIORITY attribute, 1014Windows

at scheduling utility, 126creating Windows batch script, 126GUI connecting to SQL*Plus, 101

windows, Oracle Scheduler, 996, 1013changing resource plans using windows,

1013–1017creating, 1014–1015

Page 124: Oracle Database 11g SQL and PL/SQL: A Brief Primer3A978-1... · If you’ve created a starter database using the Database Configuration Assistant (DBCA) as part of your Oracle software

1344 ■IN D E X

managing, 1015–1016overlapping windows, 1015

precedence for, 1017predefined maintenance windows, 1020prioritizing jobs, 1016–1017

WITH ADMIN OPTION clausegranting roles, 570, 576granting system privileges, 569

WITH READ ONLY clause, 312WM$VERSIONED_TABLES table, 387WM$VERSION_TABLE table, 387WORD_WRAPPED option, FORMAT clause, 109WORKAREA_SIZE_POLICY parameter, 194worker process, Data Pump, 686Workload Source page, SQL Access Advisor, 322workloads

analyzing after-upgrade SQL workload, 1219analyzing prechange SQL workload, 1218Automatic Workload Repository, 210,

959–971capturing production workload, 1210,

1211, 1217collecting operating system statistics, 1061Database Replay, 1214, 1215–1216DBMS_WORKLOAD_CAPTURE

package, 1210preprocessing workload, 1211replaying captured workload, 1211

Workspace Manager, 386–388workspaces, 386, 387, 388

WRAPPED option, FORMAT clause, 109write-ahead protocol, 182, 199, 340write permission, UNIX files, 59write-allowed period, Oracle Secure

Backup, 789writer processes, specifying number of, 455

■XX Window emulation, 46, 414X$ tables, 204XDBURIType data type, 1249xhost program, 412, 416xids parameter, TRANSACTION_BACKOUT, 869XML (Extensible Markup Language )

audit parameters, 450semistructured database model, 41SQL*Loader utility, 645SQL/XML operators, 1249viewing XML stored in Oracle table, 1250XML and SQL, 261

XML DB, Oracle, 1248–1252XML documents

creating relational view from, 1252inserting into Oracle table, 1250

XML schemasetting up XML schema, 1251user-defined data types, 264

XML value, AUDIT_TRAIL parameter, 587XMLType data type, 1249