Skip to 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
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Oracle Database 12c PL/SQL Advanced Programming Techniques

Oracle Database 12c PL/SQL Advanced Programming Techniques

Michael McLaughlin, John Harper

Publisher Resources

ISBN: 9781449324070Errata Page