Skip to Main Content
Oracle PL/SQL Programming: A Developer's Workbook
book

Oracle PL/SQL Programming: A Developer's Workbook

by Steven Feuerstein, Andrew Odewahn
May 2000
Intermediate to advanced content levelIntermediate to advanced
594 pages
11h 32m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL Programming: A Developer's Workbook

Intermediate

30-8.

One of a DBA’s tasks is to ensure that Oracle’s cost-based optimizer is using up-to-date statistics. Luckily, this task can be automated using a combination of two of Oracle’s built-in packages, DBMS_ JOB and DBMS_UTILITY.

Write a procedure that analyzes a specific schema to create statistics for the cost-based optimizer. This procedure will be submitted hourly by DBMS_ JOB. At 1:00 A.M. and 2:00 A.M., perform a complete analysis; otherwise, do it only for the indexes.

30-9.

Oracle8 introduced partitioned tables and indexes that are both a DBA’s dream and a DBA’s nightmare. They are a dream because they distribute system I/O and allow maintenance to be performed without causing all data to be unavailable. They can be nightmarish if they are used to perform business logic, as in the following exercise where no account transactions can be entered for a given month until after the 20th day of the previous month.

Suppose that a table called account_trx is created and partitioned as shown here:

CREATE TABLE account_trx
(account_no NUMBER,
 trx_amt    NUMBER,
 trx_date   DATE)
PARTITION BY RANGE (trx_date)
(PARTITION trx_199812 VALUES LESS THAN (to_date('01-JAN-1999',
                                           'DD-MON-YYYY')),
 PARTITION trx_199901 VALUES LESS THAN (to_date('01-FEB-1999',
                                           'DD-MON-YYYY')),
 PARTITION trx_199902 VALUES LESS THAN (to_date('01-MAR-1999',
                                           'DD-MON-YYYY')))
/

Write a procedure that sets up a job to run on the 20th of each month to create the partition for that month’s data.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle Database 12c PL/SQL Programming

Oracle Database 12c PL/SQL Programming

Michael McLaughlin
Oracle PL/SQL for DBAs

Oracle PL/SQL for DBAs

Arup Nanda, Steven Feuerstein
Oracle PL/SQL For Dummies

Oracle PL/SQL For Dummies

Michael Rosenblum, Paul Dorsey

Publisher Resources

ISBN: 9781449324070Supplemental ContentErrata Page