Chapter 11

371 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
371
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Chapter 11

  1. 1. CIT 4403 – Database Administration Oracle 10g Database Administrator: Implementation & Administration Chapter 11
  2. 2. Introduction to Advanced Data Management <ul><li>Advanced data management methods in Oracle </li></ul><ul><ul><li>Programming Language for SQL (PL/SQL) </li></ul></ul><ul><ul><ul><li>Allows construction of properly scripted intra-dependant SQL command structures </li></ul></ul></ul><ul><ul><li>Data pump technology </li></ul></ul><ul><ul><ul><li>Used to perform bulk loads and dumps into and out of an Oracle database </li></ul></ul></ul><ul><ul><li>SQL Loader </li></ul></ul><ul><ul><ul><li>Generally most efficient tool for mass data loading </li></ul></ul></ul><ul><ul><ul><li>Allows loading of OS flat files into table(s) at once </li></ul></ul></ul>
  3. 3. Named Blocks and Packages <ul><li>A named block is a chunk of code given a label, so that block of code can be stored in the database </li></ul><ul><ul><li>Is stored and can be recalled later and re-executed, without having to retype the entire block of code </li></ul></ul><ul><ul><li>Can be of various types with various restrictions: </li></ul></ul><ul><ul><ul><li>Procedure </li></ul></ul></ul><ul><ul><ul><li>Function </li></ul></ul></ul><ul><ul><ul><li>Trigger </li></ul></ul></ul><ul><ul><ul><li>Package </li></ul></ul></ul>
  4. 4. Triggers and Events Firing Triggers (continued)
  5. 5. What is a Cursor? <ul><li>What is a cursor? </li></ul><ul><ul><li>Temporary area (Work Area) in memory used to store the results of a query </li></ul></ul><ul><ul><li>Pointer to address in memory, a chunk of memory </li></ul></ul><ul><ul><li>SQL statement results are processed in cursors during execution </li></ul></ul><ul><ul><li>In PL/SQL, cursors can be created as programming structures for holding iterations of data </li></ul></ul><ul><ul><li>Can be used for queries returning one or many rows, and can be of two types, implicit and explicit cursors </li></ul></ul>
  6. 6. What is a Cursor? (continued) <ul><li>Explicit cursor: declared by the programmer </li></ul><ul><ul><li>Allows greater programming control </li></ul></ul><ul><ul><li>Cursor commands: OPEN, FETCH, and CLOSE </li></ul></ul><ul><ul><ul><li>DECLARE </li></ul></ul></ul><ul><ul><ul><li>CURSOR CCLIENT IS SELECT * FROM CLIENT; </li></ul></ul></ul><ul><ul><ul><li>RCLIENT CLIENT%ROWTYPE; </li></ul></ul></ul><ul><ul><ul><li>BEGIN </li></ul></ul></ul><ul><ul><ul><li>OPEN CCLIENT; </li></ul></ul></ul><ul><ul><ul><li>LOOP </li></ul></ul></ul><ul><ul><ul><li>FETCH CCLIENT INTO RCLIENT; </li></ul></ul></ul><ul><ul><ul><li>EXIT WHEN CCLIENT%NOTFOUND; </li></ul></ul></ul><ul><ul><ul><li>DBMS_OUTPUT.PUT_LINE(RCLIENT.FIRST_NAME); </li></ul></ul></ul><ul><ul><ul><li>END LOOP; </li></ul></ul></ul><ul><ul><ul><li>CLOSE CCLIENT; </li></ul></ul></ul><ul><ul><ul><li>END; </li></ul></ul></ul><ul><ul><ul><li>/ </li></ul></ul></ul><ul><li>Implicit cursor: declared automatically by PL/SQL </li></ul><ul><ul><li>Automatically opened and closed by SQL or PL/SQL </li></ul></ul><ul><ul><li>Process INSERT, UPDATE, DELETE, and SELECT </li></ul></ul><ul><ul><li>A cursor FOR loop is a special type of implicit cursor </li></ul></ul>
  7. 7. What is a Cursor? (continued)
  8. 8. Bulk Data Imports and Exports Using Data Pump <ul><li>Previously, export (exp) and import (imp) utilities were used to import/export data from a DB </li></ul><ul><li>Data Pump export (expdp) and import (impdp) utilities are more versatile and much faster </li></ul><ul><ul><li>Can be executed in parallel, failed/stopped jobs can be restarted, metadata can be filtered out, etc. </li></ul></ul><ul><li>Exporting/importing is allowed at all logical layers: tables, schemas, groups of objects, or an entire DB </li></ul><ul><ul><li>You export data and metadata </li></ul></ul><ul><ul><li>Database exports can be used to migrate and upgrade between different versions of Oracle </li></ul></ul>
  9. 9. Bulk Data Imports and Exports Using Data Pump (continued)
  10. 10. Bulk Data Loads with SQL*Loader <ul><li>SQL*Loader can perform magnificently in direct path, parallel mode, and using external tables </li></ul><ul><ul><li>Direct path loads allow appending to tables </li></ul></ul><ul><ul><li>Some situations will cause single tables and even entire SQL*Loader executions to execute using a conventional path load </li></ul></ul><ul><li>SQL*Loader is not limited to individual table loads </li></ul><ul><ul><li>It can load into more than one table at once, considering all constraints </li></ul></ul><ul><li>SQL*Loader can also perform fast direct loads with external tables </li></ul>
  11. 11. Control File Datatypes <ul><li>SQL*Loader has limited datatype set w/ commands for handling different situations for each of them: </li></ul><ul><ul><li>Strings: CHAR[(n)] </li></ul></ul><ul><ul><ul><li>DEFAULTIF col1=BLANKS </li></ul></ul></ul><ul><ul><ul><li>NULLIF col1=BLANKS </li></ul></ul></ul><ul><ul><li>Dates: DATE, TIME, TIMESTAMP, and INTERVALs </li></ul></ul><ul><ul><li>Numbers: externally or internally defined C/: </li></ul></ul><ul><ul><ul><li>EXTERNAL { INTEGER | FLOAT | DECIMAL } </li></ul></ul></ul><ul><ul><ul><ul><li>DEFAULTIF col1=BLANKS </li></ul></ul></ul></ul><ul><ul><ul><ul><li>NULLIF col1=BLANKS </li></ul></ul></ul></ul><ul><ul><ul><li>Non EXTERNAL: INTEGER(n), SMALLINT, FLOAT, DOUBLE, BYTEINT, and DECIMAL(p,s) </li></ul></ul></ul>
  12. 12. The Parameter File <ul><li>SQL*Loader can include a parameter file containing repeated settings, across multiple executions of SQL*Loader </li></ul><ul><ul><li>USERID = CLASSMATE/CLASSPASS@ORACLASS </li></ul></ul><ul><ul><li>DISCARDMAX = 2 </li></ul></ul><ul><ul><li>ERRORS = 1000000 </li></ul></ul><ul><li>To load your new client rows: </li></ul><ul><ul><li>sqlldr control=<path>dataChapter11ch11.ctl log=<path>dataChapter11ch11.log parfile=<path>dataChapter11ch11.par </li></ul></ul><ul><li>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 </li></ul>

×