Top Banner
CIT 4403 – Database Administration Oracle 10g Database Administrator: Implementation & Administration Chapter 11
12
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Chapter 11

CIT 4403 – Database Administration

Oracle 10g Database Administrator: Implementation & Administration

Chapter 11

Page 2: Chapter 11

Oracle 10g Database Administrator: Implementation and Administration 2

Introduction to Advanced Data Management

• Advanced data management methods in Oracle– Programming Language for SQL (PL/SQL)

• Allows construction of properly scripted intra-dependant SQL command structures

– Data pump technology• Used to perform bulk loads and dumps into and out of

an Oracle database

– SQL Loader• Generally most efficient tool for mass data loading

• Allows loading of OS flat files into table(s) at once

Page 3: Chapter 11

Oracle 10g Database Administrator: Implementation and Administration 3

Named Blocks and Packages

• A named block is a chunk of code given a label, so that block of code can be stored in the database– Is stored and can be recalled later and re-executed,

without having to retype the entire block of code– Can be of various types with various restrictions:

• Procedure

• Function

• Trigger

• Package

Page 4: Chapter 11

Oracle 10g Database Administrator: Implementation and Administration 4

Triggers and Events Firing Triggers (continued)

Page 5: Chapter 11

Oracle 10g Database Administrator: Implementation and Administration 5

What is a Cursor?

• What is a cursor?– Temporary area (Work Area) in memory used to

store the results of a query– Pointer to address in memory, a chunk of memory – SQL statement results are processed in cursors

during execution– In PL/SQL, cursors can be created as programming

structures for holding iterations of data– Can be used for queries returning one or many rows,

and can be of two types, implicit and explicit cursors

Page 6: Chapter 11

Oracle 10g Database Administrator: Implementation and Administration 6

What is a Cursor? (continued)

• Explicit cursor: declared by the programmer– Allows greater programming control– Cursor commands: OPEN, FETCH, and CLOSE

DECLARECURSOR CCLIENT IS SELECT * FROM CLIENT;RCLIENT CLIENT%ROWTYPE;

BEGINOPEN CCLIENT;LOOP

FETCH CCLIENT INTO RCLIENT;EXIT WHEN CCLIENT%NOTFOUND;DBMS_OUTPUT.PUT_LINE(RCLIENT.FIRST_NAME);

END LOOP;CLOSE CCLIENT;

END;/

• Implicit cursor: declared automatically by PL/SQL– Automatically opened and closed by SQL or PL/SQL– Process INSERT, UPDATE, DELETE, and SELECT– A cursor FOR loop is a special type of implicit cursor

Page 7: Chapter 11

Oracle 10g Database Administrator: Implementation and Administration 7

What is a Cursor? (continued)

Page 8: Chapter 11

Oracle 10g Database Administrator: Implementation and Administration 8

Bulk Data Imports and Exports Using Data Pump

• Previously, export (exp) and import (imp) utilities were used to import/export data from a DB

• Data Pump export (expdp) and import (impdp) utilities are more versatile and much faster– Can be executed in parallel, failed/stopped jobs can

be restarted, metadata can be filtered out, etc.• Exporting/importing is allowed at all logical layers:

tables, schemas, groups of objects, or an entire DB– You export data and metadata– Database exports can be used to migrate and

upgrade between different versions of Oracle

Page 9: Chapter 11

Oracle 10g Database Administrator: Implementation and Administration 9

Bulk Data Imports and Exports Using Data Pump (continued)

Page 10: Chapter 11

Oracle 10g Database Administrator: Implementation and Administration 10

Bulk Data Loads with SQL*Loader

• SQL*Loader can perform magnificently in direct path, parallel mode, and using external tables– Direct path loads allow appending to tables

– Some situations will cause single tables and even entire SQL*Loader executions to execute using a conventional path load

• SQL*Loader is not limited to individual table loads– It can load into more than one table at once,

considering all constraints

• SQL*Loader can also perform fast direct loads with external tables

Page 11: Chapter 11

Oracle 10g Database Administrator: Implementation and Administration 11

Control File Datatypes• SQL*Loader has limited datatype set w/ commands

for handling different situations for each of them:– Strings: CHAR[(n)]

• DEFAULTIF col1=BLANKS• NULLIF col1=BLANKS

– Dates: DATE, TIME, TIMESTAMP, and INTERVALs– Numbers: externally or internally defined C/:

• EXTERNAL { INTEGER | FLOAT | DECIMAL } – DEFAULTIF col1=BLANKS– NULLIF col1=BLANKS

• Non EXTERNAL: INTEGER(n), SMALLINT, FLOAT, DOUBLE, BYTEINT, and DECIMAL(p,s)

Page 12: Chapter 11

Oracle 10g Database Administrator: Implementation and Administration 12

The Parameter File

• SQL*Loader can include a parameter file containing repeated settings, across multiple executions of SQL*LoaderUSERID = CLASSMATE/CLASSPASS@ORACLASSDISCARDMAX = 2ERRORS = 1000000

• To load your new client rows:sqlldr control=<path>\data\Chapter11\ch11.ctl log=<path>\data\

Chapter11\ch11.log parfile=<path>\data\Chapter11\ch11.par

• Some of the most likely uses of SQL*Loader are to bulk load large amounts of data into a data warehouse, or when importing data from outside, into an existing database