appendix a brief oracle9i sol and pl/sol primer978-1-4302-0773-3/1.pdf · appendix a brief oracle9i...

98
APPENDIX A Brief Oracle9i SOL - and PL/SOL Primer - I'M suRE MOST of you are already familiar with SQL to some extent. However, I present in this appendix a quick review of Oracle9 i SQL and its programmatic cousin, PLISQL, so it may provide a starting point to learning Oracle's program- matic aspects for newcomers to the Oracle database. If you're already quite familiar with Oracle SQL, you may benefit from focusing on the newer additions to SQL and PLI SQL made in the Oracle9 i database. My goal here is simply to present a short summary of the classic DML and DDL commands and then discuss the newer SQL and PL/SQL concepts in greater detail. NOTE You might consider reading another Apress book, Oracle9i PL/SQL: A Developer's Guide, by Bulusu Lakshman, if you're interested in an up-to-date PUSQL book oriented toward developers. You can download a sample chapter of the book from http://www.apress.com/book/bookDisplay.html?biD=142. How much SQL or PL/SQL do you as a DBA need to know? The answer, of course, depends on the type of DBA you are: a production support DBA or a DBA assisting in developmental efforts. Regardless of the type of DBA you are, though, increasingly it's becoming more important 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. Oracle9i makes several powerful and innovative changes to both SQL and PL/SQL. This appendix aims to summarize some of the most important features, so you and the developers you work with can take advantage of these new features. 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. The primary goal of this appendix is to give you a very general understanding of the Oracle9i SQL and PLISQL language concepts. ll05

Upload: haque

Post on 16-Aug-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

APPENDIX

A Brief Oracle9i SOL -and PL/SOL Primer -

I'M suRE MOST of you are already familiar with SQL to some extent. However, I present in this appendix a quick review of Oracle9 i SQL and its programmatic cousin, PLISQL, so it may provide a starting point to learning Oracle's program­matic aspects for newcomers to the Oracle database. If you're already quite familiar with Oracle SQL, you may benefit from focusing on the newer additions to SQL and PLI SQL made in the Oracle9 i database. My goal here is simply to present a short summary of the classic DML and DDL commands and then discuss the newer SQL and PL/SQL concepts in greater detail.

NOTE You might consider reading another Apress book, Oracle9i PL/SQL: A Developer's Guide, by Bulusu Lakshman, if you're interested in an up-to-date PUSQL book oriented toward developers. You can download a sample chapter of the book from http://www.apress.com/book/bookDisplay.html?biD=142.

How much SQL or PL/SQL do you as a DBA need to know? The answer, of course, depends on the type of DBA you are: a production support DBA or a DBA assisting in developmental efforts. Regardless of the type of DBA you are, though, increasingly it's becoming more important 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.

Oracle9i makes several powerful and innovative changes to both SQL and PL/SQL. This appendix aims to summarize some of the most important features, so you and the developers you work with can take advantage of these new features. 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. The primary goal of this appendix is to give you a very general understanding of the Oracle9i SQL and PLISQL language concepts.

ll05

Appendix

ll06

The Oracle9i Sample Schemas The examples in this appendix use the demo tables provided by Oracle as part of the Oracle9i server software. Ideally, you should install the Oracle demo schemas in a test database and practice the parts of SQL you aren't familiar with. Oracle has a new manual called "Sample Oracle Schemas" in its documentation. If you've installed the starter database as part of your Oracle software installation, these schemas will most likely be part of your new starter database. If you've chosen to not create the starter database (by selecting a "Software only" installation option), first you must create a small Oracle9 i database. Toward the end of the database creation process, make sure you unlock the same schema accounts.

After you create the database, you can proceed to the following steps to install the sample Oracle schemas. The main Oracle9i sample schemas are the HR, OE, PM, QS, and SH schemas. The last schema, SH, can't be installed if you don't have the partitioning option as part of your database server.

Also, you must create the schemas in the order that follows because of dependencies that exist among the schema objects. You may get errors if you create the schemas in the wrong order. Each of the scripts will create the necessary schema users, tables, indexes, and constraints, and will load data into the tables. The scripts perform all this by calling other scripts in the same directory.

l. Go to the $0RACLE_HOME/demo/schema/human_resources directory and run the script hr_main.sql to create the human resources (HR) schema.

2. Go to the $0RACLE_HOME/ demo/ schema/ order_ entry directory and run the script oe_main.sql to create the order entry (OE) schema.

3. Go to the $0RACLE_HOME/demo/schema/product_media directory, and run the script pm_main.sql to create the product media (PM) schema.

4. Go to the $0RACLE_HOME/ demo/ schema/ shipping directory and run the script qs_main.sql to create the queued shipping (QS) schema.

5. Go to the $0RACLE_HOME/ demo/ schema/ sales_history directory and run the script sh_main.sql to create the sales history (SH) schema.

6. You're now ready to use the various schemas to practice your SQL and PLISQL commands. If you need to reset the schemas to their initial state, all you have to do is run the following command in SQL *Plus:

@?/demo/schema/mksample systempwd syspwd hrpwd oepwd pmpwd qspwd shpwd

In the preceding command, the seven variables after the mksample keyword should be replaced with the actual passwords for the SYSTEM and SYS users, and the passwords for the HR, OE, PM, QS, and SH schemas.

Here's a brief description of the five main sample schemas:

• The HR schema 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.

A Brief0racle9i. SQL and PUSQL Primer

• The OE 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.

• The PM schema covers content management. You can use this schema if you're exploring Oracle's interMedia option. The tables in the PM schema contain audio and video tracks, images, and documents.

• The QS schema is a group of schemas that hosts message queues. This sample schema is designed for use with Oracle's Advanced Queuing feature.

• The SH schema is the largest sample schema. You can use it for testing examples with large amounts of data. The schema contains partitioned tables, an external table, and Online Analytical Processing (OLAP) features. The fact tables sales and costs contain 750,000 rows and 250,000 rows, respectively, as compared to 107 rows in the employees table from the HRschema.

Now that you've successfully created your sample schemas, let's start the SQLreview.

Basic SQL In Chapter 7 you saw how Oracle SQL statements include DDL, DML, and other types of statements. This appendix focuses on Oracle DML statements almost exclusively. The idea is to quickly review elementary Oracle SQL and then focus on the newer Oracle9 i additions to SQL. Let's begin with a review of the most basic of all SQL statements, the select statement.

The Select Statement The select statement is the most common SQL statement. The selection operation is also called a projection. A select statement will retrieve 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;

If you want to retrieve only certain columns from a table, you specify the column names after the keyword select, 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;

1107

Appendix

1108

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 in the following example:

SQL> select distinct username from v$session;

The optional where clause in a select statement uses conditions that help you specify that only certain rows be returned. Here are some of the common condi­tions that you can use in a where clause:

= Equal > Greater Than < less Than <+ Less than or equal to >= greater than or equal to <> or ! not equal to

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 202

SQL>

- -

Faviet Fay

The pattern that you want the where clause to match should be enclosed in single quotes (' ' ) . The percent sign (%) indicates that the letters Fa can be fol­lowed 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 U acts as a wildcard for one and only one character.

A Brief Oracle9i SQL and PUSQL Primer

The Insert Statement The insert statement enables you to add new data to a table. The insert statement lets you add duplicate data if there are no unique requirements enforced by a primary key or an index. The general form of the insert statement 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', 'salapati' ,sysdate,98765);

1 row created. SQL>

In the preceding list, you had to specify the column names, because only some columns were being populated in the row you inserted. The rest of them are left blank, which is OK, provided the column isn't defined 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 (dept_id, dept_name, dept_type, dept_city) 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 as select *from (CTAS) command, as shown here:

SQL> create table b as select * from a;

The Delete Statement You use the delete statement to remove rows from a table. The delete statement has the following structure:

delete from <table> [where ,condition>];

1109

Appendix

1110

For example, if you want to delete employee Fay's row from the employees table, you 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, delete from X will result in the removal of all the rows in the table, as shown here:

SQL> Delete from X;

You can also remove all rows in a table using the truncate command, but the big difference, of course, is that you can't undo or roll back the truncate command's effects. You can undo a delete, on the other hand, by using the rollback statement:

SQL> rollback;

The Update Statement The update statement changes the value (or values) of one or more columns of a row (or rows) in a table. 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> ];

In the update statement, the expression to which a column is being set or modified can be a constant, an arithmetic or string operation, or the product of a select statement.

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, as shown here:

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, as follows:

SQL> update persons set salary = salary * 0.10 where review_grade > S;

A Brief0racle9i SQL and PUSQL Primer

Filtering Data The 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 Query Frequently, 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(s) of one or more columns. You can choose the sorting order and you can choose to sort by column aliases. You can also sort by multiple columns. I explain the Oracle order by clause in the following sections.

The Order By Clause The order by clause lets you sort the results of a query based on one or more columns' values. You can sort the results in an ascending or descending order. Here's an example:

SQL> select employee_id, salary from employees order by salary;

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 keyword desc, as shown here:

SQL> select employee_id, salary from employees order by salary desc;

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 ;

1111

Appendix

1112

Operators SQL provides you with a number of operators to perform various tasks, such as comparing column values and performing logical operations. In the following sections you'll look at the important SQL operators.

Comparison Operators Comparison operators compare a certain column value with several other column values. Here 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 Oess 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 certain rules of precedence. Oracle always evaluates arithmetical operations such as mul­tiplication, division, addition, and subtraction before it evaluates conditions. The following is the order of precedence of operators in Oracle, with the most important being listed first:

=, !=, <, >, <=, >=

IS NULL, UKE, BETWEEN, IN, EXISTS

NOT

AND

OR

A Brief0racle9i SQL and PUSQL Primer

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:

• 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.

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 in the case of a 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 isn't in the second query's results. The result set is distinct and sorted.

SQL Functions Oracle functions manipulate data items and return a result. Built-in Oracle9 i func­tions help you perform many transformations quickly, without your having to do any coding. In addition, you can create your own user-built functions. You can separate functions into several groups, as explained in the following sections.

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

• CONCAT: The CON CAT 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.

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

SQL> select LOWER('SHANNON ALAPATI') from dual; LOWER('SHANNONALAPATI')

shannon alapati SQL>

1113

Appendix

1114

• SUBSTR: The SUBSTR function gives you 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 another specified replacement string.

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: Returns the smallest value

select min(join_date) from employees;

• MAX: Returns the largest value

• AVG: Computes the average value of a column

• SUM: Computes the sum of a column

SQL> select sum(bytes) from dba_free_space;

• COUNT: Returns the total number of columns

• COUNT(*): Returns the number of rows in a table

Number and Date Functions Oracle9 i includes a number of number functions. The data functions help you format dates and times in different ways. Here are some of the important number and date functions:

• ROUND: This function returns a number rounded to the specified number of integer 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

08/FEB/2003 04:05:18 SQL>

A Brief0racle9i. SQL and PUSQL Primer

• 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-MON-YYYY, as shown in the following example:

20-FEB-2003

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

SQL> select to_date ('February 20, 2003', 'MonthDD,YYYY') from dual; TO_DATE(' FE

20-FEB-2003 SQL>

• TO_ CHAR: This function converts a data into a character string, as shown in the following example:

SQL> select sysdate from dual; SYSDATE

20-FEB-2003 SQL> SQL> select to_char(sysdate, 'dd/mon/yyyy') from dual; TO_CHAR{SYSDATE, 'DD/MON/YYYY')

20/FEB/2003 SQL>

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

General Functions and Conditional Expressions Oracle9 i provides some very powerful general functions 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 func­tions help you decide among several choices. Here are the important general and conditional Oracle9 i expressions:

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

SQL> select last_name, title, salary * NVL (commission_pct,o) I 100 COMM from employees;

1115

Appendix

1116

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

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' WHEN 40 THEN 'Operations' ELSE 'Unknown' END) department FROM employees;

SQL 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 Oracle9 i Release 2 database:

• Ranking functions enable you to rank items in a data set according to some criteria. Oracle9i has several types of ranking functions, including rank, dense rank, cume_dist, percent_rank, and ntile. The following code shows a simple example of how a ranking function can help you rank some sales data:

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 - - -

A Brief0racle9i SQL and PUSQL Primer

sales.sales_type_id=sales_types.sales_type_id AND timeframe.calendar_month_desc IN ('2003-01', '2003-02')

AND country_id='INDIA' GROUP BY sales_type;

SALES_TYPE SALES ORIGINAL_RANK DERIVED_RANK

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

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

• Period-overperiod comparisons let you compare two periods (e.g., "How does the first quarter of 2002 compare with the first quarter of 2003 in terms of percentage growth?").

• Ratio-to-report comparisons make it possible to compare ratios (e.g., "What is August's enrollment as a percentage of the entire year's enrollment?").

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

• Inverse percentiles help you find the data corresponding to a percentile value (e.g., "Get me the names of the salespeople who correspond to the median sales value.").

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

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

• First/last aggregates are appropriate when you are using the group by clause to sort data into groups. These aggregate functions let you specify the sort order for the groups.

Hierarchical Retrieval of Data If a table contains hierarchical data (i.e., 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 rela­tionship.

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

1117

Appendix

1118

Listing 1 shows a hierarchical relationship between the employees and manager columns. The connect by clause describes the relationship. The start with clause specifies where the statement should start tracing the hierarchy.

Listing 1. 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 101

SQL>

Selecting Data from Multiple Tables So far, you've mostly seen 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 link data that's in two or more tables into a single query result. In the following sections you'll look at the various types of Oracle table joins. Note that a table can be joined to other tables or to itself.

The Cartesian Product 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. Cartesian products of two large tables are almost always the result of a mistaken SQL query that omits the join condition. Here's an example of a Cartesian join:

SQL> select * from employees, dept;

When you use a join condition when you're combining data from two or more tables, you can limit the number of rows returned, as you will learn in the fol­lowing section.

A Brief0racle9i. SQL and PUSQL Primer

The Four Types of Oracle Joins Oracle offers you four major types of joins based on the way you combine rows from two or more tables or views. The next sections discuss the four types of Oracle joins.

Equi-join

With an equi-join, the 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, as shown in the following 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, before performing the join. 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. The following is a simple example of a self join. The table employees 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);

1119

Appendix

1120

Inner Join

An inner join returns all rows that satisfy the join condition. The traditional 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 Oracle9 i 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 in the other table. 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 join statement. Oracle9i also provides the Oracle 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 joins. 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 Operations Oracle provides several clauses that enable you to 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. Normally, you use the group by clause so you can perform an aggregate function.

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;

A Brief0racle9i SQL and PUSQL Primer

DEPARTMENT_ID MAX{SALARY) ------------- -----------

10 4400 20 13000 30 11000 40 6500 50 8200

5 rows selected. SQL>

Nesting Group Functions Oracle allows you to nest group functions. The following query gets you the minimum average budget for all departments:

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 clause gives you subtotals and total values. You can thus build subtotal aggregates at any level. In other words, the rollup clause gets you the aggregates at each group by level. The subtotal rows and the grand total row are called the superaggregate rows. Listing 2 shows an example of using the rollup clause.

Listing 2. A Group By with a Rollup Clause

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>

1121

Appendix

1122

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>

The Group By Clause with a Grouping Operator As you've seen, the rollup function gets you the superaggregate subtotals and grand totals. The grouping function 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 aggregates such as sums. Here's an example that shows how you can use this operator to calculate aggregates over three groupings: (year, region, product), (year, product), and (region, product). The grouping sets operator eliminates the need for inefficient union all operators.

SQL> select year, region, product, sum(sales) from regional_sales group by grouping sets (( year, region, item), (year, item), (region, item));

A Brief0racle9i SQL and PUSQL Primer

The Having Clause The having clause 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 clause 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 24000 SQL>

Writing Subqueries Subqueries resolve queries that have to be processed in multiple steps. The answer to a query depends on the results of a child or sub query to the main query. If you put a subquery in the where clause of a select statement, it's called an in line view. If the subquery occurs in the where clause of the statement, it's called a nested subquery. The following sections show you how to use a subquery to rank the values in a column.

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.

1123

Appendix

1124

Single-Row Subqueries Subqueries are useful when you need to answer queries on the basis of as yet unknown values. Subqueries help you answer questions such as the following: 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 resulting query:

SQL> SELECT first_namel Jlast_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 thanone 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 the following: 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 information. 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 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:

A Brief Oracle9i. SQL and PUSQL Primer

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

Abstract Data Types In this section you'll briefly review the important Oracle9i 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 proce­dures 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. The Oracle9i support of object-oriented features such as types makes it feasible to implement object-oriented features such as encapsulation and abstraction while modeling complex real-life objects and processes. Oracle9i also supports single inheritance of user-defined SQL types.

The Create Type Command Object 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)) 4 I

Type created. SQL>

Object Tables Object tables contain objects such as the person type you created in the previous section. Here's an example:

SQL> create table person_table of person; Table created. SQL>

1125

Appendix

1126

Here's the interesting part. The table person_ table doesn't contain single value columns like a regular Oracle table-its columns are types, which can hold mul­tiple values. You can use object tables to view the data as a single-column table or a multi-column table that consists of the components 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>

Collections Collections are ideal for representing one-to-many relationships among data. Oracle9 i offers you two main types of collections: varrays and nested tables. You'll look at these two types of collections in more detail in the following sections.

Varrays

Varrays are stored in the database as RAW or BLOB objects. 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 an array type:

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:

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 Inheritance You 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:

A Brief0racle9i SQL and PUSQL Primer

SQL> create type person_t as object ( name varchar2(8o), 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:

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 Operator The cast operator enables you to do two things. First, it lets you convert built -in data types. Second, the cast operator lets you convert a collection-type value into another collection-type value.

Here's an example of using castwith built-in data types:

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

The sample schema OE has the following types. Use these types for the cast example that follows.

CREATE TYPE address_book_t AS TABLE OF cust_address_typ; CREATE TYPE address_array_t AS VARRAY(3) OF cust_address_typ;

Using the cast operator, you can convert a varray into a nested table, as shown here:

SQL> SELECT CAST(s.addresses AS address_book_t) FROM states s WHERE s.state_id = 111;

Using Pl/SQL Although SQL is easy to learn and has a lot of powerful features, it doesn't allow 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.

1127

Appendix

1128

The Basic PL/SQL Block A PL/ SQL block is an executable program. A PL/ SQL code block, whether encapsu­lated 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 state­ments 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:

declare isbn number (9)

begin isbn := 123456789; insert into book values (isbn, 'databases', 59.99); commit;

end;

Declaring Variables You can declare both variables and constants in the declare section. Before you can use any variable, you must first declare the variable. 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 to the varchar2, char, number, and date data types, PL/SQL uses the binary_integer and Boolean data types. Here are some common PL/SQL variable declarations:

Hired date DATE; Emp_name varchar 2(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;

A Brief0racle9i SQL and PUSQL Primer

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 department table, with identical data types and length:

Declare V_DeptRecord department%ROWTYPE;

Writing Executable Statements After the begin statement, you can enter all your DML statements. These look just like your regular SQL statements, but notice the difference in how you handle a select statement and an insert statement in the following sections.

A Select Statement in PLISQL

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

declare name varchar2(30);begin

end; I

Select employee_name into name from employees where emp_id=99999;

DML Statements in PLISQL

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:

Begin

End; I

Delete from employee where emp_id = 99999; Commit;

Handling Errors In 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, and program control is handed to the exception han­dling section of the PL/SQL program. If you define your own error conditions, you have to raise exceptions by using a special raise statement.

1129

Appendix

1130

The following example shows the use of one such 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; I

PL/SQL Control Structures PL/SQL offers you several types of control structures, which enable you to perform iterations of code or conditional execution of certain statements. You'll look at the various types of control structures in PL/SQL in the following sections.

Conditional Control The main type of conditional control structure in PL/SQL is the if statement, which enables conditional execution of statements. Here's a simple example. You can use the if statement in three forms: if-then, if then-else, and if-then-elsif. Here's an example of a simple if-then-elsifstatement:

BEGIN

IF total sales > 100000 THEN bonus := sooo;

ELSIF total_sales > 35000 THEN bonus := soo;

ELSE bonus := o;

END IF; INSERT INTO new_payroll VALUES (emp_id, bonus, ••• );

END; I

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.

A Brief0racle9i SQL and PUSQL Primer

The Simple Loop

The simple loop construct encloses a set of SQL statements in between the key­words loop and end loop, as shown in the following example. Note that 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. 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 duration 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 'I I 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 con­dition 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 <= 25000 Loop

SELECT sal INTO salary FROM emp WHERE total := total + salary;

END Loop;

1131

Appendix

1132

The For Loop

The for loop is used when you want a statement to be executed for 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

End;

For count_num in 1 •• 100 Loop

Dbms_output.put_line('The current count is End loop;

Cursors

'II count_num);

An Oracle cursor is an area in memory that holds the result set of a SQL query, enabling you to individually process the rows in the result set. An Oracle cursor is actually a handle to an area of memory that Oracle uses to execute code and store information. Oracle uses implicit cursors for all DML statements. Explicit cursors are created and used by application coders.

Implicit Cursors Implicit cursors are automatically used by Oracle every time you use a select statement in PLI 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 PLISQL 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 : 'llemp_namell' salary :'1 !salary);

End; I

Explicit Cursors Explicit cursors are created by the application developer, and they facilitate opera­tions 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 PLISQL 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:

A Brief0racle9i SQL and PUSQL Primer

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 3 shows how a cursor is created first and later used within a loop.

Listing 3. Using an Explicit Cursor

Declare I* The cursor select_emp is explicitly declared *I

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 I* The cursor select_emp is opened *I Open select _emp;

Loop I* The select_emp cursor data is fetched into v_empno variable *I

Fetch select_emp into v_empno; Exit when select_emp%NOTFOUND; Dbms_output.put_line(v_empnol I ','I lv_empcity);

End loop; I* The cursor select_emp is closed *I

Close select_emp; End; I

Cursor Attributes In the example shown in Listing 3, 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:

• %ISO PEN 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 fetched so far.

1133

Appendix

1134

Cursor For Loops Normally 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 automati­cally performs the open, fetch, and close procedures, which simplifies your job. Listing 4 shows an example that uses a cursor for loop construct.

Listing 4. Using the Cursor For Loop

Declare Cursor emp_cursor is Select emp_id, emp_name,salary From employees; V_emp_info employees%RowType;

Begin For emp_info IN emp_cursor LOOP Dbms_output.put_line ('Employee id : 'llemp_idii'Employee name : ' II emp _name II' Employee salary :' II salary); End LOOP;

End; I

PLISQL Records Records 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 record, 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 the dot notation, as shown here:

meetingtyp.location

Cursor Variables Cursor 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 other procedures and functions. Let's see 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;

A Brief0racle91 SQL and PUSQL Primer

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(30), sal NUMBER(7,2));

TYPE EmpCurTyp IS REF CURSOR RETURN EmpRecTyp; emp_cv EmpCurTyp; -- declare cursor variableProcedures

A PL/SQL procedure can be used to perform various DML operations. The fol­lowing is a simple Oracle procedure:

create or replace procedure 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; I

Functions 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;

Packages Oracle packages are objects that usually consist of several procedures and func­tions. These procedures and functions are related to each other, and the package usually is designed to perform an application function by invoking all the related procedures and functions within the package. Packages are extremely powerful, because large amounts of functional code can be stored on the server and repeatedly executed by several users.

A package usually has two parts: a package specification and a package body. The package specification declares the variables, cursors, and subprograms (pro­cedures and functions) that are part of the package. The package body contains the actual cursors and subprogram code. Listing 5 shows a simple Oracle package.

1135

Appendix

1136

Listing 5. A PLISQL Package

I* First, the Package Specification I* create or replace package emp_pkg as type list is varray (100) of number (5); procedure new_employee (emp_id number, last_name varchar 2, first_name varchar2); procedure salary_raise ( emp_id number, raise number);

end emp_pkg; I I* The Package Body follows *I create or replace package body emp_pkg as procedure 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; I

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 em_pkg.salary_raise(99999, 0.15);

Oracle XML DB A 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 an Excel spreadsheet. Storing the nondatabase information in XML format makes it easier to access and update nonstructured organizational 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 in Oracle9i Release 2 for the manipulation ofXML data. Oracle9i XML DB provides the advantages of object-relational database technology andXML technology. For example, one of the major problems involved in dealing with XML data from within a relational database is the fact that most XML data is hierarchical in nature, whereas the Oracle database is based on the relational model. Oracle9imanages to deal effec­tively with the hierarchical XML data by using special SQL operators and methods. Using these operators, you can easily query and update XML data stored in an

A Brief0racle9i. SQL and PUSQL Primer

Oracle9i database. Oracle XML DB builds 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 nonstruc­tured information as relational data. You can now view data as either rows in a table or nodes in an XML document. Here is a brieflist 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 multi­media 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 DB Oracle9 i uses a special native data type called XMLType to store and manage XML data in a relational table. XMLType andXDBUEIType, 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 XMU'ype data type just as you would the usual data types in an Oracle database. You can now store a well-formed XML document 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 SALES ORDER

SQL>

NUMBER(18) XMLTYPE

The XMU'ype data type comes with a set ofXML-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 operators 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-knownXPath 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.

1137

Appendix

1138

• TransformO performs an XSL transformation.

• ExtractValueO returns a node corresponding to an XPath expression.

XML is in abstract form compared to the normal relational table entries. How does Oracle 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 transformed SQL statement like any other SQL statement.

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 table sales_catalo~table to demonstrate how to perform SQL-based DML operations with an XML-enabled table. In the following section, you'll learn how to use the Oracle XML DB repository to load XML data into a table. In listing 6, an XML document is inserted into the sales_catalo~table table.

Listing 6. 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 <Shippinglnstructions/> 12 <Deliverylnstructions>Bicycle Courier</Deliverylnstructions> 13 <ltemDescriptions> 14 <ltemDescription ItemNumber:"1"> 15 <Description>Expert Oracle DB Administration</Description> 16 <ISBN Number:"1590590228"Price:"59.95"Quantity:"5"1> 17 </ItemDescription> 18 </ItemDescriptions> 19* </SalesOrder>'));

1 row created. SQL>

You can query the sales_catalo~table table's sales_order column, as shown in listing 7, to view the XML document in its original format.

A Brief Oracle9i. SQL and PUSQL Primer

Listing 7. 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</Deliverylnstructions> <ItemDescriptions>

<ItemDescription ItemNumber="1"> <Description>Expert Oracle DB Administration</Description> <ISBN Number="9999990228" Price="S9.9S" Quantity="2"1>

</ItemDescription> </ItemDescriptions>

</SalesOrder> SQL>

Once you create the table sales_catalog_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 extractO 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 node /SalesOrder/SalesLocation/textO contains the value Dallas.

1 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. Alapati SQL>

The Oracle XML DB Repository The best way to process XML documents in Oracle XML DB is to first load them into a special repository called the Oracle XML DB repository. The XML repository is hierarchical, like most XML data is, and it enables you to easily query XML data. The paths and URLs in the repository represent the relationships 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

1139

Appendix

1140

Internet protocols such as HTTP, FTP, and WebDAV. For example, you can use Wmdows 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 a file abstraction when dealing with XML data.

Setting Up an XML Schema Before 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 6, is a simple XML schema that reflects a simple XML document. Within the SalesOrder schema are elements such as ltemDescription, 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 Oracle9i database using a PL/SQL procedure. When you register the XML schema, Oracle will create the SQL objects and the XMIJYpe tables that are necessary to store and manage the XML documents. In the previous example, registering the XML schema created a table called SalesOrder auto­matically, with one row in the table for each SalesOrder document loaded into the XML repository. The XML schema is registered under the URL http: I /local host: 8080/home/SCOTI /xdb/salesorder .xsd and contains the definition of the SalesOrder element

Creating a Relational View from an XML Document Even if a developer doesn't know much XML, he or she can use the XML docu­ments stored in the Oracle database by creating relational views based on the XML documents. In the following example, you'll see how to map nodes in an XML doc­ument 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 then query salesorder_ view like you would any other view in an Oracle database, as shown here:

SQL> select requestor,sales_location from salesorder_view; REQUESTOR SALES LOCATION Aparna Alapati Dallas SQL>

A Brief Oracle9i. SQL and PUSQL Primer

Oracle9i and Java You can use both PL/SQL and Java to write applications that need Oracle9i 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 Oracle9i database contains a Java Virtual Machine (JVM) to enable the interpretation of Java code from within the database. Just as PLI 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.

Using Java with Oracle You can use the Java programming language in several ways in Oracle9i. 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 inter­faces (APis), Java Database Connectivity (JDBC) or SQLJ, to access the Oracle9i database from a Java-based application program. In the sections the follow, you'll briefly look at the various ways you can work with Java and the Oracle database.

Java Stored Procedures

Java 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.

You can execute Java stored procedures just as you would PL/SQL stored pro­cedures. Here's a summary of the steps involved in creating a Java stored procedure. You can invoke the Java stored procedure after you complete the fol­lowing steps:

1. Define the Java class.

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

3. Load the class into the Oracle9i database. You can do this by using the loadjava command-line utility.4. Publish the Java stored procedure.

JDBC

JDBC is a popular method used to connect to an Oracle database from Java. Chapter 11 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 8 shows a simple JDBC program that connects to an Oracle database and executes a simple SQL query.

1141

Appendix

1142

Listing B. A Simple JDBC Program

import java.sql.*; public class JDBCExample {

public static void main(String args[]) throws SQLException I* Declare the type of Oracle Driver you are using *I

{DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); I* Create a database connection for the JDBC program *I Connection conn= DriverManager.getConnection(

"jdbc:oracle:thin:@nicholas:1521:aparna","hr","hr"); Statement stmt = conn.create5tatement(); I* Pass a query to SQL and store the results in the result set rs *I ResultSet rs = stmt.executeQuery("select emp_id, emp_name,salary from employees"); I* Using the while loop, result set rs is accessed row by row *I while(rs.next()){ int number = rs.getlnt(l); String name= rs.getString(2); System.out.println(number+" "+name+" "+salary);

} I* Close the JDBC result set and close the database connection *I rs.close(); conn. close();

} }

JDBC is ideal for dynamic SQL, where the SQL statements aren't known until runtime.

SQLJ

SQLJ is a complementary API to JDBC, and it's ideal for applications in which you're using static SQL (i.e., SQL that's known before the execution). Being static, SQLJ enables you to trap errors before they occur during runtime. Do understand 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 com­piler.

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

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

A Brief Oracle9i SQL and PUSQL Primer

Listing 9. A Simple SQLJ Program

import java.sql.*; import sqlj.runtime.ref.DefaultContext; import oracle.sqlj.runtime.Oracle; I* Declare the variables here */ I* Define an Iterator type to store query results */ #sql iterator Examplelter (int emp_id, String emp_name,float salary); public class MyExample I* The main method */

{ public static void main (String args[]) throws SQLException {

I* Establish the database connection for SQLJ */ Oracle.connect

("jdbc:oracle:thin:@shannon:1234:nicholas1", "hr", "hr"); I* Insert a row into the employees table */

#sql { insert into employees (emp_id, emp_name, salary) values (1001, 'Nina Alapati', soooo) };

I* Create an instance of the iterator Exampleiter */ Exampleiter iter;

I* Store the results of the select query in the iterator Exampleiter */ #sql iter={ select emp_id, emp_name, salary from employees };

I* 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 9, 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 Oracle9 i and Java, please visit Oracle's Java Center Web site (http: II otn. oracle. com/tech/ java/ content. html).

Summary This appendix provided you with a brief review of the most commonly used SQL and PL/SQL in the Oracle9i database. As a DBA, you may not be expected to be a master of high-level SQL and PL/SQL. However, because developers use pro­gramming languages such as these on a daily basis, it's helpful for you to be familiar with as much SQL and PL/ SQL as you possible can.

Java and XML play increasingly important roles in the Oracle database. This appendix provided you with an introduction into how Java and XML are integrated with Oracle9i.

1143

Index

*-- (comment delimiter), 217 $(shell command prompt), 59, 77 $HOME/profile file, 64 $0RACLE_HOME/ dbs directory, 368 % (shell command prompt), 59 & (ampersand), 216 *I (comment delimiter), 217 . (dot), 213 I command, 215 I* (comment delimiter), 217 <(redirection operator), 66 <<(redirection operator), 66 >(redirection operator), 66 »(redirection operator), 66 @(at sign), 213 [] (square brackets), 204 _(underscore), 151 {}(curly brackets), 204

A absolute path, 72 abstract data types, 1125-1127 abstraction, in object-oriented

database model, 51 acceptcommand,211 access control

fine-grained,497-500,1064 label-based, 500-501

access driver, External Table feature, 556

access parameters clause, External Table feature, 556, 557, 558-559

ACID properties, 312-313 Active Directory, 1080 active sessions, 752 active_sess_pool_pl parameter, 768 ActiveX Data Objects (ADO), 1078 Adams, Steve, 18 adding table partitions, 272

adhoc directory, 113 administrative files, Oracle, 111, 113,

115 ADO (ActiveX Data Objects), 1078 adump directory, 113 Advanced Events feature, 816 Advanced Replication feature, 675 Advanced Security feature, 523 advisories, SGA and PGA, 183-185 aggregate SQL functions, 1114,

1120-1121 alert log file

checking for problems, 960-961 instance creation example, 398-399,

401-403 overview, 151-152 viewing contents, 152 viewing OMF files in database

example, 740-741 algebra, relational, 28-29 ALL_HOMES Registry subkey, 1090 allocate channel command, RMAN,

653,654 all_rows hint, 842 all_rows optimizer mode, 831 alter command, 201,251 alter database command, 251,415,416 alter index command, 170 alter profile command, 416,513,514,

524 alter session command, 239, 320, 321,

370,730,731 alter system command, 168, 238-239,

253,335,370,527,766,858 alter table command, 170, 258-259 alter user command, 4 76 ampersand(&), 216 analytical SQL functions, 1116-1117 analyze command, 667,714,829,830,

837-839

1145

Index

1146

analyze validate feature, 7 44 Analyze Wizard, 801-802 AND operator, 1112 append command, 221 application context

creating, 496--497 creating package to access, 497-498 creating package to set, 496 and USERENV namespace, 494-496

Application Performance Monitoring (APM), 774

ARCH. See archiver (ARCH) background process

archive logs backing up, 643 changing logging mode, 406--408 dictionary views, 1012-1015 initialization parameters, 381-382 managing, 764

archivelog command, 223 archivelog mode

vs. noarchivelog mode, 406--408, 612-613,619

overview, 612-613 archiver (ARCH) background process

and database hangs, 954-962 how it works, 955 overview, 161, 165-166 what to do when it sticks, 954,

955-956 arraysize SQL *Plus environment

variable, 203 as_authent_prefix initialization

parameter, 516,520 ASCII files, loading table data into, 575 ASCII mode data transmission, 87 asynchronous 1/0, and DBW

background process, 162 at command, Wmdows, 928, 1087 at sign(@), 213 atomicity, as ACID property, 312 attributes

in ERM, 33, 34-35, 36 and normalization, 38-40 predefined in USERENV

namespace, 495

in relational database model, defined, 27

audit trail, 511 audit_file_dest initialization parameter,

371 auditing

customizing, 501-506 default, 506-507 dictionary views, 987-988 enabling, 505-506 fine-grained, 509-511, 1065 initialization parameters, 371-373 levels, 508 object-level audits, 508 overview, 501 privilege-level audits, 508 security guidelines, 520 statement-level audits, 508 turning off, 509 turning on, 508-509

audit_sys_operations initialization parameter, 372

audit_ trail initialization parameter, 371

AUM. See Automatic Undo Management (AUM) feature

authentication external, 516 operating system level, 520 overview, 511 proxy, 517 remote client, 523 and RMAN utility connections,

622-623 role of passwords, 511-512 using database, 511-515 Windows Active Directory, 1080

authorization, role of centralized users, 517

autoallocateoption, 156-157, 245,247, 725

autocommit SQL *Plus environment variable, 203

automatic Oracle9i database features, 723-736

Automatic Segment Space Management feature, 156,725-726

automatic shutdown script, 134-135 automatic space allocation. See

extents, autoallocate option; segments, auto option; space management

automatic start-up script, 134-135 Automatic Undo Management (AUM)

feature advantages,333-334 and buffer busy waits, 946 creating undo tablespaces, 727 disadvantages, 730 implementing, 727-730 monitoring undo tablespaces, 729 overview, 158, 333, 726-727 setting up, 334-336 specifying undo retention period,

727-728 switching between undo

tablespaces, 728-729 and undo quota, 729-730

automating jobs, UNIX systems vs. Windows systems, 1087

autonomous SQL transactions, 346 Autotrace tool, 865-870

B B-tree data structure, 280 background dump directory, 113, 151,

152 background processes

defined, 160, 161 key list, 161 mandatory, 161 overview, 161

background_dump_destinitialization parameter, 375

backing up databases. See also RMAN (Recovery Manager)

clone techniques, 104 closed backups, 614,656-658 cold backups, 658 consistent vs. inconsistent backups,

613-614,619 Fujitsu's Remote Equivalent Copy,

104

guidelines for backup processes, 616-618

H-P's Business Copy, 104 hotbackups,659-661 new technologies, 104 online backups, 614,658-661 open backups, 614,658 open vs. closed backups, 614,658 overview, 3, 7, 611-619 and RAID, 100 role of System Change Numbers,

613-614 SAN works Enterprise Volume

Manager, 104 snapshottechniques,104 strategies, 614-618 Sun's Instant Image, 104 terminology, 612-614 testing backup files, 618 troubleshooting, 670-671 user-managed methods, 619, 620,

621 using tape devices, 611, 620, 621,

634 verifying RMAN backups, 669-670 which files to backup, 619 whole vs. partial backups, 613

backing up recovery catalog, 640-642 backup command, RMAN, 627 backup controlfile command, 695 backup pieces, defined, 625 backup sets, defined, 625 backup utilities, UNIX, 84-85 Backup Wtzard, 802-803 bad file external table access

parameter, 559 bad parameter, SQL *Loader control

file, 545 begin statement, PLISQL, 201, 1128 best practices, Optimal Flexible

Architecture recommendations as, 110

between comparison operator, 1112 binary operations, 828. See also set

operations binary type data transmissions, 87

Index

1147

Index

1148

bind variables, 852, 898-899 binding, in SQL transactions, 312 bindsize parameter, SQL *Loader

control rue, 544 bitmap indexes, 281-282,847 bitmap join indexes (BJis), 843-844 bitmap_merge_area_size initialization

parameter, 855 bitmaps, storing database space

management information as, 153 BJis. See bitmap join indexes (BJis) block dumps, 142-143 block media recovery (BMR), 714-715 block size, changing online, 753-755 blockinglocks,330-331 blockrecovercommand, RMAN, 714 blocks. See data blocks BMC Software, 58 Boolean operators, 1112 Bourne shell, 57,59 Boyce-Codd normal form (BCNF), 43 branching, 81-82 break command, 224 btitle command, 225 B*tree data structure, 280 buffer busy waits, 945-94 7, 949 buffer cache. See database buffer cache Buffer Cache Advisory, 184, 185, 908,

1005 Buffer Cache Size Advisor, OEM, 757 buffer parameter, import utility, 594 bug fixes, 889-890 Burleson Oracle Consulting Web site,

18 business rules, 47-48

c C shell, 57, 59, 65 cache buffer chain latch-free wait

event, 950 cache buffers LRU chain latch-free wait

event, 950 cache misses, 17 4 caches. See data dictionary; database

buffer cache; library cache calculus, relational, 29

candidate keys, 34-35, 37 Capacity Planner, OEM Diagnostics

Pack,935,936 cardinality, in ERM, 33-34, 37 Cartesian joins, 28,826,843, 1118 case, in UNIX, 63 CASE SQL function, 1116 case statement, SQL, 841 case statement, UNIX, 82 castoperator, 1127 catcommand,68 catalog.sql script, 403, 974 catexp.sql script, 605 catproc.sql script, 403 CBO. See cost-based optimizer (CBO) cdcommand,61,73 CD-ROM, Oracle9i server software, 123 central processing units. See CPUs

(central processing units) Certificate Store, 1080 certification, 15 channels, RMAN

allocate channel command, 653, 654 automatic configuration, 626 configuring, 635 defined,626 manual allocation, 626

check constraints, 287, 553 . checkpoint (CKPT) background

process,161, 162-164 checkpoint completed wait event, 947 checksums, 667 Chen, Peter, 33 chmodcommand, 70, 71, 77, 78,79 chooseroptimizermode,830 CKPT. See checkpoint (CKPT)

background process classes, in object-oriented database

model, 50 CLASS_PATH variable, 135 clear command, 207-208 cloning databases, 698-703 closed backups, 614,656-658 closed database recovery, 677, 679 clusters, defined, 277 COALESCESQLfunction, 1116 coalescing table partitions, 27 4

Codd, E.R, 26 cold backups, 614,658 collections, 1126 colsep SQL *Plus environment variable,

203 column command, 224 column-level object privileges, 488 columnarrayrows parameter, direct

path data loading method, 553 columns, table

adding,745 changing data types, 7 45 dropping, 7 45 multiple-column subqueries, 1124 renaming, 7 45 what to index, 846-84 7

COMAutomation, 1078 COM (Component Object Model), 1078 command-line mode

executing shell programs, 77 export utility, 588-590 import utility, 598

command-line parameters, SQL*Loader control file, 543-547

command prompts changing, 77 overview, 59

commands, UNIX basic list, 61-62 options for, 63 switches for, 63

commit command, 189, 240, 310, 316-327

committed transactions, 189, 190, 191 comparison operators, 1112 compatible initialization parameter,

373 composite indexes, 278 composite partitioning, 271-272 compress command, 605, 608 compress parameter, export utility, 584 compression techniques, 854-855 compute command, 198,225 CON CAT SQL function, 1113 concatenate clause, SQL *Loader

control file, 540 concatenated indexes, 848

concurrency control overview, 322-323 controlling transactions, 313-318 dirty read problem, 314,318,319 implementing Oracle's control

system, 322-332 and ISO transaction standard, 316 last update problem, 315, 318, 319 locking methods of control, 322 nomepeatable read problem, 315,

318,319 overview, 189-190 phantom read problem, 314-315,

318 problems, 314-315 role of schedules, 315 timestamping method of control,

322 validation method of control, 322

condition external table access parameter, 559

conditional branching, 81-82 conditional SQL functions, 1115-1116 Configuration Assistant. See Enterprise

Manager Configuration Assistant, OEM; Net Configuration Assistant (NCA); Oracle Database Configuration Assistant (ODCA)

configure channel parameter, RMAN, 635

connect by clause, in hierarchical queries, 1117-1118

connect descriptors, 429, 430, 435 connect identifiers, 429-430 connectstrings,430 connectivity

net service name naming methods, 435-441

and Oracle Net Listener, 431-435 troubleshooting, 466-468

consistency as ACID property, 312-313 and ISO standard, 315-316 overview, 189-190 statement -level, 323 transaction-level, 323

consistent parameter, export utility, 586

Index

1149

Index

1150

consistent vs. inconsistent backups, 613-614,619

constants, in data loading, 547 constraint-related dictionary views,

995-999 constraints, creating in table

redefinition process, 7 49. See also integrity constraints

constraints parameter export utility, 585 import utility, 592

consumer groups assigning users to consumer groups,

481-483 creating consumer groups, 4 79 and

DBA_RSRC_CONSUMER_GRO UPS view, 480-481

switch_ current_ consumer _group procedure,1037

using plan directives to switch consumer group priorities, 752

contention. See resources, contention continueof clause, SQL *Loader control

file, 540 control file in SQL *Loader

bad parameter, 545 bindsize parameter, 544 command-line parameters, 543-54 7 concatenate clause, 540 continueofclause, 540 control parameter, 544 data file-related clauses, 539-541 data file specification, 539 data parameter, 544 data transformation parameters,

543 data types in, 542 delimiters in, 542-543 directparameter, 544-545 and discard file, 545 errors parameter, 545 field-mapping clauses, 541-543 load parameter, 545 loading-related clauses, 539 logparameter, 545 and logical records, 540

overview, 537-538 parallel parameter, 546 and physical records, 540 position clause, 542 record format, 541 resumable parameter, 546 resumable_name parameter, 546 resumable_timeoutparameter, 546 rows parameter, 544 skip parameter, 54 7 table column names, 541 table-mapping clauses, 541-543 userid parameter, 543

control files, database backing up, 644 backup controlfile command, 695 create controlfile command, 694,

696-697 key information in, 14 7 OMF file creation, 739, 740 OMF file naming convention, 738 overview, 114, 147-148, 191 recovering from loss, 693-697 redo byte addresses in, 163 RMAN backup parameters, 636-637 role ofOMF feature, 736-742 role ofSCNs, 191 significance in Oracle database, 191 as type of database file, 114 user-managed backups, 657

control parameter, SQL *Loader control file,544

control structures conditional branching, 81-82 for-do-done loops, 80 if-then-else structure, 81 looping, 79-81 overview, 79 until-do-done loops, 8~1 while-do-done loops, 79-80

control_file_record_keep_time initialization parameter, 389

control-files initialization parameter, 374

coordination job background process, 161

copy command, RMAN, 628

copy command, SQL*Plus, 198, 221-222

copy commands, UNIX, 655-662 copy utilities, UNIX systems vs.

Windows systems, 1087 copycommit SQL *Plus environment

variable, 203 copying files, 68 core dump directory, 113, 152 core dumps, 946--94 7 core_dump_dest initialization

parameter, 374 corruption, database

in control files, 666 in data blocks, 666--667 in redo logs, 666, 763 repairing, 714-716, 1044-1045 role of analyze command, 667 role ofDBMS_REPAIR utility,

668-669 role of dbverify utility, 668 trial recoveries, 715-716

cost-based optimizer (CBO) choosing join method, 833 choosing join order, 833 drawbacks, 833-834 exarnple,826--827 hints that influence execution plan,

842 ovenriew,l94-195,828-829 plan stability feature, 855, 856 problem of bad statistics, 960-962 providing statistics to, 829-830,

834-839 refreshing statistics, 860 role of stored outlines, 855-859 vs. rule-based optimization, 829 selecting access path, 832-833 setting level, 831 setting mode, 830-831 and SQL statement transformation,

831-832 what it does, 830-833 when to use, 829

courses, 13-14 cp command, 68, 655

cpio command, 84-85, 1087 CPUs (central processing units)

determining top users, 914-915 determining units used by

processes, 914 long run queues, 913 parse time, 916--918 performance tuning, 912-918,

966--967 reasons for system slowdowns,

913-918 recursive usage, 918 role in Oracle database

performance, 139-140 system utilization problems, 956 tracking by using OEM, 915 UNIX systems vs. Windows systems,

1086 ways time is used, 915-918

create catalog command, RMAN, 638-639

create command, 264-265 create controlfile command, 694,

696--697 create database command, 400, 401,

724-725,727 create database link command, 765 create directory command, 559 create outline command, 858 create procedure command, 490 create profile command, 513 create schema command, 241 create table command, 559 create tablespacecommand, 725,741 create type command, 1125 create_ stat_ table procedure, 835 create_stored_outlines initialization

parameter, 857, 1046 crontab utility, 928 crontab utility, UNIX, 85, 1087 cross-checking RMAN backups, 669 crosscheck command, RMAN, 631 CTAS command, 260-261 cube operator, 1122 cumulative incremental backups, 646 curly brackets (), 204 CURRDATE variable, 78

Index

1151

Index

1152

current_ user, as predefined USERENV attribute, 495

cursors, in PL/SQL transactions, 1132-1135

attributes, 1133 explicit, 1132-1133 implicit, 1132 for loops, 1134 overview, 1132 variables, 1134-1135

cursors, in SQL transactions, 311 cursor _sharing initialization

paramete~385,899-900,972

cursor _space _for _time initialization parameter, 385, 900-901

cutcommand, 75

D daemons (UNIX) us. Windows Services,

1084-1085 data, labeling, 500-501 data, older, querying, 340-341 data abstraction, in object-oriented

database model, 51 data blocks

buffer cache sizes, 145, 171 detecting corruption in, 666-669 as foundation of database storage ·

hierarchy, 140, 141 multiple sizes, 142, 144-145, 171,

249 online size changes, 753-755 optimum size, 141-142 overview, 140, 141 repairing corruption in, 714-716,

1044-1045 space allocation, 154-156 verification, 390 viewing contents, 142-143

data center disasters, 675 data concurrency. See concurrency data consistency. See consistency data definition language (DDL)

alter, begin, define, execute, and grantcommands,20l

us. data manipulation language (DML), 27-28, 201, 464

extracting from tables, 275-276 generating for external tables,

559-562 and JDBC, 464 overview, 27 SQL statements as, 30, 240-241

data dictionary archive log-based views, 1012-1015 audit-related views, 987-988 backup-related views, 1008-1009 cache size, 173 caching information, 902-903 constraint- and index-related views,

995-999 creating, 97 4 creating objects, 403-404 dynamic performance views,

1003-1027 exporting metadata for tablespaces,

602-603 file-related dynamic views,

1026-1027 general dynamic views, 1022-1025 general static views, 975-979 as internal Oracle set oftables, 191 LogMineruse, 706,708-711 memory-related views, 1004-1009 operational performance-related

views, 1018-1021 overview, 192-193,973-974 ownership, 193 performance monitoring views,

1016-1017 recovery-related views, 1015-1016 redo log-based views, 1012-1015 role of shared pool, 172, 173 session-related views, 1010-1012 SQL-related views, 1018 static views, 975-1003 storage-related dynamic views,

1026-1027 storage-related static views, 989-993 and tablespaces, 153

user-related dynamic views, 101Q-1012

user-related static views, 979-987 views for managing database

objects, 999 views for managing tables, 274-277,

999-1003 views for managing tablespaces,

254-256 views for managing undo space

information, 340 views for managing views, 999-1003 views for monitoring transactions,

993-995 views overview, 296-297

data encryption, 518 data extents. See extents data file record numbers, in data

loading, 54 7 data file-related clauses, SQL *Loader

control file, 539-541 data file specification, SQL*Loader

control file, 539 data files

autoextending,251 managing through OEM console,

796,797 mapping to physical devices,

766-768 OMF file creation, 739, 741 OMF file naming convention, 738 overview, 111, 114, 115, 145, 146-147 as raw files, 145 recovering, 688-589 recovering without backups,

697-698 renaming, 252 role ofOMF feature, 736-742 role ofSCNs, 191 storing database space

management information in, 153

and tablespace management, 153-154

user-managed backups, 656-657 data flow diagrams (DFDs), 31

data loading. See also ETL (Extraction, Transformation, Loading) process

generating data, 54 7 load-then-transform method, 534 overview, 533-535 role of DBA, 8 transform-then-load method, 534 using external tables, 555-562

data manipulation language (DML) vs. data definition language (DDL),

27-28,201,464 insert, delete, select, and update

commands,201,239,1107-1110 and JDBC, 464 making changes permanent, 222 overview, 27-28 and PLISQL, 1129 SQL statements as, 30, 201, 239-240,

1107-1110 data parameter, SQL *Loader control

file, 544 data reorganization features, Oracle9i

database, 742-745 data transformation

deriving data from existing tables, 562,563-564

overview, 562 using PL!SQL, 564, 565 using SQL, 564-573 ways of performing, 562-563

data transformation parameters, SQL *Loader control file, 543

data transmission, and FTP, 87 data types

abstract, 1125-1127 array, 242 object, 242 specifying in database tables, 4 7 in SQL *Loader control file, 542 table, 242 user-defined, 242 XML schema, 242

data warehouses, transforming data, 562-563. See also Oracle9i Warehouse Builder (OWB); Warehouse Management feature, OEM

Index

1153

Index

1154

database administrators (DBAs) background needed, 12-15 backup responsibilities, 3, 7 certification, 15 creating and managing users, 5 database design role, 8-10 design responsibilities, 4 general advice for, 21-22 implementation responsibilities, 4 job classifications, 10 managing users, 4 70-4 77 organizations for, 16-18 overall responsibilities, 3-4 overall role, 3-10 performance responsibilities, 3, 6,

18-19,853-860 resources for, 16-18 security role, 3, 4-5 staying informed, 16-18 system management role, 6-8 training, 12-15 typical daily routine, 21

database buffer cache advisory, 184, 185, 908, 1005 allocating to multiple pools, 170,

171, 908-911 and block sizes, 171, 753, 754,

906-908 and database writer background

process, 161-162 default pool, 908, 909 dynamicreconfiguration,755-757 hitratios, 172-175,937 keep pool, 908,909,910 overview, 169-170 performance tuning, 906-911 pooltypes,170-171,908,909,910 recycle pool, 908, 909, 910 role of checkpoint background

process, 162-164 as SGA component, 168 writing data to disk, 161-162

Database Creation Agent (DBCA), 334 database design, 31-48 database failures

extentoffailure,677-679 human error, 675-676

media-type,94,676-677 overview, 673 reducing vulnerabilities, 679-680 system-type,673-674

database files, Oracle, 114-115 Database Health Overview Chart, 934,

935 database instance names, 428 database level option, export utility,

582-583 database links

creating, 764-766 overview, 764 private, 764-765 public, 765-766

database migrations, 606-607 database recovery

change-based SCN recovery, 690 complete recovery of whole

databases, 683-686 complete vs. incomplete, 679 data file recovery, 688-689 vs. database restoration, 677 fast -start fault recovery, 67 4-675 incomplete,690-693 initialization parameters, 388-389,

674-675 log sequence recovery, 690 open vs. closed, 677, 679 phases, 734-736 point-in-time, 704-705 recovering data files without

backups, 697-698 recovering from loss of control files,

693-697 redo or roll-forward phase, 734 role of DBA, 7 tablespace recovery, 681-682,

686-688 time-based recovery, 690-691 time factors, 678 trial recoveries, 715-716 troubleshooting, 716-718 types,677-679 typical media recovery scenarios,

683-698 undo or rollback phase, 734

undoing changes, 703-711 user-managed, 682-683,685-686,

688,689 using Flashback Query feature,

711-714 using LogMiner utility, 705-711 using RMAN, 680-682, 683-685,

686-687,688-689 Database Resource Manager

assigning users to consumer groups, 481-483

controlling undo space, 729 creating consumer groups, 4 79 creating pending area, 4 79 creating plan directives, 483-484 creating resource plans, 483 and

DBA_RSRC_CONSUMER_GRO UPS view, 480-481

enabling, 485-486 how to use, 4 78-483 internal_quiesce resource plan

directive, 768 overview, 478, 751-752 and quiesced mode, 422-423, 768 reasons to use, 477-478 role of plan directives, 752 switching long-running

transactions, 752 what it does, 751-752

database service names examples, 428 overview, 428-429 registering with listener, 432-433

database start-up triggers, 503 database writer (DBW) background

process defined, 161 fast commit mechanism, 190 overview, 161-162 role of CKPT background process,

162-164 write ahead protocol, 190

database_name initialization parameter, 428

databases. See also relational databases; tablespaces

allocating file space, 365 automatic start-up and shutdown

scripts, 134-135 backing up, 3, 7, 611-671 cloning, 698-703 cost-based optimizer, 194-195 creating,9,334,363,393-409 creating default user accounts, 512 creating file systems for, 365-366 creating objects, 9-10 designing, 8-10 development type, 11, 12 DSStype, 11 estimating requirements, 7 hanging,954,960-962 high-performance, 18-19 hit ratios, 937 instance names, 428 loading data, 8, 533-535 (See also

data loading) monitoring status with V$VIEWS,

423 mounting, 401, 415-416 OLAP type, 11, 797, 798, 854 OLTP type, 11 opening,416-417 vs. Oracle instances, 139 overview, 26-30, 114-115 performance tuning goals, 6,

953-954 production type, 11, 12 protecting, 4 (See also security) putting in quiesced state, 422,

759-760,768 quiesced state, 422, 759-760, 768 recovering, 673-718 relational model, 26-30 restoring, 607, 677 restricting access, 417-418 role of schemas, 27 security guidelines, 519-524 service names, 428-429 shutting down, 418-421 simple transaction example,

187-189 sizing files, 365 starting, 414-417

Index

1155

Index

1156

suspended mode, 423, 760 systems management, 6-8 test type, 11, 12 things to do before creating,

364-393 troubleshooting, 6, 19-20 types, 10-12 user-managed backups, 655-662 wait statistics, 938-952

date command, 61 date SQL functions, 1114-1115 DB file scattered read wait event,

947-948 DB file sequential read wait event, 948 DBA_AUDIT_OBJECT view, 988 DBA_AUDIT_SESSION view, 988 DBA_AUDIT_STATEMENT view, 988 DBA_AUDIT_TRAIL view, 987-988 DBA_BLOCKERS table, 330 DBACUCKWeb site, 18 DBA_COL_PRIVS view, 527, 985 DBA_ CONS_ COLUMNS view, 996 DBA_ CONSTRAINTS view, 995-996 DBA_DATA_FILES view, 254-255,

991-992 DBA_EXTENTS view, 989-990, 1047 DBA_FREE_SPACE view, 255-256, 990,

1047 DBA_IND_COLUMNS view, 997 DBA_INDEXES view, 997 DBAJOBS view, 978-979, 1033 DBA_LOCKS view, 994 DBA_MVIEWS view, 1002-1003 DBA_ OBJECTS view, 979 DBA_OJBECTSview, 909,910 DBA_OUTUNES view, 986 DBA_PART_TABLES view, 1000 DBA_POUCIES view, 985-986 DBA_PROFILES view, 475, 981, 1056 DBA_REGISTRY view, 976--977 DBA_RESUMABLE view, 352, 995 DBA_ROLE_PRIVS view, 527 DBA_ROLLBACK_SEGS view, 336. 340 DBA_RSRC_CONSUMER_GROUPS

view, 480-481 DBA_RSRC_PLANS view, 986--987 DBAs. See database administrators

(DBAs)

DBA_SEGMENTS view, 256, 991, 1047 DBA_SOURCE view, 978 DBAsupport.com Web site, 18 DBA_SYNONYMS view, 294 DBA_SYS_PRIVS view, 527, 984 DBA_TAB_COLUMNS view, 274-275,

1000-1001 DBA_ TABLES view, 274, 999 DBA_TABLESPACES view, 248, 255,

725-726,993 DBA_TAB_PARTITIONS view, 1000 DBA_TAB_PRIVS view, 527, 984-985 DBA_TEMP _FILES view, 991-992 DBA_UNDO_EXTENTS view, 340,

994-995 DBA_ USERS view, 525, 980-981, 1056 DBA_VIEWSview, 1001-1002 db_block_checkinginitialization

parameter, 390 db_block_checksum initialization

parameter, 390, 667 db_block_size initialization parameter,

171,386 DBCA (Database Creation Agent), 334 db_cache size initialization parameter,

171,182,378,910 db_cache_advice initialization

parameter, 381 db_create_file_destinitialization

parameter, 159, 253, 375, 737-738, 741

db_create_online_log_dest initialization parameter, 738,740,741

db_create_online_log_dest_n initialization parameter, 376

db_domain initialization parameter, 372

db_file_multiblock_read_count initialization parameter, 387, 840

db _file_name_convert initialization parameter, 699

db _files initialization parameter, 37 4 db_keep_cache_sizeinitialization

parameter, 378 DBMS_APPUCATION_INFO package,

1033-1035 DBMS_FGApackage, 510,1065

DBMS_FLASHBACK package, 340, 341, 343-344,712,713,714,1070

DBMS_]OB package, 926, 927-928, 1031-1033

DBMS_LOGMNR package, 706, 708, 709,1071-1072

DBMS_LOGSTDBY package, 1062 DBMS_METADATA package, 275-277,

1069 DBMS_MVIEWpackage, 1068-1069.

See also materialized views DBMS_ OBFUSCATION_ TOOLKIT

package,518 DBMS_OIAP package, 298, 301, 306,

1066--1068 DBMS_OUTLN package, 857,

1045-1047 DBMS_OUTLN_EDIT package, 857,

858-859,1045-1047 DBMS_ OUTPUT package, 1040-1041 DBMS_PROFILER package, 1050-1052 DBMS_REDEFINITION package,

746-747,748,749,768,1069-1070 DBMS_REFRESH package, 1072-1073 DBMS_REPAIR package, 668-669,

1042-1045 DBMS_RESOURCE_MANAGER, 482,

483,1065-1066 DBMS_RESUMABLE package, 352,

1066 DBMS_RLS package, 498-499,

1064-1065 DBMS_SESSION package, 873,

1035-1037 DBMS_SHARED_POOL package, 904,

1060-1062 DBMS_SPACE package, 1047-1049 DBMS_SPACE_ADMIN package, 724,

1049-1050 DBMS_STATS package

us. analyze command, 837-839 collecting statistics, 835-837 creating statistics table, 835 invoking, 835 overview, 829,834,835, 1063-1064 reasons to use, 960

types of statistics, 829-830 types of statistics provided, 829-830

DBMS_STORAGE_MAP package, 767, 1075-1076

DBMS_SYSTEM package, 945, 1037-1040

DBMS_TTS package, 601, 1073-1074 DBMS_UTIUTYpackage, 1074-1075 DBMS_WM package, 355, 356,

1070-1071. See also Workspace Manager feature

db_name, as predefined USERENV attribute, 495

db_name initialization parameter, 372 db_nk_cache_size initialization

parameter, 378-379, 754 db_recycle_cache_size initialization

parameter, 378 dbshutscript, 1086 DBSNMP account, 406, 511, 512, 521 dbstartscript, 1086 DBW. See database writer (DBW)

background process db_ writer _process initialization

parameter, 162, 376 DCOM (Distributed COM), 1078 dd command, 84, 655 DDL. See data definition language

(DDL) DDL locks, 325 DDL triggers, 503,505 deadlocks, 331 decision support systems (DSS), 12 declare statement, PLISQL, 201, 1128 DECODE SQLfunction, 1116 defaultauditing,506--507 default buffer pool, 170, 908, 909 default device type parameter, RMAN,

634 deferrable constraints, 290-291 dejinecommand,216,240-241 define SQL *Plus environment variable,

203 definer rights, 489-490 degree of parallelism, RMAN, 635,655 delete statement, PLISQL, 1129

Index

1157

Index

ll58

delete statement, SQL, 201, 220, 240, 324,325,559,1109-1110

deleting files, 69 deletion anomalies, 39 delimited by external table access

parameter, 559 delimiters in SQL *Loader control file,

542-543 denormalization, 44 describecommand,209-210,275 descriptors, connect, 429, 430, 435 destroy parameter, import utility, 596 I dev directory, 73 development databases, 11, 12 dfcommand, 93 diagnostics. See also Oracle Diagnostics

Pack initialization parameters, 384-388 UNIX systems vs. Wmdows systems,

1088 Diet view, 975-976 dictionary cache, 902-903 dictionary managed tablespaces

converting to locally managed tablespaces, 157, 724, 725, 1049-1050

vs. locally managed tablespaces, 153-154,157,243-244

difference set operation, 28 differential incremental backups,

645-646 direct parameter

export utility, 585 SQL *Loader control file, 544-545

direct path data loading method columnarrayrows parameter, 553 vs. convention loading method, 537 direct clause, 552 list of options, 552-553 managing constraints and triggers,

553 multithreading option, 553 overview, 536--537,550-551 rows parameter, 552 skip_index_maintenance parameter,

552

streamsize parameter, 553 unrecoverable parameter, 552

direct path read wait event, 948 direct path write wait event, 948 directories, OlD

overview, 447-448 setting up structure, 448-451

directories, Oracle naming conventions for Oracle9i

serverso~are, 112-115 structure for Oracle9i server

so~are, 112-113 directories, UNIX

as file type, 67 listing files, 68 managing, 72-73 most important, 73 overview, 72 tree structure, 72

Directory Information Tree (DIT), 447-448

Directory Migration WIZard, 458-460 directory naming method, net service

name, 440-441 directory services, 441, 517-518. See

also Oracle Internet Directory (OlD)

dirty read concurrency problem, 314, 319

disable no validate command, 289 disable validate command, 289 disaster recovery. See also database

recovery data center disasters, 675 new backup technologies, 104 Oracle high-availability systems for,

662-670 discard file, SQL *Loader control file,

545 discard file external table access

parameter, 559 discrete SQL transactions, 346 disk arrays. See RAID (redundant arrays

of independent disks) disk controllers, 94, 100 disk failure, 94, 676-677

disk I/O factors with impact on 110 rates, 919 measuring performance, 920-922 reducing contention, 922 system utilization problems, 956

disk mirroring, 96, 97, 98 disk striping, 94, 96, 97, 98 disk systems. See also RAID (redundant

arrays of independent disks); storage technologies

availability issues, 94 1/0 limitations, 166 1/0 operations per second, 96 monitoring usage, 93-94 Oracle requirements, 109 performance issues, 94 redundancy in, 94-95 role in Oracle database

performance, 139-140 secondary storage, 166 space as Oracle installation issue,

109, 115-116 storage configuration issues, 92-93 transfer rate, 96

dispatcher background process, 161 dispatchers initialization parameter,

373 DISPIAYvariable, 121, 122, 124 distinguished names (DNs), 447, 448 Distributed COM (DCOM), 1078 distributed databases, managing in

OEM, 797-799 distributed locks, 325 diversify utility, 668 DML. See data manipulation language

(DML) DML-based triggers, 502-503 D~Llocks,324-325

documents, for installing Oracle9i serversoftNvare,lOB-109

dollar sign ($), 59, 77 domain constraints, 48 domain_name initialization parameter,

428 domains, in relational database model,

defined, 27

dot(.), 213 do~time,rninimizing,6

drivers, for Java Database Connectivity, 461-462

drop catalog command, RMAN, 638 drop command, 250-251, 254 dropping table partitions, 273-274 du command, 93-94 dual table, 242 dump directories, 113, 151, 152 dump file, export utility, 589-590, 605 dumps, systemstate, 961 duplicate command, RMAN, 698,

700-702 duplicate data, removing, 575 durability, as ACID property, 313 dynamic initialization parameters, 149,

413-414 dynamic performance views (V$), 191,

193-194,1003-1027

E e-mail notification, OE~. configuring,

812,814 echo command, 61,78 echo SQL *Plus environment variable,

203 edit filename SQL *Plus environment

variable, 203 editors, UNIX

alternatives to vi, 75 vi, 74-75

emulators, terminal, 58, 59 enable validate command, 289 enabling auditing, 505-506 encapsulation, in object-oriented

database model, 51 encryption, 87, 518. See also passwords end statement, PL!SQL, 1128 enqueue wait event, 949 Enterprise ~anager Configuration

Assistant, OE~. 780-785. See also Oracle Enterprise ~anager (OE~)

enterprise user security, 517-518 Enterprise Volume ~anager, 104

Index

1159

Index

1160

entity-relationship diagrams (ERDs) creating, 35-37 overview, 32 transforming into relational tables,

46 entity-relationship modeling (ERM)

building ERDs, 35-37 candidate keys, 34-35 and normalization, 38-40 overview, 32-34 role of Oracle Designer, 44-45 types of relationships, 34 unique identifiers, 34

entries, OlD, 44 7 entryiD, as predefined USERENV

attribute, 495 env command, 64-65 environment, UNIX, 63-65 environment variables

setting at installation of Oracle9i serverso~are,120-121, 135

setting before creating Oracle databases,367-368

in shell programs, 76-79 for SQL *Plus, 203-206 UNIX overview, 63-65

equijoins, 841, 1119 ERDs. See entity-relationship diagrams

(ERDs) ERM. See entity-relationship modeling

(ERM) error codes

export utility, 589 import utility, 599 SQL *Loader, 576

errors handling in PLISQL, 1129-1130 human, 675-676 and Java Database Connectivity,

464-465 maximum extents-related, 732-733 ORA_00257 error, 671 ORA_00376 error, 718 ORA_Oll52 error, 717-718 ORA_01194 error, 716-717 ORA_30032 error, 350

out-of-space, 733-734 space-related, 732-734

errors parameter, SQL *Loader control file, 545

I etc directory, 73 /etc/profile file, 63, 64 ETL (Extraction, Transformation,

Loading) process overview, 534-535 role of external tables, 534 role of multitable inserts, 535,

566-567 role of table functions, 535, 568-573 role of transportable tables paces,

535 role of upserts, 535

event system, OEM, 775, 776, 810-812 Event Viewer, Wmdows, 1088 events. See also wait events

creating, 810 OEM overview, 775, 776, 810 scheduling, 812 selecting test criteria, 811 specifying test conditions, 810-811

example.ksh shell program, 77-79 exception statement, PLISQL, 1128 exchanging table partitions, 273 exclusive (X) lock mode, 189, 326,

328-329 executable programs, creating, 77-78 execute command, 201, 211 EXISTS clause, 841 exists operator, 1124 exit codes, 550, 599 exit command, 208 exiting SQL *Plus, 208 exp directory, 113 Expert feature, 817 Explain Plan tool

creating plans, 862 interpreting plan output, 863-865 overview, 861 plan examples, 863-865 prerequisites for using, 861 producing plans, 862 reading plans, 863

explicit locking, 328-329

exportcon1n1and,65 export utility

avoiding errors, 605 coDlDland-line use, 588-590 compress paran1eter, 584 consistentparan1eter, 586 constraints paran1eter, 585 database level option, 582-583 and database n1igrations, 606-607 directparan1eter, 585 dun1p file, 589-590, 605 error codes, 589 feedback paran1eter, 585 file paran1eter, 583 file paran1eters, 583, 607 files paran1eter, 583 flashback-related paran1eters,

586-587 jlashback_scn paran1eter, 586 flashback_ time paran1eter, 586 grants paran1eter, 585 indexes paran1eter, 585 interactive n1ode, 587-588 invoking,587-590 and large databases, 607 level options, 581-583 lin1itations, 606 logparan1eter, 583 options for export, 583-586 overview, 579-580 paran1eters, 581-587 parfile paran1eter, 583 query paran1eter, 584 reasonable paran1eter, 586 recordlength paran1eter, 585 recoverable errors, 604, 605 restoring databases, 607 resumable_name paran1eter, 586 resumable_timeoutparan1eter, 586 rows paran1eter, 584 schema level option, 582 specifying n1ultiple files, 607 starting, 587-590 statistics paran1eter, 585, 605 table level option, 581-582 tablespace level option, 582 triggers paran1eter, 585

in UNIX shell scripts, 608 userid paran1eter, 581 validating exports, 608 ways to optilllize, 609-610 ways to use, 579-580

export views, 605 ExportVVizard,800-801 extents

autoallocate option, 156-157, 245, 247,725

defined, 140 initial, 143 liDlit-related errors, 732-733 local vs. dictionary database

Dlanagelllent,247, 724,725 overview, 143-144 space allocation, 156-157, 244, 245,

24 7, 724-725 uniform size option, 156, 157, 245,

247 external authentication, 516 external nanling n1ethod, net service

nall1e,439-440 External Table feature

access paran1eters, 558-559 advantages, 555 bad file external table access

paran1eter, 559 condition external table access

paran1eter, 559 delimited by external table access

paran1eter, 559 discard file external table access

paran1eter, 559 fixed length external table access

paran1eter, 558 how to use, 556-558 load when external table access

paran1eter, 559 log file external table access

paran1eter, 559 overview, 533, 537, 555 recordJormat_info external table

access paran1eter, 558 vs. SQL *Loader, 555-556 using for data loading, 556-558

Index

1161

Index

1162

variable length external table access parameter, 559

external tables creating, 55~558 overview, 265-267 role in ETL process, 534 using to load data, 555-562

external_name, as predefined USERENV attribute, 495

extraction. See ETL (Extraction, Transformation, Loading) process

F failures. See database failures fast commit mechanism, 190 fast-start fault recovery, 674-675 fast_start_io_targetinitialization

parameter, 67 4, 735 fast_start_mttr_target (FSMT)

initialization parameter, 164, 389, 675,735

FAT file system, 1087 FCLOSE function, 1055 feedback parameter

export utility, 585 import utility, 594

feedback SQL *Plus environment variable, 204

fetching, 893 FGA. See DBMS_FGA package field-mapping clauses, SQL *Loader

control file, 541-543 fields, large, loading into tables, 574 fifth normal form (5NF), 44 file mapping, 76~768, 1075 file parameter

export utility, 583 import utility, 591

file permissions, UN1X determining, 69-70 modifying, 70-71 setting, 70-71 setting defaults prior to Oracle9i

server software installation, 119-120

types, 69

file-related dynamic dictionary views, 102~1027

file-related parameters export utility, 583 import utility, 591

file systems allocating file space, 365-366 choosing file location, 365-366 impact on disk 110 rates, 919 obtaining system authorization for,

366 planning,365-366 sizing, 365 UN1X vs. Windows, 1087

File Transfer Protocol (FTP), 87-88 file_mapping initialization parameter,

766,1075 files, Oracle

choosinglocation,365-366 initialization parameters, 374-375 renaming, 252 specifying where to create, 159

files, raw, 92, 95 files, UN1X

backing up, 84-85 character special, 67 copying, 68 creating with vi editor, 74-75 deleting, 69 directories as file type, 67 editing with vi editor, 74-75 linking,67 listing, 68 making executable, 77-78 managing, 68-69 moving,68 ordinary, 67 vs. raw files, 92, 95 reading from, 69-71, 1053-1057 remote copying, 87 renaming, 68 restoring,84-85 special, 67 types, 67 UN1X overview, 67 viewing contents, 68 writing to, 69-71, 1053-1057

files parameter export utility, 583 import utility, 591

filtering data, 1111 fine-grained access control, 497-500,

1064 fine-grained auditing, 509-511, 1065 finish_table_redefprocedure, 750-751 firewalls, 522 first/last aggregate SQL functions, 1117 first normal form (lNF), 40-41 first-order predicate calculus, 29 first_rows hint, 842 first_rows optimizer mode, 830 first_rows_n optimizer mode, 831 fixed length external table access

parameter, 558 Flashback Query feature

granting privilege, 344, 712 implementing queries, 342-346 overview, 340-341 and undo tablespace, 158 using as of clause, 344-346 using DBMS_FIASHBACK package,

340,341,343-344 using for data recovery, 711-714 using to correct data errors, 676

flashback-related parameters, export utility, 586-587

flashback_ sen parameter, export utility, 586

flashback_ time parameter, export utility, 586

FMON process, 766, 767 FMPUTL process, 766 FOPEN function, 1055 for-do-done loops, 80 for loop, 1132 foreign keys, 35, 46, 4 7 fourth normal form (4NF), 43-44 fragmented tablespaces, overcoming,

724-725 free buffer waits, 948-949 FREELlST GROUPS parameter, 725,

726,946 FREELlST parameter, 155-156, 245,

725,726,946

FSMT. See fast_start_mttr_target (FSMT) initialization parameter

FTP (File Transfer Protocol), 87-88 Fujitsu, 104 full backups, 627-628 full hint, 842 full level option, import utility, 593 full table scans, 832, 840-841, 853 function-basedindexes,282,848 functional dependence, defined, 40 functions, PL/SQL, 1135

G gather _database_statistics procedure,

835 gather _index_stats procedure, 835 gather _schema_ statistics procedure,

835 gather _system_stats procedure, 836 gather _table_stats procedure, 835 GE (greater-than-or-equal-to)

operator, 1112 getcommand,217 glanceplus utility, 91-92 globally partitioned indexes, 283, 849 glogin.sql script, 205-206 gpm command, 91 grant any object privilege system

privilege, 489 grantcommand,201 grants parameter

export utility, 585 import utility, 592

granularity page-level, 323-324 row-level, 323-324, 325

granules, 168 greater-than-or-equal-to operator

(GE), 1112 grep command, 61, 83 group by clause

with cube operator, 1122 example,1120-1121 with grouping sets operator, 1122 overview, 1120 with rollup operator, 1121

Index

1163

Index

1164

group SQL functions, 112G-1123 groups

redo log, 76G-763 UNIX systems vs. Windows systems,

1086 GUI interfaces

H

andFTP, 88 Oracle Enterprise Manager, 777,

785-787 performance monitoring tools, 91 SQL performance tuning tools,

879-884 for Statspack tool, 933 TOAD software, 1052 UNIX systems vs. Windows systems,

1087

hanganalyze utility, 961 hanging databases, 954, 96G-962 HARD (Hardware Assisted Resilient

Data) Initiative, 103, 670 hard links, 67 hard parsing, 311-312,894,900 Hardware Assisted Resilient Data

(HARD)Initiative,l03,670 hash clusters, 277 hashjoins,833,843 hash partitioning, 269-270 having clause, 842, 1123 head command, 75 heading SQL *Plus environment

variable, 204 heap-organized tables, 257, 847 help index command, 202-203 heuristics, in query processing

strategies, 827-828 Hewlett-Packard UNIX systems, 56, 91,

118, 119, 134 Hewlett-Packard's Business Copy, 104 hierarchical data retrieval, 1117-1118 histograms, 860, 1117 HISTSIZE variable, 65 hit ratios, 937 home directories, 73, 112-113 $HOME/profile file, 64

HOMEID Registry subkey, 1089-1090 host, as predefined USERENV

attribute, 495 hostcommand,201,210 host naming method, net service

name,439 hotbackups,614,659-661 Hotsos Web site, 18 HP UNIX systems, 56, 91, 118, 119, 134 HR sample schema, 1106 HTTP servers, 1093 HTTPWeb server, 228-229 human error, 675-676 Hummingbird emulator, 58

I II 0 operations per second, 96 IBM UNIX servers, 56 identifiers, connect, 429-430 idle events, 952 if-then-else structure, 81, 1130 if-then-elseif structure, 1130 if-then structure, 1130 ignore parameter, import utility, 597 image copies, defined, 626 immediate constraints, 29G-291 Immigration and Naturalization

Service (INS), 962 import utility

avoiding errors, 605 bufferparameter, 594 command-line mode, 598 constraints parameter, 592 and database migrations, 606-607 destroy parameter, 596 error codes, 599 feedback parameter, 594 file parameter, 591 file-related parameters, 591 files parameter, 591 filesize parameter, 607 fulllevel option, 593 grants parameter, 592 ignore parameter, 597 indexes parameter, 592 indexfile parameter, 595-596, 608

interactive mode, 598 invoking,598-599 and large databases, 607 level options, 593 limitations, 606 log parameter, 591 optimizer statistics, 597, 605 optionsforimportin~593-597

order of importing, 590 overview, 579-580, 590 parameters,590-598 parfile parameter, 591 recoverable errors, 604, 605 restoring databases, 607 resumable parameter, 597 resumable parameters, 597-598 resumable_name parameter, 598 resumable_timeoutparameter, 598 rows parameter, 592 schema level option, 593 show parameter, 594-595 specifying multiple files, 607 specifying objects to be imported,

591-593 starting, 598-599 table level option, 593 and transportable tablespaces,

599-604 typical session, 598-599 in UNIX shell scripts, 608 useridparameter, 591 ways to optimize, 609-610 ways to use, 579-580

Import Wizard, 800-801 In clause, 841 in comparison operator, 1112 incomplete recoveries

overview, 690 resetting redo log files, 691-692 using RMAN, 690-691 using user-managed techniques,

692-692 inconsistent backups

vs. consistent backups, 613-614, 619 defined, 613

incremental backups cumulative, 646 differential, 645-646 overview, 627-628 performing, 645-646

index hint, 842 index-only plans, 847 index-organized tables (lOTs)

compressing,854-855 creating, 264-265 vs. heap-organized tables, 847 vs. normal tables, 264 overview, 263-265,847 updating, 264

indexrebuilds, 745, 769 index-related dictionary views,

995-999 Index1\mingWtzard, 817, 849-850 indexes

allocating file space, 365 analyzing, 837-839 B-tree, 280, 847 bitmap, 281-282,847 bitmap join (BJis), 843-844 CBO scans, 832-833,840,841 comparing queries with and

without, 867-870 composite, 278 compressing, 854-855 concatenated, 848 creating,279-280,281 dropping and rebuilding, 576 ftxnction-based,282,848 globally partitioned, 283 guidelines,279-280 locally partitioned, 283-284 maintenance operations, 285 maximum extents-related errors,

732-733 monitoring usage, 284, 850-851 optimizer path evaluation, 832-833 out-of-space errors, 733-734 overview, 277-278, 845 partitioned,282-284,849 prefixed vs. nonprefixed, 849 primary, 278

Index

1165

Index

1166

rebuilding, 745, 769, 860 removing, 851 reverse-key, 282,848-849 schemes, 280 secondary, 278 types,278,847-849 unnecessary, 851 what to index, 846-84 7 when to use, 845-846

indexes parameter export utility, 585 import utility, 592

index_ffs hint, 842 indexfile parameter, import utility,

595-596,608 INDEX_STATS view, 998-999 InfiniBand, 103 inheritance, in object-oriented

database model, 51 initialization files. See also init.ora

initialization file; SPFILE server file changing parameter values, 369-370 creating, 368-370 creating init.ora file, 395-396 dynamic parameters, 149 nnodrncying,l36,149 and pfile parameter, 1095

initialization parameters in alert log file, 151 archive log-related, 381-382 as_authent_prefix parameter, 516,

520 audit-related, 371-373 audit_..file_destparameter, 371 audit_sys_operations parameter, 372 audit_trail parameter, 371 background_dump_destparameter,

375 bitmap_merge_area_size parameter,

855 for buffer pool types, 170 changing values, 369-370 checking, 150-151 compatible parameter, 373 for configuring PGA, 178, 758 control_..file_record_keep_time

parameter, 389

control_..files parameter, 37 4 core_dump_destparameter, 374 create_stored_outlines parameter,

857,1046 creating, 368-370 cursor_sharingparameter, 385,

899-900,972 cursor _space _for _time parameter,

385,900-901 data block verification-related, 390 database_name parameter, 428 db_block size parameter, 171, 386 db_block_checkingparameter, 390 db_block_checksum parameter, 390,

667 db_cachesizeparameter, 171,182,

378,910 db_cache_adviceparameter, 381 db_create_..file_dest parameter, 159,

253,375,737-738,741 db_create_online_log_dest

parameter, 738,740,741 db_create_online_log_dest_n

parameter, 376 db_domain parameter, 372 db_..file_multiblock_read_count

parameter, 387, 840 db_..file_name_convertparameter,

699 db_..filesparameter, 374 db_keep_cache_size parameter, 378 db_nameparameter, 372 db_nk_cache_size parameter,

378-379,754 db_recycle_cache_size parameter,

378 db_writer_processparameter, 162,

376 diagnostics-related, 384-388 dispatchers parameter, 373 domain_ name parameter, 428 dynamic,149,413-414 fast_start_io_targe parameter, 67 4,

735 fast_start_mttr _target (FSMT)

paramete~ 164,389,675,735 file-related, 374-375

file_mappingparameter, 766, 1075 hidden,151 instance_nameparameter, 373,428 java_pool_size parameter, 380-381 large_pool parameter, 380 licensing-related, 383-384 lock_sga parameter, 381 log_archive_dest_n parameter, 382 log_archive_formatparameter, 382 log_archive_maximum_processes

parameter, 165-166 log_archive_min_succeed_dest

parameter, 764 log_archive_start parameter, 382 log_buffer parameter, 380 log_checkpoint_interval parameter,

389,674 log_checkpoint_timeout_interval

parameter, 735 log_file_name_convertparameter,

699 max_dump_file_size parameter, 872 memory configuration-related,

377-381 name-related, 372-373 nls_date_formatparameter, 373 OMF-related, 375-376, 737-738 open_ cursors parameter, 377 optimizer _features_ enabled

parameter, 856 optimizer _mode parameter, 384 for Oracle9i, 370-391 oracle_ trace_ enable parameter, 387 os_authent_prefix parameter, 390 parallel_automatic_tuning

parameter, 387 parallel_ max_ servers parameter, 388 performance-related, 384-388 pga_aggregate_target parameter,

176,177,178,379-380,758,911, 912

process-related, 376-377 query _rewrite_ enabled parameter,

384,856 query _rewrite_ integrity parameter,

385

recovery-related, 388-389, 674-675 remote_login_passwordfile

parameter, 390-391, 514 remote_os_authentparameter, 520 resource_limitparameter, 388 rollback-related, 383 security-related, 390-391 service_ name parameter, 373,

428-429 session-related, 376-377 session_ cached_ cursors parameter,

901 sga_maximum_sizeparameter, 381 sga_max_size parameter, 168, 169 shared_pool_reserved_size

parameter, 379 shared_pool_size parameter, 379 specifying, 149-150 sql_traceparameter, 387 star_transformation_enabled

parameter, 385, 856 statistics_ level parameter, 871 store_area_size parameter, 855 timed_statistics parameter, 388, 871 transaction_auditingparameter, 372 undo space-related, 382-383 undocumented, 391 undo_managementparameter, 334,

336,383 undo_retention parameter, 341, 383,

726,727 undo_tablespace parameter, 382 user_dump_destparameter, 374,873 user _dump_file_size parameter, 872 use_ stored_ outlines parameter, 858,

1046 utl_file_directory parameter, 375,

521,1054 viewing current values, 391-393 workarea_size_policy parameter,

388,758 init.ora initialization file. See also

initialization parameters automatic archiving option, 165 creating,368-369,395-396 overview, 149 reading, 392

Index

1167

Index

1168

setting up file location parameters for OMF-based database, 739

vs. SPFILE server file, 409 INITRANS parameter, 946 inline functions, 851-852 inline views, 239, 1123 inner joins, 1120 input, UNIX, 65-66 INS. See Immigration and

Naturalization Service (INS) insert first command, 566-567 insert statement, PL/SQL, 1129 insert statement, SQL, 199,201,

219-220,240,324,325,550,559, 1109

insertion anomalies, 39 installing

Oracle Database Server, 8-9 Oracle Enterprise Manager, 772 Oracle Internet Directory, 443-444 Oracle9i on UNIX systems, 107-110,

123-130,364 Oracle9i on Windows systems,

1088-1089 instance optimizer level, 831 instance_name initialization

parameter, 373, 428 instances

collecting performance statistics with Statspack, 922-933

vs. databases, 139 deleting by using oradim utility, 196 managing in OEM, 793, 794-795 measuring performance, 936-952 modifying by using oradirn utility,

196 naming,428 in object-oriented database model,

50 Oracle processes in, 159 performance tuning, 887-889,

963-972 as predefined USERENV attribute,

495 starting, 396-399 starting by using OMF feature, 7 40

starting by using Oracle Administration Assistant for Wmdows NT, 1099

starting by using oradim utility, 1095 stopping by using Oracle

Administration Assistant for Windows NT, 1099

stopping by using oradim utility, 1096

UNIX systems vs. Wmdows systems, 1080-1083

Instant Image, 104 INSTR SQL function, 841, 1114 integrity constraints

check,287,553 deferrable, 290-291 and direct path data loading

method, 553 disabling, 289-290 immediate,290-291 NOT NULL, 287,553 overview, 285-286 primary key, 286, 553 referential, 288 rely, 290 states, 288 unique,287-288,553

Intelligent Agent, OEM autodiscovery feature, 779 configuring, 778-779 DBSNMP account, 406, 511, 512,

521 and Management Server, 776, 777 vs. Oracle Agent for Wmdows

systems, 1093, 1094 overview, 778 starting, 779

interactive mode export utility, 587-588 import utility, 598

interfaces. See GUI interfaces; SQL*Plus

interim tables, creating, 747-750 internal locks, 325 internal tables, 192 internal_quiesce resource plan

directive, 768

International Oracle Users Group (IOUG), 16-17

Internet sites, 17-18 intersection set operation, 28, 1113 inverse percentile SQL functions, 1117 invoker rights, 489-490 iostat utility, 89 lOTs. See index-organized tables (lOTs) ip_address, as predefined USERENV

attribute, 495 ISO transaction standard

and isolation levels, 318-322 overview, 315-316

isolation, as ACID property, 313 isolation levels

changing default, 319-320 overview, 318 read committed level, 318, 319,

320-321 read-only level, 319, 320 read uncommitted level, 318, 319 repeatable read level, 318, 319 serializable level, 318, 320-321

iSQL*Plus authentication levels, 233-234 client tier, 228 corrliguring,228-230 database tier, 230 executing scripts from URL,231-232 executing SQL commands, 235 inapplicable SQL *Plus commands,

235-236 installing, 228-230 invoking from URL, 231-232 logging in, 231, 233-234 middle tier, 228-229 overview, 227 security issues, 234, 236 using, 230-233 work screen, 232-233

lxora Web site, 18

J Java, and Oracle9i database, 1141-1143 Java Database Connectivity (JDBC)

drivers for, 461-462 error handling, 464-465

establishing connectivity,461-462 executing SQL statements, 463-464 handling DDL and DML statements,

464 handling queries, 463 overview, 461 processing SQL statements through

connection,462-465 role of statement objects, 463 sample program, 465-466 and SQL, 1141-1142

Java pool, 168, 175 java_pool_size initialization parameter,

380-381 JDBC. See Java Database Connectivity

(JDBC) Jlnitiator plug-in, 792 job system, OEM, 775, 776, 806-810 Jobs feature, OEM

choosing script, 808-809 choosing tasks, 808 creating, 807-809 naming,807,808 overview, 775, 776, 806, 807 scheduling,85,809 submitting, 809

joins as binary operations, 828 and bitmap join indexes, 843-844 Cartesian, 28, 826, 843, 1118 choosing CBO method for, 833 choosing CBO order for, 833 equi-, 841, 1119 hash,833,843 inner, 1120 merge method, 843 multitable, 841 natural, 1119 nested-loop, 833, 843 outer, 1120 reduced relations, 827 selecting method, 843 selecting order, 845 self, 1119 sort-merge, 833 two tables, 827 types, 1119-1120

Index

1169

Index

1170

Journal File System (JFS), 1087 Just a Bunch of Disks (JOBs), 95

K keep buffer pool, 170,908,909,910 kernel, UNIX

defined, 57 reconfiguring for Oracle9i server

software installation, 117-118 kill command, 83-84 killing user sessions, 527-529,

1081-1083 Kornshell

L

analyzing shell scripts, 77-79 command prompt, 59, 77 control flow structures, 79-82 indicating in shell programs, 78 overview, 57-58

label-based access control, 500--501 large databases

exporting and importing, 607 loading large fields into tables, 57 4 moving large amounts of data,

599-604 large jobs

moving large amounts of data, 599-604

role of Database Resource Manager, 751-753

large pool dynarnicreconfiguration,755-757 large_pool parameter, 380 overview, 175 performance tuning, 911

latch-free wait event, 949-951 latches, 325, 949 LDAP directory services, 517-518. See

also Oracle Internet Directory (OlD)

LDAP (Lightweight Directory Access Protocol), 441-442

ldapadd command, 455-456 LD_LIBRARY_PATH variable, 135, 368

LE Oess-than-or-equal-to) operator, 1112

least recently used (LRU) algorithm, 162,169,175

Legato NetWorker, 647-648 Legato Single Server Version (LSSV)

architecture, 649-650 doing tape backups, 652-655 installing, 650--651 and RMAN, 648, 649, 652-655 using with RMAN, 648-649 ways to use, 651-652

LENGTH SQL function, 1113 less-than-or-equal-to operator (LE),

1112 LGWR. See log writer (LGWR)

background process library cache. See also shared pool

measuring efficiency, 896-898 optimizing, 898-902 overview, 173, 892-893 and parsing, 893, 894-896 pinning objects in, 904-906

library cache latch, 950 license_max_sessions initialization

parameter, 384 license_max_users initialization

parameter, 384 Lightweight Directory Access Protocol

(LDAP), 441-442. See also Oracle Internet Directory (OlD)

like comparison operator, 1108, 1112 linesize SQL*Plus environment

variable, 204 link command, 67 links, hard us. symbolic, 67 Linux

managing Oracle on, 1103 and Oracle9i database, 1101-1103 overview, 56-57 stable us. beta releases, 1102-1103 us. Unix, 1101-1102 as X Window-using operating

systems, 1101 list backup command, RMAN, 629-630 list backupsets command, RMAN, 682 list copy command, RMAN, 630

list partitioning, 270-271 listener. See Oracle Net listener listing files, 68 load parameter, SQL *Loader control

file, 545 load when external table access

parameter, 559 loading. See data loading; ETL

(Extraction, Transformation, Loading) process

loading-related clauses, SQL*Loader control file, 539

local commands, 198 local naming method, net service

name,436-438 local partitioned indexes, 849 locally managed tablespaces

converting dictionary managed tablespacesto, 157,724,725, 1049-1050

creating,244-256, 724 vs. dictionary managed tablespaces,

154,155,156,157,243-244 overview, 724 removing,250-251 storage features, 244-246 and temporary tablespaces, 154

locally partitioned indexes, 283-284 location transparency, 291,426 Lock Manager, 331-332 locked accounts, 512 locking mechanisms

blocking of locks, 330-331 DDL locks, 325 deadlocks, 331 distributed locks, 325 DMLlocks,324-325 exclusive mode, 189, 325-326 exclusive (X) table lock mode, 326,

328-329 internal locks, 325 latches, 325 managing of locks, 330-332 methods overview, 323-324 modes overview, 325-326 optimistic methods, 322, 323 overview, 189, 322-323

performance issues, 957-958 pessimistic methods, 322, 323 row exclusive (RX) table lock mode,

326,327 row-level (TX) vs. table (TM) locks,

326 row share (RS) table lock mode, 326,

327 share lock mode, 189, 325, 326 share row exclusive (SRX) table lock

mode,326,327-328 share (S) table lock mode, 326, 327 types oflocks, 324-325

locking user accounts, 512-513 lock_sga initialization parameter, 381 log buffer space wait event, 951 logfileextemal table access parameter,

559 log file space wait event, 951 log file sync wait event, 952 log files, SQL *Loader, 549-550, 559,

560. See also alert log file; redo log files

log groups, 707 log parameter

export utility, 583 import utility, 591 SQL *Loader control file, 545

log writer (LGWR) background process, 161,162,174,191

log_archive_dest_n initialization parameter, 382

log_archiveJormat initialization parameter, 382

log_archive_maximum_processes initialization parameter, 165-166

log_archive_min_succeed_dest initialization parameter, 764

log_archive_start initialization parameter, 382

log_buffer initialization parameter, 380 log_ checkpoint_ interval initialization

parameter, 389,674 log_checkpoint_timeout_interval

initialization parameter, 735 LOGFILE variable, 78

Index

1171

Index

1172

log_file_name_convert initialization parameter, 699

logging into UNIX, 58-59 logging out of UNIX, 59 logical databases

design overview, 31-32 entity-relationship modeling, 32-37 vs. physical structures, 140 structural overview, 140

logical operators, 1112 logical records, SQL *Loader control

file, 540 logical standby databases, 665, 1062 logical time stamps, 190 Logical Volume Manager (LVM), 94, 95,

766 logical volumes, 95 .login file

specifying default environment preferences, 206

as user profile for SQL *Plus, 206 LogMiner utility

analyzing redo log files, 710-711 data dictionary use, 706, 708-711 DBMS_LOGMNR package, 706, 708,

709, 1071-1072 how it works, 706-707 overview, 705-706 and supplemental logging, 707 typical session, 708-710 V$LOGMNR_CONTENTS view, 706,

710-711 logoff triggers, 503, 504 logon triggers, 503, 504 long SQL transactions, managing,

352-360,752,964-965 long SQL *Plus environment variable,

204 looping

cursor for loops, 1134 for-do-done loops, 80 overview, 79 PL/SQL constructs, 1130-1132 until-do-done loops, 80-81 while-do-done loops, 79-80

lost update concurrency problem, 315, 319

LOWER SQL function, 1113 LPAD SQL function, 1114 LRU Oeast recently used) algorithm,

162,169,175 ls command, 68, 69 lsnrctl utility

checking listener status, 432-433 listing monitored services, 433 starting listener, 433 stopping listener, 433

LSSV. See Legato Single Server Version (LSSV)

M maintaining indexes, 285 maintaining partitioned tables,

272-274 maintenance window, 422 man pages, 60 management packs, OEM, 814-817 Management Server, OEM

configuring, 780-785 monitoring, 784-785 overview, 776, 777, 1094 repository creation, 780-784

many-to-many relationships, 34, 37 mapping libraries, 766, 767 materialized views

creating,303,304-305 and DBMS_MVIEW package,

1068-1069 and DBMS_OLAP package, 298, 301,

306,1066-1068 and DBMS_REFRESH package,

1072-1073 estimating size, 306 overview, 297-298 privileges, 303 query results, 305-306 role of Summary Advisor, 301-302 when to use, 855

max_dump_file_size initialization parameter, 872

max_ estimated_ exec_ time resource plan directive, 753

maxextents storage clause, 733

Mean Time Between Failure (MBTF) ratings, 94, 101

Mean Time to Recover (MTTR), 735-736

media failures block media recovery, 714-715 overview, 676-677 typical recovery scenarios, 683-698

Media Management Layer (MML), 620, 622,647-648. See also Legato NetWorker; Legato Single Server Version

memory adjusting on the fly, 181-183 allocating,185-187,367 configuration parameters, 377-381 determining session use, 525 dynamic reconfiguration, 755-758 modifying SGA dynamically,

181-183 monitoring usage, 178-181 as Oracle installation issue, 109-110 Oracle overview, 166 Oracle requirements, 109-110 Oracle structures, 166-178 performance issues, 969 performance overview, 890-891 performance tuning, 890-912 PGA overview, 175-178 processes in, 958-959 role of Oracle Enterprise Manager,

185-187 SGAoverview, 166-175 SQL buffer, 217 tuning resources in Wmdows

systems, 1085-1086 UNIX systems vs. Windows systems,

1085-1086 merge command, 535, 564-565 merge joins, 843 merging table partitions, 273 metadata. See also data dictionary

DBMS_METADATA package, 1069 exporting for tablespaces, 602-603

methods, in object-oriented database model, 50

Microsoft Certificate Store, 1080 Microsoft Management Console

(MMC), Wmdows, 1088 Microsoft .NET, 1078 Microsoft Transaction Server (MTS),

1079 Microsoft Windows. See Windows

systems migrations, database, 606-607 Milsap, Carey, 18, 110 minus set operator, 1113 mirroring, disk, 96, 97, 98, 761 mission-critical databases, backing up,

647-648 mkdir command, 72 MLOCK privilege, 118 MMC (Microsoft Management

Console), Wmdows, 1088 modeling, role in logical database

design, 32-37 monitoring index usage, 284 more command, 68 mount points, 111,112, 116-117 mounting databases, 401, 415-416 moving

files in UNIX, 68 large amounts of data, 599-604

moving-window aggregate SQL functions, 1117

MTS (Microsoft Transaction Server), 1079

MTTR. See Mean Time to Recover (MTTR)

Multi-Threaded Server (MTS), 1084 multiple-column subqueries, 1124 multiple-row subqueries, 1124 multiple tables, retrieving data from,

1118-1120 multiplexing redo log files, 760, 761 multitable inserts, role in BTL process,

535,566-567 multitable joins, 841 multithreading option, direct path data

loading method, 553 mv command, 68

Index

1173

Index

1174

N name initialization parameters,

372-373 names

database instance names, 428 database service names, 428-429 net service names, 435-441

NAS. See network attached storage (NAS)

natural joins, 1119 NCA. See Net Configuration Assistant

(NCA) nested-loop joins, 833, 843 nested subqueries, 239, 1123 nested tables, 1126 nesting group functions, 1121 Net Configuration Assistant (NCA)

configuring clients for OlD naming, 460-461

creating new services, 438 creating Oracle Context, 451-454 starting, 438

.NET platform, 1078 net service names

adding to OlD, 454-460 and connectivity, 435-441 directory naming method, 440-441 external naming method, 439-440 host naming method, 439 local naming method, 436-438 naming methods, 435, 436-441 Oracle Names method, 440

netstat utility, 92 network attached storage (NAS),

102-103 network connections. See Oracle Net

Services Network Information Services (NIS),

439-440 NetWorker, 647-648 networks. See also Oracle Net

and performance problems, 965-966

securing,522 new projects, estimating system

requirements, 7

new users, creating, 471-472 newpage SQL *Plus environment

variable, 204 NFS file systems, 112 NLS_DATABASE_PARAMETERS view,

977 nls_date_Jormat initialization

parameter, 373 noarchivelog mode

vs. archivelog mode, 406-408, 612-613,619

overview, 612-613 noaudit command, 509 nohupcommand,83 nonrepeatable read concurrency

problem, 315 normal forms

Boyce-Codd (BCNF), 43 fifth (5NF), 44 first (lNF), 40-41 fourth (4NF), 43-44 overview, 40 second (2NF), 41-42 third (3NF), 42-43

normalization Boyce-Codd normal form (BCNF),

43 and data anomalies, 39-40 fifth normal form (5NF), 44 first normal form (1NF), 40-41 fourth normal form (4NF), 43-44 normal forms, 40-44 reasons to use, 38 second normal form (2NF), 41-42 third normal form (3NF), 42-43

not exists operator, 1124-1125 NOT NULL constraints, 287, 553 NOT operator, 1112 notification system, OEM, 775, 776 NT Backup utility, 1087 NTFS file system, 1087 number SQLfunctions, 1114-1115 numwidth SQL *Plus environment

variable, 204 NVL SQL function, 1115

0 Object Data Management Group

(0DMG),51 Object Definition Language (ODL), 51 object-level audits, 508 object linking and embedding (OLE),

1078 object model, 5Q-51 object-oriented programming (OOP),

1125-1127 object privileges, 486, 487-488 object-relational database

management systems (ORDMS), 26,49-52

object-relational model, 51-52 object tables, 1125-1127 object transparency, 291 objects, 33, 50 OCOPY command, Wmdows, 1087 octal numbers method, 70, 71 ODBC (Open Database Connectivity),

1078 ODCA. See Oracle Database

Configuration Assistant (ODCA) ODP .NET (Oracle Data Provider for

.NET), 1078 OE sample schema, 1107 OEM. See Oracle Enterprise Manager

(OEM) OEM Diagnostics Pack

Capacity Planner, 935, 936 overview, 934 Performance Manager, 814, 934,

935,967,968,970,971 OEM 1\ming Pack, 817, 88Q-884 oemctl utility, OEM, 790-791 OFA (Optimal Flexible Architecture),

11Q-115 offline, tablespaces, 252 OlD. See Oracle Internet Directory

(OlD) oidctl utility, 444-445 OIAP databases, 11, 797, 798, 854 OLE DB providers, 1078 OLE (object linking and embedding),

1078 OITP (online transaction processing), 11

OME See Oracle Managed Files (OMF) one-to-many relationships, 34, 37 one-to-one relationships, 34, 37 one_script.sql example, 218 online analytical processing (OIAP),

11,797,798,854 online analyze validate feature, 7 44 online backups

vs. cold backups, 614 defined, 614 managing,661-662 overview, 658-659 performing, 646-647,659-661

online index rebuilds, 7 45, 769 online table redefinition feature

example, 746-751 failed attempts, 768 overview, 7 45 troubleshooting, 768 what it does, 745-746

online transaction processing (OLTP), 11

0040 (Oracle Objects for OLE), 1078 open accounts, 512 open backups, 614,658 Open Database Connectivity (ODBC),

1078 open database recovery, 677, 679 open_ cursors initialization parameter,

377 opening databases, 416-417 operating systems. See also Linux;

UNIX; Windows systems authentication issues, 520 memory management, 954 performance tuning utilities, 912 security guidelines, 520 setting environment variables, 394

operational performance-related dictionary views, 1018-1021

operators comparison, 1112 logical, 1112 overview, 1112 redirection, 66 set, 1112

OPS$0RACLE account, 516

Index

1175

Index

1176

/opt/bin/ directory, 119 Optimal Flexible Architecture (OFA),

110-115 optimistic locking methods, 322, 323 optimizer, Oracle. See cost-based

optimizer (CBO) optimizer statistics, import utility, 597,

605 optimizer Jeatures_enabled

initialization parameter, 856 optimizer _mode initialization

parameter, 384 optimizing imports and exports,

609-610 optimizing queries

cost optimization example, 826-827 execution plan generation, 825 heuristic strategies, 827-828 overview, 824-825 query rewrite phase, 825

OR operator, 1112 ORA_00257 error, 671 ORA_00376 error, 718 ORA_01152 error, 717-718 ORA_01194 error, 716-717 ORA_30032 error, 350 ORAC. See Oracle Real Application

Clusters (ORAC) Oracle. See also Oracle Enterprise

Manager (OEM) automatic database management

features, 723-742 Automatic Segment Space

Management feature, 156, 725-726

CD-ROM for server software, 123 DBMS_REPAlR utility, 668-669 directory and file naming

conventions,112-115 directory structure, 112-113 diversify utility, 668 External Table feature, 533 file mapping feature, 766-768, 1075 home directory, 112-113 initialization parameters, 370-383 installation checklist, 122-123 installation documents, 108-109

installation overview, 107-110, 364 installation planning, 107-110 installing in silent mode, 131-134 installing on Windows systems,

1088-1089 instances vs. databases, 139 andJava,1141-1143 andLinux, 1101-1103 object-oriented programming

(OOP) features, 1125-1127 online capabilities, 7 42-760 as ORDBMS, 52 post-installation tasks, 134-136 pre-installation tasks, 115-122 Resumable Space Allocation feature,

730-734 role of DBA, 8-9 sample schemas, 1106-1107 step-by-step installation, 123-130 system requirements, 109-110 uninstalling, 136 uninstalling on Windows systems,

1100-1101 andWindows, 1077-1101 Windows vs. UNIX, 1080-1088

Oracle Administration Assistant for Windows NT, 1097-1099

Oracle administrative files, 111, 113, 115

Oracle Advanced Events feature, 816 Oracle Advanced Security feature, 518,

523 Oracle Agent service for Windows

systems, 1093 Oracle Backup Solutions Program

(BSP), 647 Oracle Base directory, 112 Oracle Change Management Pack, 817 Oracle Context

creating, 451-454 in directory trees, 447-448 overview, 451

Oracle Corporation Optimal Flexible Architecture

recommendations, 110-115 security alerts, 523 storage issues, 103-104

Oracle Data Guard data protection modes, 665-666 maximum availability mode,

665-666 maximum performance mode, 666 maximum protection mode, 665 overview, 663-664

Oracle Data Provider for .NET, 1078 Oracle Database Configuration

Assistant (ODCA), 637, 1096 Oracle Database Creation Agent

(DBCA), 334 OracleDBAs

background needed, 12-15 backup responsibilities, 3, 7 certification, 15 creating and managing users, 5 database design role, 8-10 design responsibilities, 4 general advice for, 21-22 implementation responsibilities, 4 job classifications, 10 organizations for, 16-18 overall role, 3-10 performance responsibilities, 3, 6,

18-19,853-860 resources for, 16-18 responsibilities, 3-4 security role, 3, 4-5 staying informed, 16-18 system management role, 6-8 training, 12-15 typical daily routine, 21

Oracle Diagnostics Pack, 814-816 Oracle Directory Manager, 431,

448-451. See also Oracle Internet Directory

Oracle Enterprise Login Assistant, 1079 Oracle Enterprise Manager (OEM). See

also Workspace Manager feature archdtecture, 776-778 benefits of using, 772,773-775 Buffer Cache Size Advisor, 757 components, 776-778 Configuration Assistant, 780-785 configuring, 778-791

configuring e-mail notification, 812, 814

configuring paging notification, 812-813

configuringreporting,788-791 configuring Web servers for

reporting services, 790-791 Console Navigator, 787 data management, 793-799 database wizards, 799-803 Discover Nodes option, 786-787,

792 eventsystem, 775,776,810-812 GUI-based console, 777,785-787 installing, 772 Instance Manager, 793, 794-795 IntelligentAgent, 776, 777, 778,

1093,1094 job system, 775, 776, 806-810 Lock Manager, 331-332 management packs, 814-817 Management Server component,

776,777 managing distributed databases,

797-799 managing memory allocations,

185-187 monitoring capabilities, 773-77 4 monitoringserverstatus, 785 MTTRAdvisor, 735-736 notification system, 775, 776 Oracle Change Management Pack,

817 Oracle Diagnostics Pack, 814-816,

934-936 Oracle 1\ming Pack, 817, 880-884 overview, 195,771-772 reporting system, 775, 776, 803-806 running console from Web

browsers, 791 running reports from Web browsers,

791 scalability, 774 Schema Manager, 794, 795 Security Manager, 796 security system, 775, 776 as set of systems, 775-776

Index

1177

Index

1178

setting up preferred credentials, 788-789

Storage Manager, 796-797 tracking CPU usage, 915 troubleshooting, 817-818 Undo Space Advisor, 728 Undo Tablespace Advisory, 338-339 user interface, 777, 785-787 using to reorganize database objects

online, 742-744 Warehouse Management feature,

797-799 Web-based access, 773

Oracle Expert, 817, 882-884 Oracle Fail Safe feature, 1079 Oracle FAQWeb site, 18 Oracle functions, 568-569 Oracle Index 1\ming Wizard, 817,

849-850 Oracle Internet Directory (OlD)

adding service names, 454-460 configuring clients for naming,

460-461 creating directory structure,

448-451 creating Oracle Context, 451-454 how it is organized, 44 7-448 how it works, 446-44 7 installing, 443-444 LDAP server (oidldapd), 444,446 making database connections,

446-447 managing server, 444-446 monitor process (oidmon), 444, 445,

446 overview, 441-442 resolving names, 446-44 7 role in security management,

518-519 role of oidctl utility, 444-445 starting, 445, 446 stopping, 446

Oracle Label Security feature, 50~501 Oracle listener service for Windows

systems, 1092-1093 Oracle Managed Files (OMF)

benefits of using, 737

creating databases, 739-742 creating files, 737-742, 739 database creation example, 739-7 42 file naming conventions, 738 initialization parameters, 375-376,

737-738,740,741 limitations, 736-737 overview, 159, 736-737 role in schema management,

253-254 starting instances, 7 40 types of files, 738-739

Oracle Names method, 440 Oracle Net. See also Net Configuration

Assistant (NCA) configuring, 136 directory naming method, 44~1 external naming method, 439-440 GUI tools, 430-431 host naming method, 439 local naming method, 436-438 net service name naming methods,

435-441 Oracle Names method, 440 overview, 427-428 utilities, 428 validating connection requests,

436-438 Oracle Net Configuration Assistant. See

Net Configuration Assistant (NCA) Oracle Net Listener. See also Oracle

listener service for Windows systems

automatic service registration, 432-433

changingconfiguration,433-434 checkingstatus,432-433 and connectivity, 431-435 how it works, 431-432 listing monitored services, 433 managing,434-435 multiple listeners, 434 overview, 427-428 safeguarding service, 522-523 setting password, 434-435 setting queue size, 434 starting, 433 stopping, 433

Oracle Net Manager, 431, 454, 456-458 Oracle Net Services, 426. See also

Oracle Net Oracle Objects for OLE (0040), 1078 Oracle ODBC, 1078 Oracle OLE DB provider, 1078 Oracle Performance Manager, 814, 934,

935,967,968,970,971 Oracle Performance Monitor,

Windows, 1088 Oracle Performance Planner, 814 Oracle PLISQL packages, 1029-1076 Oracle Policy Manager, 500 Oracle processes. See processes, Oracle Oracle product files, 111, 114, 115 Oracle Program Global Area (PGA). See

Program Global Area (PGA) Oracle Real Application Clusters

(ORAC), 92,428,663 Oracle Service (OracleServiceSID),

1091-1092 Oracle Services for Microsoft

Transaction Server (MTS), 1079 Oracle services on Windows systems,

1090--1094 Oracle SQLAnalyzer, 817,880--882 Oracle Storage Compatibility Program

(OSCP), 103 Oracle System Global Area (SGA). See

System Global Area (SGA) Oracle Tablespace Map feature, 817 Oracle Technology Network (OTN), 16 Oracle TopSessions tool, 814-816 Oracle Tracer, 816 Oracle transaction management,

316-318 Oracle Thning Pack, 817, 880--884 Oracle Universal Installer, 116 oracle user. See user oracle Oracle Wallets, 1079 OracleXMLDB, 1136-1140 Oracle9 i Designer tool, 44-45 Oracle9iWarehouse Builder (OWB),

535 ORACLE_BASE variable, 120, 367 OracleDBCreators group, 454

ORACLE_HOME variable, 120, 124, 135,367

ORACLE_LOADER driver, 265 OracleNetAdmins group, 454 OracleSecurityAdmins group, 454 OracleServiceSID, 1081, 1091-1092 ORACLE_SID directory, 396 ORACLE_SID variable, 78, 121, 135, 367 OracleStartSID, 1081 oracle_ trace_ enable initialization

parameter, 387 ORA_DBA group, 1086 oradebug utility, 945 oradim utility, 1095-1096 oraenv script, initializing, 135 ORAENV_ASKvariable, 121 ORAINVENTORY group, 118, 119 orakill command, 1081, 1082 ORAKILL utility, 528 ORA_NLS33 variable, 121 OraPub Web site, 18 orapwd utility, 151 ORA_SID_DBA group, 1086 ORAS_SID_OPER group, 1086 orastack utility, 1085 oratab file, 136 order by clause, 239, 1111, 1123 order of importing, import utility, 590 ordered hint, 842 os_authent_prefix initialization

parameter, 390 OSCP. See Oracle Storage Compatibility

Program (OSCP) OSDBA group, 118 OSOPER group, 118 os_user, as predefined USERENV

attribute, 495 out-of-space errors, 733-734 outer joins, 1120 Outline Manager feature, 817, 858-859 outlines

creating, 857-858 stored, 1045-1047

OUTLN account, 406, 512, 521, 857, 1046

output, UNIX, 65-66

Index

1179

Index

1180

OWB. See Oracle9iWarehouse Builder (OWB)

owner. See user oracle

p packages, PLISQL, 1029-1076 page-level granularity, 323-324 pagesize SQL *Plus environment

variable, 204 paging notification, OEM, configuring,

812-813 parallelexecution,568,859 parallel parameter, SQL *Loader

control file, 546 parallel_automatic_tuning

initialization parameter, 387 parallel_max_servers initialization

parameter, 388 parameter file, defined, 583 parameters. See also initialization

parameters export utility, 581-587 import utility, 590-598

parfile parameter export utility, 583 import utility, 591

parsing and CPU usage, 916-918 guidelines for use, 901-902 hard,311-312,894,900 overview, 311,824 reusing statements, 851, 852, 893 soft, 311, 894 and SQL Trace utility, 894-896

partial database backups vs. entire database backups, 613 user-managed, 661--662

partition independence, 267 partitioned indexes, 282-284, 849 partitioned tables

adding partitions, 272 coalescing partitions, 27 4 composite partitioning, 271-272 dropping partitions, 273-27 4 exchanging partitions, 273 hash partitioning, 269-270

listpartitioning,270-271 maintenance operations, 272-274 merging partitions, 273 overview, 267-268, 854 range partitioning, 268-269 splitting partitions, 273

passwd command, 62 password files, 151, 514-515 passwords

aging policies, 513-514 changing,472 changing for default users, 406 in connect strings, 430 encrypted, 515 expiration, 513-514 for logging into UNIX, 59 role in database authentication,

511-512 security guidelines, 519 setting for listener, 434-435, 522 setting user profile parameters,

474-475 patches,software,889-890 PATH variable, 65, 78, 119, 121, 367 paths, relative us. absolute, 72 pausecommand,211-212 pause SQL *Plus environment variable

2W ,

PCTFREE parameter, 154-155,247,946 PCTINCREASE parameter, 247 PCTUSED parameter, 154-155, 156,

247,725,726 percent sign(%), 59 Performance Manager, OEM

Diagnostics Pack, 814, 934, 935, 967,968,970,971

performance monitoring initialization parameters, 384-388 iostat utility, 89 sarcommand, 89-90,912,913,

920-922,946,1088 tools overview, 88 top command, 90-91 views, 1016-1017 vmstat utility, 88-89, 912, 954, 1088

Performance Planner, 814

performance tables. See dynamic performance views (V$)

performance tuning high-performance databases, 18-19 ll1stancetundng,887-889,963-972 as iterative process, 822-823 memory, 89o-912 overview, 6, 821-823 reactive, 822-823 role of DBA, 3, 6, 18-19,853-860 steps ll1 approaching, 822 system performance, 912-919 tools for SQL, 860-884

period(.), 213 period-overperiod comparison SQL

functions, 1117 permissions

appropriate, 521 changblg, 7o-71 determll1ll1g,69-70 overview, 69-71 security guidelines, 521 setting, 70 types,69-71 UNIX defaults, 521 user oracle, 119, 120

pessimistic locking methods, 322, 323 pfile directory, 113 PFILE file, 410 pfileparameter, 1095 PGA. See Program Global Area (PGA) pga_aggregate_target initialization

parameter, 176, 177, 178, 379-380, 758, 911, 912

phantom read concurrency problem, 314-315

physical databases design, 45-48 vs. logical structures, 140 overview, 146

physical devices, mapping Oracle files to, 766-768

physical records, SQL *Loader control file, 540

physical standby databases, 665 PIDs. See process IDs (PIDs) ping command, 785

The Pipelines Web site, 18 pipelindng,defined,568 PITR (poblt-bl-time recovery), 704-705 PKI (public-key infrastructure), 1079,

1080 PL/SQL. See also SQL statements

basic code blocks, 1128 begin statement, 1128 conditional control, 113o-1132 declare statement, 1128 declarblg variables, 1128-1129 deletestatement, 1129 DML statements, 1129 end statement, 1128 exception statement, 1128 functions, 1135 handling errors, 1129-1130 insertstatement, 1129 looping constructs, 113o-1132 overview, 30, 1127-1130 packages, 1029-1076 raise statement, 1129-1130 selectstatement, 1129 vs. SQL, 1127 update statement, 1129 usblg to transform data, 564, 565 writing executable statements, 1129

plan directives, Database Resource Manager, 752, 753

plan_table table, 861, 862, 864-865, 978 PM sample schema, 1107 PMON. See process monitor (PMON)

background process poblt-bl-time recovery (PITR), 704-705 poblters, to files, 67 policy groups, 500 port numbers, for database

connections, 429 position clause, SQL *Loader control

file,542 positional system, 77 preferred credentials, OEM, 788-789 primary bldexes, 278, 846 primary keys, 34-35,46,47,286,553 private database links, 764-765 private synonyms, 292, 293-294 privilege-level audits, 508

Index

1181

Index

1182

privileged users, 514 privileges

appropriate, 520-521 for creating databases, 394 grant any object privilege privilege,

489 granting and revoking, 201 granting for RMAN, 638 granting through roles, 524 object, 486, 487-488 in Oracle databases, 486-490 revoking, 489 and roles, 490-493 security guidelines, 520-521 system, 486, 487 use of roles, 201

process IDs (PIDs), 82, 1080 process monitor (PMON) background

process,83,16l, 165,432 processes, Oracle

abnormal size increases, 958-959 background processes, 160 components in memory, 958 initialization parameters, 376-377 measuring memory usage, 959 overview, 159 server processes, 160 us. user processes, 160

processes initialization parameter, 376 processes us. threads, 1080-1083 product files, Oracle, 111, 114, 115 PRODUCT_COMPONENT_ VERSION

view, 976 production databases, 11, 12, 353 production DBAs, 10 product_user_profile table, 199, 200 .profile files, 63, 64, 121 profiles. See user profiles Program Global Area (PGA)

advisory, 185 automatic memory management,

911-912 automating SQL execution memory

management,l76-l77 configuring manually, 178 determining memory usage,

180-181

dynamically memory reconfiguration, 758

overview, 175-176 performance tuning, 911-912 role in memory-intensive SQL

operations, 176-177 projection unary operation, 28 projects, estimating system

requirements, 7 prompt command, 211 properties

ACID, 312-313 SQL transactions, 312-313

propositional calculus, 29 protocols, for database connections,

429 proxy authentication, 517 proxy copies, defined, 626 proxy_user, as predefined USERENV

attribute, 495 ps command, 82-83 PSI variable, 65, 77 public database links, 765-766 public-key infrastructure (PKI), 1079,

1080 PUBUC privilege, 521 public synonyms, 292-293 PUBUC user group, 492 pupbld.sql script, 199, 408 pwd command, 62, 73

Q QS sample schema, 1107 queries. See also select statement, SQL

Cartesian product example, 826 comparing with and without

indexes, 867-870 executing,828 heuristic strategies for processing,

827-828 hierarchical, 1117-1118 joining two tables, 827 multiple-table data retrieval,

1118-1120 obtaining wait information, 941-943 optimizing, 824-839

on Oracle service threads, 1083-1084

processing by using Java Database Connectivity (JDBC), 463

reduced relations, 827 rewrite capability, 305-306 sorting results, 1111 subqueries, 239, 841 using Flashback Query feature,

342-346 query parameter, export utility, 584 query rewrite feature, 305-306 query _rewrite_ enabled initialization

parameter, 384, 856 query _rewrite_integrity initialization

parameter, 385 Quest Software, 18, 58, 1052 quiescing,database,422, 759-760,768 quit command, 208 quitting SQL *Plus, 208

R RAID (redundant arrays of

independent disks) and backups, 100 choosing configuration, 98-100 impact on disk 110 rates, 919 list of levels, 96-98 and Oracle, 101 overview, 95-96 pros and cons of each level, 98 ways to implement, 101

raise statement, PL/SQL, 1129-1130 RAM (random-access memory), role in

Oracle database performance, 139-140

random-access memory (RAM), role in Oracle database performance, 139-140

range partitioning, 268-269 ranking type SQL functions, 1116-1117 ratio-to-report comparison SQL

functions, 1117 raw files

data files as, 145 impact on disk 110 rates, 919

and Oracle Real Application Clusters, 92

in tablespaces, 145 vs. UNIX file system, 92, 95

RBU. See Rollback Segment Undo (RBU)mode

rep command, 87 .rev files, 624 RDAs. See redo byte addresses (RDAs) read committed isolation level, 318,

319,320-321 read consistency, 189, 323, 332-340 read-only tablespaces, 253 read uncommitted isolation level, 318,

319 README files, for Oracle9i server

software, 109 reasonable parameter, export utility,

586 rebuildingindexes,745,769,860 rebuilding tables, 860 RECO. See recoverer (RECO)

background process record format, SQL *Loader control file,

541 record numbers, in data loading, 54 7 recordJormat_info external table

access parameter, 558 recordlength parameter, export utility,

585 records, PLISQL, 1134 recover command, 223 recoverer (RECO) background process,

161,166 recovery. See database recovery recovery catalog

backing up, 640-642 connecting to, 624 vs. control file, 637 create catalog command, 638-639 creating schema, 638 drop catalog command, 638 overview, 621-622 registering databases, 639-640

Recovery Manager. See RMAN (Recovery Manager)

Index

1183

Index

1184

recovery-related dictionary views, 1015-1016

recursive CPU usage, 918 recycle buffer pool, 170, 908, 909, 910 redefinition. See online table

redefinition feature redirecting output, 66 redirection operators, 66 redo byte addresses (RDAs), 163 redo log buffer, 168, 174 redo log files

adding groups, 761-762 allocating file space, 366 analyzing with LogMiner, 710-711 archivelog vs. noarchivelog mode,

406-408,612-613,619 corruption in, 666, 763 creating groups, 761 and database backup, 612-613 dictionaryviews, 1012-1015 dropping, 762-763 and fast-start fault recovery,

674-675 key information in, 148 and LGWR background process, 162 loss as example of single point of

failure, 618 managing, 760-766 managing through OEM console,

796 monitoring, 763 multiplexing, 149, 760, 761 OMF file creation, 739,741 OMF file naming convention, 738 overview, 114, 148-149 in redo log groups, 760-763 renaming, 762 resetting after incomplete

recoveries, 691-692 role of CKPT background process,

163 role ofOMF feature, 736-742 role of SCNs, 191 space requests, 951 user-managed backups, 657 viewing details about, 763 writing to disk, 162, 174

redo log groups, 760-763 redo threads, 760 reduced relations, joining, 827 redundancy sets, 618, 680 redundant arrays of independent disks.

See RAID (redundant arrays of independent disks)

referential constraints, 288 referential integrity, 48 Reflections emulator, 58, 59 refreshing statistics, 860 registering database service names

with listener, 432-433 Registry, Windows, 1089-1090, 1099 relational algebra, 28-29 relational calculus, 29 relational database management

systems (RDBMS), 26. See also databases

relational databases. See also databases data anomalies, 39-40 implementation, 48-49 implementing design, 48-49 implementing security, 48 integrity constraint management,

285-291 life cycle, 30-49

limitations of model, 50 logical design, 31-45 vs. object-oriented databases, 50-51 overview, 26-30 physical design, 45-48 requirements analysis, 30-31 reverse engineering, 49 sizing, 48 steps in constructing, 30-49

relations, in relational database model, 27, 38-44. See also entity­relationship modeling (ERM)

relationships, ERM cardinality, 34, 37 changing nature, 35-37 many-to-many, 34,37 one-to-many, 34,37 one-to-one, 34, 37 types, 33-34

relative distinguished names (RDNs), 447,448,454

relative path, 72 Release Notes, for Oracle9i server

so~e,108-109

rely constraints, 290 remark command, 217, 221 remote client authentication, 523 Remote Equivalent Copy, 104 remote file copying, 87, 104 remotelogins,87 remote_login_passwordfile

initialization parameter, 390-391, 514

remote_os_authentinitialization parameter, 520

renaming data files, 252 files,68 Oracle files, 252 Oracle table columns, 259 Oracle tables, 259

ReorgWJ.Zard, 817 reorganization features, Oracle9i,

742-745 Reorganization Wizard, 7 42-7 44 repeatable read isolation level, 318, 319 repfooter command, 225 rep header command, 225 REPLACE SQLfunction, 1114 Replication feature, 663 report need backup command, RMAN,

629 report obsolete command, RMAN, 629,

633-634 report schema command, RMAN,

628-629 reporting system, OEM, 775, 776 reports, OEM

custom, 804 prebuilt, 804 publishing to Web site, 804-806

Reports_ User account, changing default password, 788, 790

resetlogs option, 691-692 resource parameters, 4 73-4 7 4 resource plan directives, 729, 753

Resource Plan Wizard, 485, 486 resource_limit initialization parameter,

388 resources

contention, 969-972 excessive contention for, 957 limiting usage, 472-474

restore tablespace command, RMAN, 686

restore utilities, UNIX, 84-85 restoring databases, 607, 677. See also

database recovery restrict command, 201-202 restricting database access, 417-418 resumable parameter

import utility, 597 SQL *Loader control file, 546

resumable parameters, import utility, 597-598

Resumable Space Allocation feature common errors, 350 DBA_RESUMABLE view, 352, 995 DBMS_RESUMABLE package, 352,

1066 example, 731-732 granting privilege, 350 how it works, 731-732 invoking, 730,731 monitoring, 352 notification of suspended

operations, 351 overview, 251,349,730 and SQL *Loader, 734 steps in using, 350-351 types of conditions, 732-734 types of operations, 349 which operations are resumable,

734 resumable_name parameter

export utility, 586 import utility, 598 SQL *Loader control file, 546

resumable_timeoutparameter export utility, 586 import utility, 598 SQL *Loader control file, 546

resume database command, 423

Index

1185

Index

1186

retention time setting policy in RMAN, 631-632 specifying inAUM feature, 727-728 for undo records, 337-340 undo _retention initialization

parameter, 341, 383, 726, 727 return codes, 550 reverse engineering, 49 reverse key indexes, 282, 848-849 revoking privileges, 489 rlogin command, 87 rm command, 69 RMAN (Recovery Manager)

advantages in database recovery, 680-682

allocate channel command, 653, 654 arctritecture,621-622 backupcommand,627 backup commands, 627-628 backup examples, 642-644 backup optimization feature, 636 benefits, 620-621 block media recovery (BMR)

command, 714 blockrecover command, 714 cloning databases, 698-702 configure channel parameter, 635 configuring, 631-637 control file backup parameters,

636-637 copy command, 628 copy commands, 628 create catalog command, 638-639 creating recovery catalog, 637-642 crosscheck command, 631 data file recovery, 688-689 default device type parameter, 634 drop catalog command, 638 full vs. incremental backups,

627-628 granting privileges, 638 incomplete recoveries, 690-691 job commands, 628 and Legato Single Server Version,

648,649,652-655 l~tbackupcommand,629-630

list backupsets command, 682

l~t copy command, 630 listing commands, 629-630 and Media Management Layer,

647-648 monitoring, 670 overview, 619-621 performing incremental backups,

645-646 performing online backups, 646-64 7 performing recoveries, 680-682 point-in-time recovery, 704-705 recovering data files without

backups, 697-698 recovering from loss of control files,

693-694 recovery window option, 632 redundancy option, 632 registering target databases,

639-640 report need backup command, 629 report obsolete command, 629,

633-634 report schema command, 628-629 reporting commands, 628-629 role oflarge pool, 175 role of recovery catalog, 621-622,

624 scripting language, 624-625 setting degree of parallelism, 635,

655 setting retention policy, 631-632 storing repository, 621-622 tablespace PITR, 704-705 tablespace recovery, 681-682,

686-688 terminology, 625-626 typesofcommands,627-631 vs. user-managed backup methods,

620,621 validate backupsetcommand, 630,

682 validate command, 630-631,

669-670 validation commands, 630-631 verification of backups, 669-670 ways to connect to, 622-624 whole database recovery, 683-685

rmdir command, 73 ROLE_ROLE_PRNS view, 527, 981-982 roles

creating, 491-492 disabling, 492, 524 dropping, 493 enabling, 492 granting privileges through, 524 privileges and, 490-493 and PUBUC user group, 492 secure application, 493

ROLE_SYS_PRNS view, 527, 983 ROLE_TAB_PRNS view, 527 roll-forward process, 674 rollback, in database recovery process,

674,734-736 rollback command, 157, 189,240,

317-318,1110 Rollback Segment Undo (RBU) mode,

158 rollback segments, 156-157,333,

383-384, 726. See also undo segments

rolled back transactions, 189 rollup clause, 1121 root directory, 72, 73 ROUND SQL function, 1114 row exclusive (RX) table locking mode,

326,327 row-level granularity, 323-324, 325 rowlocks,326,329 row share (RS) table locking mode, 326,

327 ROWIDs,832 rows, table

multiple-row subqueries, 1124 single-row subqueries, 1124

rows parameter direct path data loading method,

552 export utility, 584 import utility, 592 SQL *Loader control file, 544

RPAD SQL function, 1114 runcommand,214,215 run queues, 913 runtime area, PGA, 176

s SAME (Stripe and Mirror Everything)

guidelines, 922 SANs. See storage area networks (SANs) SANworks Enterprise Volume Manager,

104 sarcommand,89-90,912,913,

920-922,946,1088 save point command, 240 scalability

Oracle Enterprise Manager (OEM), 774

Windows issues, 1084 scaling, guidelines for use, 901-902 scans

ftilltable,832,840-841,853 index,832-833,840,841

schedules defined,315 serial, 315 serializable, 315

schedulingjobs,85,809 schema-independent users, 518 schema level option

export utility, 582 import utility, 593

Schema Manager, OEM, 795 schemas. See also SQL statements

installing Oracle9i samples, 1106-1107

list of objects, 241 management overview, 241-242 managing in OEM, 794, 795 overview, 27

SCN s. See System Change Numbers (SCNs)

scripts. See also shell programs and OEM, 771-772 in Recovery Manager, 624-625 SQL, choosing for jobs, 808-809

second normal form (2NF), 41-42 secondaryindexes,278,846 secondary storage, 166 secure application roles, 493 Secure Sockets Layer (SSL), 429, 773 security. See also authentication

access control, 497-500

Index

1187

Index

1188

creating policies, 498-500 database guidelines, 519-524 fine-grained measures, 493-501 implementing in new databases, 48 initialization parameters, 390-391 iSQL *Plus issues, 234, 236 policies for applications, 524 role of centralized directories,

517-518 role of DBA, 3, 4-5 SQL*Plus issues, 199-202 Windows model, 1079-1080

security alerts, 523 security identifiers (SIDs)

OracleServiceSID, 1081 OracleStartSID, 1081

Security Manager, OEM, 775, 776, 796 segments

auto option, 155, 156, 245, 247, 726 Automatic Segment Space

Management feature, 156, 725-726

defined, 140, 155 manual option, 155-156, 245, 248 overview, 144 rollback,156-157,333,383-385, 726 space allocation, 155-156, 244, 245,

246,247,725-726 wait statistics, 943-944

select for update command, 329 select statement, PLISQL, 1129 selectstatement, SQL

as of clause, 344-346 for defining views, 296 and DML locks, 324, 325 like condition, 1108, 1112 order by clause, 1111 overview, 201,239, 1107-1108 whereclause, 1108, 1111

selection unary operation, 28 selfjoins, 1119 self-managing databases, 723. See also

automatic Oracle9i database features

semistructured data models, 52 sequence function, in data loading, 54 7

sequence numbers, loading into tables using SQL *Loader, 575

sequences creating, 295 dropping, 295 overview, 294

serial schedules, 315 serializable isolation level, 318,

320-321 serializable schedules, 315 server error triggers, 503 server-executed commands, 199 server parameter file (SPFILE). See

SPFILE server file server processes

defined, 160 overview, 160-161 vs. user processes, 160-161

server-side access controls, 522 serveroutput SQL *Plus environment

variable, 204 servers

and Oracle databases, 139-140 and performance problems, 965

service level agreements (SIAs), 614-616

service_name initialization parameter, 373,428-429

services command, 432-433 services. ora file, 778, 779, 792 session control statements, 239 session optimizer level, 831 session-related dictionary views,

1010-1012 session temporary tables, 263 session_ cached_ cursors initialization

parameter, 901 SESSION_PRIVS view, 527 SESSION_ROLES view, 527 sessions. See also DBMS_SESSION

package active, 752 initialization parameters, 376-377 killing, 527-529

sessions initialization parameter, 376 session_ user, as predefined USERENV

attribute, 495

setconln1and,202-203 set linesize command, 198 set operations, 28-29, 1112 set role command, 201, 239, 524 set theory, 28-29 set transaction command, 240, 320, 321 setenv con1n1and, 65 SGA. See System Global Area (SGA) sga_maximum_size initialization

parameter, 381 sga_max_size initialization parameter,

168,169 SH sample schema, 1107 share lock mode, 189 share row exclusive (SRX) table locking

mode,326,327-328 share (S) table locking mode, 326, 327 shared pool. See also library cache

advisory, 184, 906 dynamic reconfiguration, 755,

757-758 overview, 168, 172-174 performance issues, 960 performance tuning, 892-906 pinning objects in, 904-906 pinning small tables, 860 sizing,903-904

Shared Pool Advisory, 184, 906 shared pool latch, 949 shared schemas, 518 shared server architecture vs.

dedicated server architecture, 426-427

shared_pool_reserved_size initialization parameter, 379

shared_pool_size initialization . parameter, 379

shell programs analyzing, 77-79 automating database imports and

exports, 608 control flow structures, 79-82 creating, 76 database monitoring example,

77-79 example.ksh file, 77-79

executing, 77,79 overview, 76 scheduling, 85 variables in, 76-77

shell scripting. See shell programs shell variables, 63, 65, 76-79 shells, UNIX

basic con1n1ands, 60-62 built-in con1n1ands, 60-62 con1n1and prompts, 59, 77 overview, 57-59

show command, 208 show parameter, import utility, 594-595 show parameter command, 150-151,

392-393 show parameter undo con1n1and,

339-340 show sga command, 178 shutdown con1n1and, 223, 419-421, 614 shutdown scripts, 134-135 shutting down databases

overview, 418 shutdown abort con1n1and, 191,

420-421,614,619 shutdown immediate command,

419 shutdown normal con1n1and, 419,

614 shutdown transactional con1n1and,

419,614 UNIX systems vs. Windows systems,

1086 in Windows systems, 1094-1096

SIDs. See security identifiers (SIDs) SIGTERM signal, 84 silent mode software installation,

131-134 Simple Mail Transfer Protocol (SMTP),

1057 Simple Network Management Protocol

(SNMP), 778 simulating data recovery, 715-716 single points of failure, 618 single-row SQL functions, 1113-1114 single-row subqueries, 1124 skip parameter, SQL *Loader control

file, 547

Index

1189

Index

1190

skip_index_maintenance parameter, direct path data loading method, 552

SLAs (service level agreements), 614-616

SMON. See system monitor (SMON) background process

SMTP (Simple Mail Transfer Protocol), 1057

snmp_ro.ora file, 778-779 snmp_rw.ora file, 778, 779 soft parsing, 311, 894 software patches, 889-890 sort-merge joins, 833 sorting query results, 1111 space management. See also

Resumable Space Allocation feature; Workspace Manager feature

Automatic Segment Space Management feature, 156, 725-726

Automatic Undo Management feature, 726-730

and locally managed databases, 724-725

space-related errors, 732-734 Spcpkg.sql script, 923 Spctab.sql script, 923 Spcuser.sql script, 923 SPFILE server file

backing up, 636 creating,149,150,368,410-413 example, 412 vs. init.ora file, 409 OMF initialization parameters,

737-738 overview, 149, 150,409-410 reading, 392 scope of dynamic parameter

changes, 413-414 splitting table partitions, 273 spoolcommand,210-211 spreport.sql script, 929 SQL. See structured query language

(SQL) SQL Analyze tool, 817, 880-882

SQL buffer, 217 SQL functions

aggregate, 1114,1120-1121 analytical, 1116-1117 conditional, 1115-1116 date, 1114-1115 first/last aggregate, 1117 general, 1115-1116 histogram, 1117 hypothetical rank and distribution,

1117 inverse percentile, 1117 moving-window aggregate, 1117 number, 1114-1115 overview, 1113 period-overperiod comparison,

1117 ranking type, 1116-1117 ratio-to-report comparison, 1117 single-row, 1113-1114 statistical, 1117 in where clauses, 841

SQL performance tuning tools Autotrace tool, 865-870 Explain Plan tool, 861-865 GUI tools, 879-884 OEM Thning Pack, 817, 880-884 Oracle Expert tool, 882-884 SQLAnalyze tool, 817,880-882 SQL Trace tool, 870-873, 894-896 T.KPROF utility, 870, 872, 873-876,

896 V$SQLAREA view, 877-879, 903,

1018,1033 SQLISML standard, 1137 SQL statements

common transformations, 832 . data definition statements, 240-241 data manipulation statements,

239-240 determining use, 526 hints that influence CBO execution

plan, 842 improving code quality, 839-853 inline functions, 851-852 multi table inserts, 535, 566-567 optimizing, 893

Oracle types, 237-241 parallelexecution,859 parsing, 824 processing by using Java Database

Connectivity, 462-465 and query processing, 824-828 reusing, 851 role of library cache, 173 session control statements, 239 simpletuning,884-885 system control statements, 238-239 tools for optimizing, 860-884 tracing by using 10046 Trace, 944 transaction control statements, 240 transforming, 831-832 using to generate SQL scripts,

226-227 using to transform data, 564-573 where clause, 839-841

SQL Trace tool, 870-873, 894-896 SQL transactions

ACID properties, 312-313 assigning users to consumer groups,

752 autonomous, 346 binding stage, 312 committed,189,190,191 concurrency control, 313-318 and consistency, 323 cursors in, 311 deadlocks, 331 defined, 189, 309 dictionary views for monitoring,

993-995 discrete, 346 execution stage, 312 ISO standard, 315-316 limiting maximum execution times,

752-753 limiting number by using queuing,

752 long-running,352-360,752,964-965 and Oracle, 316-318 overview, 310 overwriting, 337 parsing stage, 311 possible events, 310

properties,312-313 role of PGA in memory-intensive

operations, 176-177 rolled back, 189 simple example, 187-189 soft vs. hard parsing, 311-312 stages, 311-312

sql_context feature, 495 SQLJ, 1142-1143 SQL*Loader

control file overview, 537-547 data loading overview, 533-535 direct path loading method,

536-537,550-553 dropping and rebuilding indexes,

576 vs. External Table feature, 555 generating data, 54 7 generating external table creation

statements, 560-562 invoking,548-552 loading data into multiple tables,

576 loading large data fields into tables,

574 loading sequence numbers into

tables, 575 loading table data into ASCII files,

575 loading XML data into, 577 log file, 549-550 methods of data loading, 536-537 overview, 265-266, 536 parameter file, 548 parfile, 548 removing duplicate data, 575 and resumable operations, 734 role of External Table feature, 537 role of Oracle9iWarehouse Builder,

535 steps in loading data, 537 tips for optimizing use, 554 trapping error codes, 576 useful data-loading techniques,

573-577 using to load usernames into tables,

574

Index

1191

Index

1192

using when clause during loads, 573-577

sqlnet.ora file enforcing server-side access

controls, 522 and local naming, 438

SQL*Plus command line arguments, 206-207 commands for database

administration,223 commands that do something,

209-212 comments in scripts, 217, 221 creating command files, 212 creating Web pages, 222-223 editing code, 218-222 executing command scripts,

213-215 exiting, 208 formatting commands, 224-225 interactive mode, 198 invoking, 198 vs. iSQL *Plus, 227 limiting access, 199-201 list of commands, 202-203 list of common environment

variables, 203-204 listing commands, 217-218 manual mode, 198 overview, 197-198 restricting usage, 524 role in creating databases, 394, 396 saving commands to a file, 212-213 scripted mode, 198 security issues, 199-202 setting environment, 202-203 setting environment variables,

203-204 specifying variable preferences,

205-206 types of commands, 198-199 in Windows systems, 1094-1096

sqlplus_product_user_profile, 199 sqlpromptcommand, 209 sqlprompt SQL *Plus environment

variable, 204 sql_trace initialization parameter, 387

square brackets([]), 204 ssh program, 87 SSL (Secure Sockets Layer), 429, 773 standard errors, 65, 66 standard input, 66 standard output, 66 standby databases

and data center disasters, 675 DBMS_LOGSTDBYpackage, 1062 and Oracle Data Guard, 663-664 physical and logical, 664-665 protection modes, 665-666

start command, 223 start-up scripts, 134-135,215 start-up triggers, 503 start with clause, in hierarchical

queries, 1117 starting databases

in UNIX systems, 414-417 UNIX systems vs. Wmdows systems,

1086 in Windows systems, 1094-1096

star _transformation_ enabled initialization parameter, 385, 856

startup mount command, 415-416 startup nomountcommand, 415 statement-level audits, 508 Statement object, JDBC, 463 statement optimizer level, 831 statistical SQL functions, 1117 statistics, table, 597, 860. See also

DBMS_STATS package statistics parameter, export utility, 585,

605 statistics_ level initialization parameter,

871 Statspack tool

collecting data, 926-928 deleting data, 928 installing,923-924 obtaining reports, 928-933 overview, 922-923 related GUI-based tools, 933 scheduling statistics collection, 928 snapshot levels, 925-926 using, 925-936

status command, 432-433

status.sql script example, 214 storage area networks (SANs), 102 Storage Manager, OEM, 796-797 storage-related dynamic dictionary

views, 1026-1027 storage-related static views, 989-993 storage technologies. See also disk

systems; RAID (redundant arrays of independent disks)

capacity overview, 101 InfiniBand, 103 network attached storage, 102-103 role of Oracle Corporation, 103-104 storage area networks, 102

store command, 208 store_area_size initialization

parameter, 855 stored outlines

creating and managing in Outline Manager, 858-859

creating manually, 857-858 and DBMS_OUTLN package, 857,

1045-1046 editing, 858, 859 enabling, 858 implementing plan stability, 856 managing,1045-1047 overview, 855-856 tracking in databases, 1046-104 7 when to use, 856

stored procedures executing,489-490 Java, 1141

streaming, defined, 568 streamsize parameter, direct path data

loading method, 553 strings, connect, 430 Stripe and Mirror Everything (SAME)

guidelines, 922 striping,disk,94,96,97,98,919 structured query language (SQL). See

also PLISQL; SQL statements basic concepts, 1107-1111 code quality improvement, 839-853 DML statements, 30, 201, 239-240,

1107-1110 grouping of operations, 112Q-1123

hierarchical data retrieval, 1117-1118

multiple-table data retrieval, 1118-1120

overview, 27-28, 237-238, 1105 and relational theory, 29-30 sorting query results, 1111 as transform-oriented language, 30 value of good coding practices, 823

subqueries in from clauses, 239 correlated, 1124 IN clause vs. EXISTS clause, 841 inline views as, 239, 1123 multiple-column, 1124 multiple-row, 1124 nested, 239, 1123 single-row, 1124 in where clauses, 239,841 writing, 1123-1125

substitution variables, 216 SUBSTR SQLfunction, 568,841, 1114 Summary Advisor

collecting statistics, 298-300 filtering workload contents, 301 overview, 298 providing workload, 299-300 recommendations, 302-303

Sun Microsystems, 104 Sun Solaris, 56 supplemental logging, 707 suspended mode, 760 switches, command, 63 symbolic links, 67 symbolic notation, 70, 71 synchronizing tables in table

redefinition process, 750 synonyms

dropping,293-294 overview, 291 private, 292, 293-294 public, 292-293 viewing information, 294

SYS account, 193, 394, 406, 512, 514, 759,768,866,1030

SYSDATE SQL function, 1114 sysdate variable, in data loading, 54 7

Index

1193

Index

1194

SYSDBA privilege, 151, 394, 410, 506, 507,514,520

SYSOPER privilege, 410, 506, 507, 514, 520

SYSTEM account, 394,406, 512, 759, 764-765,768,866

system activity reporter (sar), 89-90, 912,913,920-922,946,1088

system administrators, UNIX obtaining necessary DBA

authorization,367 vs. Oracle DBAs, 15-16,84 role in Oracle9 i installation, 116-120

System Change Numbers (SCNs) overview, 190-191 and read consistency, 332-333 role in database backups, 613-614

system control statements. See alter system command

system failures, 673-674 system files, 72 System Global Area (SGA)

advisories, 183-184 database buffer cache, 168, 169-172 determining memory usage,

179-180 dynamic memory reconfiguration,

755-758 dynamicallymodifying, 181-183 Java pool, 168, 175 locking, 169 main components, 168 optional larger pool, 168, 175 overview, 167-168 redo log buffer, 168, 174 role of Oracle Enterprise Manager,

185-187 sga_max_size initialization

parameter, 168, 169 shared pool, 168, 172-174 size considerations, 167, 168

system identifiers (SIDs), 428 system-level triggers, 503-505 system monitor (SMON) background

process, 161,165,726-727 system performance, 912-919 system privileges, 486, 487,489

System tablespace, 145, 156, 244, 725, 741

systemstate dumps, 961

T table column names, SQL*Loader

control file, 541 table functions

how to use, 569-572 for mining Web services data,

572-573 overview, 568-569 vs. regular Oracle functions, 568-569 role in ETL process, 535

table level option export utility, 581-582 import utility, 593

tablelocks,326,327-329 table-mapping clauses, SQL*Loader

control file, 541-543 table operator, 1126 table redefinition. See online table

redefinition feature tables, database

access by ROWlD, 832 adding, dropping, and renaming

columns, 745 adding columns, 259 allocating file space, 365 altering, 258 changing storage parameters, 7 45 clusters, 277 compressing, 854-855 copying,221-222 creating, 256-261 creating by using CTAS option,

260-261 designing, 47-48 dropping columns, 259 external, 265-267 fullscans,832,840-841,853 heap-organized,257 index-organized,263-265,745,847 indexscans,832-833,840,841 inserting XML documents into,

1138-1140

integrity constraint management, 285-291

interim/temporary, 747-750 joining selected rows, 827 joining two, 827 lock±ngissues,957-958 maximum extents-related errors,

732-733 moving to another tablespace, 7 45 multiple, loading in one SQL *Loader

run,576 multiple, selecting data from,

1118-1120 naming conventions, 47 nested, 1126 normalizing, 38-44 optimizer access methods, 832-833 out-of-space errors, 733-734 partitioned,267-274,854 partitioning online, 7 45 pinning in shared pool, 860 rebuilding, 860 redefir.Ung,745-751 reducing fragmentation, 7 45 removing all data, 260 renaming, 259 renaming columns, 259 renaming constraints, 7 45 role in relational model, 26-27 session temporary, 263 special, 261-277 specifying columns, 4 7 specifyingtablespace,257 starting redefinition process,

748-749 synchronizing in table redefinition

process, 750 temporary, 261-263 transaction temporary, 263 transforming data, 7 45 transforming ERDs into, 46 types, 47 versioning, 353-359 what to index, 846-84 7 when to index, 845-846

tables, internal, 192. See also data dictionary; dynamic performance views (V$)

tablespace level option, export utility, 582

Tablespace Map feature, 817 tablespaces

adding space, 251 assigning to new users, 4 70-4 71 backing up, 644, 661-662 benefits, 146 creating, 157,242,244-256 creating in OMF database example,

741-742 creating more, 404-405 data dictionary views, 254-256 defined, 140, 242 extent sizes, 156-157 fragmentation issues, 724-725 increasing database size, 152-157 locallymanaged,724-726 locally vs. dictionary managed,

153-154,155,156,157,243-244, 724,725,1049-1050

managing through OEM console, 796

multiple block sizes, 144-145, 171, 249

naming, 114 OEM_repository, 783-785 OMF files, 253-254 online block changes, 753-755 overview, 111, 114, 144, 152 point-in-time recovery, 704-705 read-only, 253 recovering,681-682,686-689 removing,250-251 space allocation, 153-156 storage features, 244-246 System tablespace, 145 taking offline, 252 temporary, 145, 154, 249 transportable, 535, 599-604, 1073 undo tablespace, 145 undoing changes, 704-705

tail command, 75

Index

1195

Index

1196

tape devices, 611, 620, 621, 634. See also Legato Single Server Version (LSSV)

tarcornrnand,84-85,1087 Task Manager, Windows, 1088 TCPIIP, 429 telnet, 59, 86 temp files, OMF file naming

convention, 738 temporary tables

creating,263,747-750 features, 262 overview, 261-262 session length, 263 transaction-length, 263

temporary tablespaces allocating file space, 365 assigning to new users, 4 71 creating,249-250,365 creating in OMF database example,

741 and locally managed tablespaces,

154 need for, 145

terminal, as predefined USERENV attribute, 495

terminal emulators, 58, 59 termout SQL *Plus environment

variable, 204 test databases, 11, 12 third normal form (3NF), 42-43 threads,querying,1083-1084 threads vs. processes, 1080-1083. See

also processes, Oracle time SQL *Plus environment variable,

204 timed_statistics initialization

parameter, 388, 871 timestamping,190,322 timing SQL *Plus environment variable,

204 TKPROF utility, 870, 872, 873-876, 896 /tmp directory, 73 TNS_ADMIN variable, 121, 135 tnsnames.ora file

example, 437-438 migrating to OlD, 458-460 overview, 436

TOAD GUI-based software, 1052 TO_CHAR SQL function, 1115 TO_DATE SQL function, 841, 1115 TO_NUMBER SQL function, 841, 1115 top cornrnand, 90-91 top n analysis, 1123 TopSessions tool, 814-816,963 TO_TIMESTAMP SQL function, 1115 trace files, 152 Tracerfeature,816 tracing SQL statement execution

using 10046 Trace, 944 using DBMS_SYSTEM package, 945 using oradebug utility, 945 using SQL Trace, 870-873, 894-896 using TKPROE 873-876

training, 12-15 transaction control statements, 240 transaction-set consistency, 189 transaction temporary tables, 263 transaction_auditing initialization

parameter, 372 transactions, SQL. See SQL transactions transfer rate, 96 transform-oriented languages, 30 transformation. See ETL (Extraction,

Transformation, Loading) process transforming data. See data

transformation TRANSlATE function, 568 transparency

location, 291,426 object, 291

transportable tablespaces DBMS_TTS package, 601, 1073-1074 how to use, 600-604 overview, 599-600 role in ETL process, 535 ways to use, 600

tree structure, UNIX directories, 72 trial recoveries, 715-716 triggers

creating in table redefinition process, 7 49

and customized database auditing, 501-506

database start-up, 503

DDL, 503, 505 and direct path data loading

method, 553 DML-based, 502-503 logoff, 503, 504 logon, 503, 504 overview, 296 server error, 503 system-level, 503-505

triggers, disabling, 553 triggers parameter, export utility, 585 TRIM SQL function, 1114 troubleshooting

connectivity, 466-468 database recovery, 716-718 databases, 6, 19-20 Oracle Enterprise Manager, 817-818

TRUNC SQL function, 1114 truncate command, 260, 1110 ttitle command, 225 tuples, 28 TWO_TASK variable, 135 type hierarchies, 1126

u uname command, 62 unary operations, 28, 828 undefinecommand, 216 underscore U, 151 undo records, 157, 332-340, 726 undo segments, 189, 322-323, 335-336,

726-727,730. See also rollback segments

undo space initialization parameters, 382-383 managing,333-340 managing information, 339-340

Undo Space Advisor, OEM, 728 Undo Tablespace Advisory, OEM,

338-339 undo tablespace command, 727 undo tablespaces

allocating file space, 365 creating, 145,334-335,727 creating in OMF database example,

741

dynamicallychanging,335 monitoring, 729 overview, 726 sizing,338-339 switching between, 728-729

undo_managementinitialization parameter, 334, 336, 383

undo_pool resource plan directive, 729, 753

undo _retention initialization parameter, 341, 383, 726, 727

undo_tablespace initialization parameter, 382

uninstalling Oracle software using Universal Installer, 136 on Windows systems, 1100-1101

union set operator, 28, 1113 unique constraints, 287-288, 553 unique identifiers (UIDs), 34 unique keys, 278 UNIX

accessing system, 58-59 basic commands, 60-62 creating database backups, 655-666 creating groups prior to Oracle9i

server software installation, 118 data input, 65-66 data output, 65-66 and disk storage, 92-93 environment, 63-65, 367-368, 394 getting help, 60 home directory, 73 installing Oracle9i server software,

107-136 and IP addresses, 59 killing sessions, 527-529 vs. Linux operating system,

1101-1103 logging in, 58-59 logging out, 59 navigating files and directories,

66-75 overview, 55-57 performance monitoring tools,

88-92 popular servers, 56

Index

1197

Index

1198

running processes in background, 83

shells for, 57-59 system administrators, 15-16, 84,

116--120 terminating processes, 83-84 tracking processes, 82-83 variants, 55-56 vs. Windows operating system,

1080-1088 unrecoverable parameter, direct path

data loading method, 552 until-do-done loops, 80-81 update anomalies, 39 update statement, SQL, 201, 240, 324,

325,564,1110,1111 upgrading software, 8-9 upserts, role in ETL process, 535 uptime,615,616 U.S. Immigration and Naturalization

Service (INS), 962 user accounts

default,creating,512 locking and unlocking, 512-513 open vs.locked, 512 security guidelines, 519

user authentication. See authentication user-defined data types, 242 user dump directory, 113, 152 user files, 72 /user/local/bin/ directory, 119 user-managed backups

managing, 662 overview, 655-656 partial database backups, 661-662 vs. RMAN utility, 619, 620, 621 whole databases, 656--661

user-managed recoveries after loss of control files, 694-697 after loss of data files without

backups, 698 complete recovery of whole

databases,683-685 data file recovery, 689 incomplete,692-693 overview, 682-683 tablespace recovery, 688

user management assigning default tablespace to new

users, 470 assigning temporary tablespace to

new users, 4 71 creating users, 4 71-4 72 dynamic dictionary views,

1010-1012 overview, 4 70 static dictionary views, 979-987 tasks before creating users, 470-471

User Manager, Wmdows, 1088 user oracle

creating, 118-119 file permissions, 119, 120 .profile file, 121 tasks after installation of Oracle9 i

server software, 135-136 tasks prior to installation of Oracle9 i

serversoftware,120-121 user processes

defined, 160 vs. Oracle processes, 160 vs. server processes, 160-161

user profiles altering, 476, 524-525 assigning to users, 4 76 default profile, 4 75 dropping,476-477 limiting user resource usage,

472-474 parameters and limits, 4 73-477 setting password parameters,

474-475 user statement errors, 676 user _dump_dest initialization

parameter, 374,873 user _dump_file_size initialization

parameter, 872 USERENV namespace, 494-496 userid parameter

export utility, 581 import utility, 591 SQL *Loader control file, 543

usemames in connect strings, 430 using SQL *Loader to load into

tables, 574

users. See also user oracle altering profiles, 476, 524-525 assigning profiles, 476 changing passwords, 472, 526 controlling their database access,

486-493 creating, 5, 471-472 determining SQL statement use; 526 dropping profiles, 4 76-4 77 killing sessions, 527-529 limiting resource usage, 4 72-4 7 4 listing information, 525 logging in as, 526 managing,5,524-529 privileged, 514 and privileges, 486-490 and roles, 490-493 schema-independent, 518 setting password parameters,

474-475 UNIX systems vs. Windows systems,

1086 useful DBA views for managing, 527

use_stored_outlines initialization parameter, 858, 1046

/usr/bin/ksh directory, 78 UTL_FILE package, 521, 1053-1057 utl_Jile_directory initialization

paramete~375,521, 1054 UTL_SMTP package, 1057-1060 UTL_TCP package, 1057-1058 utlxplan.sql script, 861

v V$views

overview, 193-194 using for wait information, 939-941

validate backupset command, RMAN, 630,682

validate command, RMAN, 630-631, 669-670

validate index command, 837 validation, as method of concurrency

control, 322 V$ARCHIVE_DEST view, 1014-1015 V$ARCHIVE_DEST_STATUS view, 1015

V$ARCHIVED_LOGview, 709, 1014 variable cursors, 1134-1135 variable length external table access

parameter, 559 variables. See also environment

variables PL!SQL, declaring, 1128-1129 shell,63,65,76-79

varrays, 1126 V$BACKUP view, 1008-1009 V$BACKUP _DEVICE view, 1008 V$BACKUP _PIECE view, 1009 V$BGPROCESS view, 1081, 1083 V$BUFFER_POOL view, 1005 V$BUFFER_POOL_STATISTICS view,

907 V$CONTROLFILE view, 1027 V$CONTROLFILE_RECORD_SECTION

view, 1027 V$DATABASE view, 1022-1023 V$DATAFILE view, 766, 1026 V$DB_CACHE_ADVICE view, 184, 908,

1005-1006 V$DB_OBJECT_CACHE view, 903,

1006-1007,1061 V$DISPATCHER view, 1023 verify SQL *Plus environment variable,

204 versioned tables, 353-359 versions, defined, 111 V$FILESTAT view, 94 7, 1026 vi editor

creating files, 7 4-75 editing files, 7 4-75 navigation commands, 74 overview, 7 4 text manipulation commands,

74-75 view resolution, 297 viewing file contents, 68 views. See also data dictionary;

dynamic performance views (V$); materialized views

creating, 296 improper use, 853 overview, 296 when to use, 853

Index

1199

Index

1200

V$INSTANCE view, 423, 1018-1019 V$INSTANCE_RECOVERY view, 735,

1015-1016 Virtual Private Databases, 493, 494 V$IATCH view, 1020 V$IATCHNAME view, 1020 V$LIBRARYCACHE view, 896-898, 1006 V$LIBRARY_CACHE_MEMORY view,

898 V$LICENSE view, 1022 V$LOCKview, 1019 V$LOCKED_OBJECTview, 1020 V$LOG view, 763, 1013 V$LOGFILE view, 763, 1013 V$LOGMNR_CONTENTS view, 706,

710-711 V$MAP _ELEMENT view, 767, 1075 V$MAP _FILE view, 767, 1075 V$MAP _FILE_IO_STACKview, 767 vmstat utility, 88-89, 912, 954, 1088 V$NLS_PARAMETERS view, 1024 V$0BJECT_USAGE view, 850, 1025 V$0PTION view, 1023 V$PARAMETER view, 150, 392,

1023-1024 VPDs. See Virtual Private Databases V$PGASTAT view, 758, 1007 V$PGASTAT_TARGET_ADVICE view,

1008 V$PGA_TARGET_ADVICE view, 185,

911,912 V$PROCESS view, 180, 1020-1021 V$PWFILE_USERS view, 514, 1010 V$RECOVER_FILE view, 1016 V$RMAN_CONFIGURATION view, 631,

1009 V$ROLLSTAT view, 340 V$ROWCACHE view, 1006 V$RSRC_CONSUMER_GROUP view,

1021 V$RSRC_PLAN view, 1021 V$SEGMENT_STATISTICS view, 943,

944 V$SEGSTAT view, 943 V$SEGSTAT_NAME view, 943 V$SESS_IO view, 1012

V$SESSION view, 194, 330, 525, 526, 528,957,1011,1033

V$SESSION_CONNECT_INFO view, 1010-1011

V$SESSION_EVENT view, 938, 939, 940-941,965

V$SESSION_LONGOPS view, 670, 1012 V$SESSION_ WAIT view, 939-940,

942-943,946,965 V$SESSION_ WAITS view, 963 V$SGA view, 1004 V$SGA_DYNAMIC_COMPONENTS

view, 1005 V$SGAS11\Tview, 178-180,181,906,

1004 V$SHARED_POOL_ADVICE view, 184,

757-758,898 V$SPPARAMETER view, 1024 V$SQL view, 964, 1018 V$SQIAREA view, 877-879, 903, 1018,

1033 V$SQL_PLAN view, 879 V$SQL_PLAN_STATISTICS view, 879 V$SQLTEXT view, 1018 V$STATISTICS_LEVEL view, 183, 1025 V$SYSSTATview, 951,963, 1016-1017 V$SYSTEM_EVENT view, 939, 942, 943,

944 V$SYSTEM_PARAMETER view, 1023 V$TABLESPACE view, 766 V$TRANSACTION view, 340, 1021 V$UNDOSTAT view, 337-338, 340, 729 V$VERSION view, 1022

w W3C (WorldWide Web Consortium), 33 wait events

buffer busy waits, 945-947 collecting statistics, 938-952 list, 945-952

wait information collecting event details, 944-945 obtaining, 941-943 segment-level statistics, 943-944 using V$ tables for finding, 939-941

overview, 938-939

VVallet~anage~ 1079 VVarehouse Builder. See0racle9i

VVarehouse Builder (OVVB) VVarehouse ~anagement feature, OE~.

797-799 warm backups, 614 VVeb pages, creating with SQL *Plus,

222-223 VVeb servers, configuring for OE~

reporting services, 790-791 VVeb services, using table functions to

mine data, 572-573 VVeb sites

for Oracle resources, 17-18 publishing OE~ reports to, 804-806

when clause, in SQL *Loader control files, 573-574

where clause and CBO, 839-841 and filtering data, 1111 vs. having clause, 842 and select statement, 1108, 1111 SQL functions in, 841 and update statement, 1110, 1111

whereis command, 62 which command, 62 while-do-done loops, 79-80 while loop, 1131 who command, 62 whoami command, 62 Wmdows NT Server, 58 Wmdows Services

typical list, 1084-1085 vs. UNIX daemons, 1084-1085

Wmdows systems accessing index wizard, 849 Active Directory, 1080 automatic database start-up and

shutdown, 1086 CPU considerations, 1086 creating batch scripts, 215 database access methods, 1078 installing Oracle9i, 1088-1089 managing Oracle on, 1090-1011 memory considerations, 1085-1086 monitoring ~anagement Server,

784,785

Oracle integration with Wmdows services,1079-1080

Oracle9i overview, 1077-1080 OracleServiceSID, 1081 OracleStartSID, 1081 overview, 56 Registry, 1089-1090 scalability issues, 1084 security model, 1079-1080 starting Oracle services, 1090-1094 system administrators, 15-16 uninstalling Oracle, 1100-1101 vs. UNIX, 1080-1088

wizards Analyze WIZard, 801-802 Backup WIZard, 802-803 Directory ~igration VVizard,

458-460 Export VVizard, 800-801 Import WIZard, 800-801 IndexThningVVizard, 817,849-850 in Oracle Enterprise ~anager,

799-803 ReorgVVizard, 817 Reorganization VVizard, 7 42-7 44 Resource Plan WIZard, 485, 486

~SYSschema,353,354

~$VERSIONED_TABLES table, 353 ~$VERSION_ TABLE table, 353 workarea_size_policy initialization

parameter, 388, 758 VVorkspace ~anager feature

benefits of using, 353 creating tables for use in, 356 creatingworkspaces, 357-359 DB~S_ ~package, 355, 356,

1070-1071 granting privileges, 355-356 and import utility, 606 inserting test values into tables,

356-357 installing, 354-355 managing workspaces in, 359-360 overview, 352, 798 and table versioning, 353-359

write ahead protocol, 190 VVRQ emulator, 58

Index

1201

Index

1202

X XWmdowSystem, 58,1101 XML (Extensible Markup Language)

creating relational document views, 1140

loading data into Oracle XML databases, 577

in Oracle9i, 52 Oracle9iXMLDB, 1136-1140 storinginXMLDB, 1137-1140

XML repository, 1139-1140 XML schemas, 1140 XMLType data type, 1137 >DPath,1137,1138

JOIN THE APRESS FORUMS AND BE PART OF OUR COMMUNilY. You'll find discussions that cover topics

of interest to IT professionals, programmers, and enthusiasts just like you. If you post a query to one of our

forums, you can expect that some of the best minds in the business-especially Apress authors, who all write

with The Expert's Voice TM-will chime in to help you. Why not aim to become one of our most valuable partic­

ipants (MVPs) and win cool stuff? Here's a sampling of what you'll find:

DATABASES

Data drives everything. Share information, exchange ideas, and discuss any database programming or administration issues.

INTERNET TECHNOLOGIES AND NETWORKING

Try living without plumbing (and eventually 1Pv6). Talk about networking topics including protocols, design, administration, wireless, wired, storage, backup, certifications, trends, and new technologies.

JAVA

We've come a long way from the old Oak tree. Hang out and discuss Java in whatever fiavor you choose: J2SE, J2EE, J2ME, Jakarta, and so on.

MAC OSX

All about the Zen of OS X. OS X is both the present and the future for Mac apps. Make suggestions, offer up ideas, or boast about your new hardware.

OPEN SOURCE

Source code is good; understanding (open) source is better. Discuss open source technologies and related topics such as PHP, MySQL, Linux, Perl, Apache, Python, and more.

HOW TO PARTICIPATE:

PROGRAMMING/BUSINESS

Unfortunately, it is. Talk about the Apress line of books that cover software methodology, best practices, and how programmers interact with the "suits."

WEB DEVELOPMENT/DESIGN

Ugly doesn't cut it anymore, and CGI is absurd. Help is in sight for your site. Find design solutions for your projects and get ideas for building an interactive Web site.

SECURITY

Lots of bad guys out there-the good guys need help. Discuss computer and network security issues here. Just don't let anyone else know the answers!

TECHNOLOGY IN ACTION

Cool things. Fun things. lfs after hours. It's time to play. Whether you're into LEGQ® MINDSTORMS™ or turning an old PC into a DVR, this is where technology turns into fun.

WINDOWS

No defenestration here. Ask questions about all aspects of Windows programming, get help on Microsoft technologies covered in Apress books, or provide feedback on any Apress Windows book.

Go to the Apress Forums site at http://forums.apress.com/.

Click the New User link.