ETL - Oracle Database Features and PL/SQL Techniques Boyan Boev CNsys BGOUG - 2005.

Slides:



Advertisements
Similar presentations
PL/SQL : Stop making the same performance mistakes
Advertisements

18 Copyright © Oracle Corporation, All rights reserved. Transporting Data Between Databases.
AN INTRODUCTION TO PL/SQL Mehdi Azarmi 1. Introduction PL/SQL is Oracle's procedural language extension to SQL, the non-procedural relational database.
PL/SQL. Introduction to PL/SQL PL/SQL is the procedure extension to Oracle SQL. It is used to access an Oracle database from various environments (e.g.
April 14, 2004 Next Information Systems 1 Bulk Collections and Inserts in Oracle 9i & 10g Simay Alpöge Next Information Systems, Inc.
SQL*PLUS, PLSQL and SQLLDR Ali Obaidi. SQL Advantages High level – Builds on relational algebra and calculus – Powerful operations – Enables automatic.
Loading & organising data. Objectives Loading data using direct-load insert Loading data into oracle tables using SQL*Loader conventional and direct paths.
9 Copyright © 2004, Oracle. All rights reserved. Managing Data.
Technical BI Project Lifecycle
Advanced Package Concepts. 2 home back first prev next last What Will I Learn? Write packages that use the overloading feature Write packages that use.
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
A Guide to SQL, Seventh Edition. Objectives Embed SQL commands in PL/SQL programs Retrieve single rows using embedded SQL Update a table using embedded.
Oracle PL/SQL Injection David Litchfield. What is PL/SQL? Procedural Language / Structured Query Language Oracle’s extension to standard SQL Programmable.
PL/SQL Bulk Collections in Oracle 9i and 10g Kent Crotty Burleson Consulting October 13, 2006.
ORACLE ONLINE TRAINING Contact our Support Team : SOFTNSOL India: Skype id : softnsoltrainings id:
Bordoloi and Bock CURSORS. Bordoloi and Bock CURSOR MANIPULATION To process an SQL statement, ORACLE needs to create an area of memory known as the context.
PL / SQL P rocedural L anguage / S tructured Q uery L anguage Chapter 7 in Lab Reference.
Agenda Journalling More Embedded SQL. Journalling.
Oracle10g Developer: PL/SQL Programming1 Objectives Manipulating data with cursors Managing errors with exception handlers Addressing exception-handling.
Oracle9 i JDeveloper for Database Developers and DBAs Brian Fry Principal Product Manager Oracle JDeveloper Oracle Corporation.
An Improved Approach to Generating Configuration Files from a Database Jon Finke Rensselaer Polytechnic Institute.
SAGE Computing Services Customised Oracle Training Workshops and Consulting Are you making the most of PL/SQL? Hints and tricks and things you may have.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
ISV Innovation Presented by ISV Innovation Presented by Business Intelligence Fundamentals: Data Loading Ola Ekdahl IT Mentors 9/12/08.
My experience building a custom ETL system Problems, solutions and Oracle quirks or How scary Oracle can look for a Java developer.
Oracle PL/SQL Programming Steven Feuerstein All About the (Amazing) Function Result Cache of Oracle Database 11g.
ETL There’s a New Sheriff in Town: Oracle OR… Not Just another Pretty Face Presented by: Bonnie O’Neil.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
Advanced PL/SQL and Oracle ETL Doug Cosman Senior Oracle DBA SageLogix, Inc. Open World 2003.
Lecture 4 PL/SQL language. PL/SQL – procedural SQL Allows combining procedural and SQL code PL/SQL code is compiled, including SQL commands PL/SQL code.
I Copyright © 2004, Oracle. All rights reserved. Introduction Copyright © 2004, Oracle. All rights reserved.
1 Definition of a subquery Nested subqueries Correlated subqueries The ISNULL function Derived tables The EXISTS operator Mixing data types: CAST & CONVERT.
Oracle PL/SQL Practices. Critical elements of PL/SQL Best Practices Build your development toolbox Unit test PL/SQL programs Optimize SQL in PL/SQL programs.
1 Chapter 14 DML Tuning. 2 DML Performance Fundamentals DML Performance is affected by: – Efficiency of WHERE clause – Amount of index maintenance – Referential.
Oracle Data Integrator Procedures, Advanced Workflows.
CERN - IT Department CH-1211 Genève 23 Switzerland t DB Development Tools Benthic SQL Developer Application Express WLCG Service Reliability.
6 Extraction, Transformation, and Loading (ETL) Transformation.
DAT 360: DTS in SQL Server 2000 Best Practices Euan Garden Group Manager, SQL Server Microsoft Corporation.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Outline Introduction to Oracle Memory Structures SGA, PGA, SCA The Specifics of the System Global Area (SGA) Structures Overview of Program Global Areas.
Commercial RDBMSs Access and Oracle. Access DBMS Architchecture  Can be used as a standalone system on a single PC: -JET Engine -Microsoft Data Engine.
School of Computing and Management Sciences © Sheffield Hallam University SQL is non-procedural –designed to be relatively approachable to non- programmers.
Dynamic SQL Oracle Database PL/SQL 10g Programming Chapter 13.
What is a Package? A package is an Oracle object, which holds other objects within it. Objects commonly held within a package are procedures, functions,
Objectives Database triggers and syntax
PL/SQLPL/SQL Oracle10g Developer: PL/SQL Programming Chapter 9 Database Triggers.
DAT 332 SQL Server 2000 Data Transformation Services (DTS) Best Practices Euan Garden Product Unit Manager SQL Server Development Microsoft Corporation.
D Copyright © Oracle Corporation, All rights reserved. Loading Data into a Database.
PL/SQLPL/SQL Oracle11g: PL/SQL Programming Chapter 4 Cursors and Exception Handling.
6 Copyright © 2009, Oracle. All rights reserved. Using the Data Transformation Operators.
1 Chapter 13 Parallel SQL. 2 Understanding Parallel SQL Enables a SQL statement to be: – Split into multiple threads – Each thread processed simultaneously.
Oracle11g: PL/SQL Programming Chapter 3 Handling Data in PL/SQL Blocks.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
Best Practices in Loading Large Datasets Asanka Padmakumara (BSc,MCTS) SQL Server Sri Lanka User Group Meeting Oct 2013.
 CONACT UC:  Magnific training   
CS422 Principles of Database Systems Stored Procedures and Triggers Chengyu Sun California State University, Los Angeles.
Preface IIntroduction Course Objectives I-2 Oracle Complete Solution I-3 Course Agenda I-4 Tables Used in This Course I-5 The Order Entry Schema I-6 The.
1 Copyright © 2004, Oracle. All rights reserved. PL/SQL Programming Concepts: Review.
6 Copyright © 2009, Oracle. All rights reserved. Using Dynamic SQL.
11 Copyright © 2009, Oracle. All rights reserved. Enhancing ETL Performance.
Tim Hall Oracle ACE Director
A Guide to SQL, Seventh Edition
PL/SQL MULTIPLE CHOICE QUESTION.
SQL Stored Triggers Presented by: Dr. Samir Tartir
Oracle11g: PL/SQL Programming Chapter 4 Cursors and Exception Handling.
Best Practices in PL/SQL
PL/SQL Scripting in Oracle:
Oracle9i Developer: PL/SQL Programming Chapter 8 Database Triggers.
MATERI PL/SQL Procedures Functions Packages Database Triggers
Prof. Arfaoui. COM390 Chapter 9
Presentation transcript:

ETL - Oracle Database Features and PL/SQL Techniques Boyan Boev CNsys BGOUG

Agenda ETL Concepts ETL Process Development - Recommendations –Oracle Database Configuration –PL/SQL Techniques –Database Features Conclusion BGOUG

What is ETL? ETL Elements ETL Purpose ETL as a Part of Business Intelligence Solution Types of ETL  Using Tools  Custom PL/SQL Scripts BGOUG

ETL – Extract, Transform and Load Extract  Pull the Data From the Source Transform  Convert the Input Format to the Target Format  Encode any Values Load  Insert the Transformed Data to the Target Tables BGOUG

Agenda ETL Concepts ETL Process Development - Recommendations –Oracle Database Configuration –PL/SQL Techniques –Database Features Conclusion BGOUG

Oracle database configuration Don’t use ARCHIVE LOG Mode  Reduce the Amount of I/O Activity Use NOLOGGING DML Statements ALTER TABLE … NOLOGGING; INSERT /*+ nologging*/ … Change the stage schema data model  Indexes  Constraints  Triggers BGOUG

Agenda ETL Concepts ETL Process Development - Recommendations –Oracle Database Configuration –PL/SQL Techniques –Database Features Conclusion BGOUG

ETL – recommendations PL/SQL Techniques  Bulk Binding  Collection Types  Pipelined Table Functions  Package Variables  Native Compilation BGOUG

PL/SQL – Binding Types of Binds  IN-Binds  OUT-Binds Bind Options  Single Row Binds  Bulk Binds BGOUG

Single Row Binds Cursor For Loop Example: BGOUG DECLARE CURSORexample_cursor( p_id_in NUMBER ) IS SELECT * FROM customer_action WHERE cust_id = p_id_in; v_cust_id NUMBER := 1681; BEGIN FOR rec INexample_cursor( v_cust_id ) LOOP INSERT INTO cust_action_hist(…) VALUES( … ); END LOOP; END; /

BGOUG Context Switching

BGOUG Bulk Binding IN-Binds  - An Array of Values is passed to SQL Engine OUT-Binds  - SQL Engine populates a PL/SQL Bind Array Context Switching once per Batch Instead of Once Per Row Performance Increase to Up to 15 Times

BGOUG Bulk Bind Operators Bulk Collect  Specifying of the LIMIT clause  Be Careful to handle last batch OPEN cursor … LOOP FETCH cursor BULK COLLECT INTO … LIMIT 100; EXIT WHEN cursor%NOTFOUND; END LOOP;

BGOUG Bulk Bind Operators FORALL  Bulk DML Operator  Not Looping Construct  PL/SQL table is Referenced in the statement  Handling and Reporting Exceptions  VALUES OF, INDICES OF ( New in Oracle 10g ) FORALL i IN INSERT INTO emp2 VALUES (enums(i), names(i), median(sals),...);

BGOUG Collection Types Associative Arrays( PL/SQL Tables )  PL/SQL type only - not a SQL Type  Easy to Use Nested Tables  Shared Type

BGOUG Associative Arrays( PL/SQL Tables ) automatic element allocation no need to initialize DECLARE TYPE EmpTabTyp IS TABLE OF employees%ROWTYPE INDEX BY PLS_INTEGER; emp_tab EmpTabTyp; BEGIN SELECT * BULK COLLECT INTO emp_tab FROM employees WHERE employee_id = 100; END; /

BGOUG Nested Tables PL/SQL  Example DECLARE TYPE nest_tab_t IS TABLE OF NUMBER; nt nest_tab_t := nest_tab_t(); BEGIN FOR i IN LOOP nt.EXTEND; nt(i) := i; END LOOP; END; /

BGOUG Nested Tables Global  Example CREATE OR REPLACE TYPE _demo_obj_t AS OBJECT ( _idNUMBER, demo_codeNUMBER, valueVARCHAR2(30) ); / CREATE OR REPLACE TYPE _demo_nt_t AS TABLE OF _demo_obj_t; /

BGOUG Nested Tables SQL-Defined Nested Tables  Sorted  Aggregated  Ised in Dynamic In-Lists  Joined with SQL Tables  Joined with other PL/SQL nested tables Nested Tables Enable Table Functions  TABLE Operator otell Oracle to treat the Variable like SQL Table  CAST Operator oExplicitly Tells Oracle the Data Type to be used to Handle the Operation -

BGOUG Nested Tables Global Nested tables – example: DECLARE eml_dmo_nt _demo_nt_t := _demo_nt_t(); BEGIN -- Some logic that populates the nested table … eml_dmo_nt.EXTEND(3); eml_dmo_nt(1) := _demo_obj_t(45, 3, '23'); eml_dmo_nt(2) := _demo_obj_t(22, 3, '41'); eml_dmo_nt(3) := _demo_obj_t(18, 7, 'over_100k'); -- Process the data in assending order of id. FOR r IN (SELECT * FROM TABLE(CAST(eml_dmo_nt AS _demo_nt_t)) ORDER BY 1) LOOP dbms_output.put_line(r. _id || ' ' || r.demo_id); END LOOP; END; /

BGOUG Table Functions Data is Buffered in the Local Variables During Function Execution Pipelined Table Functions –SELECT * FROM plsql_function;

BGOUG Pipelined Functions - example FUNCTION pipelined_demo( data SYS_REFCURSOR ) RETURN demo_nt_t PIPELINED IS CURSOR demo_cursor IS SELECT demo_obj_t(emp_id, value) FROM emp; emp_nt demo_nt_t; BEGIN OPEN _demo_cur; LOOP EXIT WHEN _demo_cur%NOTFOUND; FETCH _demo_cur BULK COLLECT INTO eml_dmo_nt LIMIT 1000; FOR i IN 1..eml_dmo_nt.COUNT LOOP /* Apply some business logic on the object here, and return a row. */ PIPE ROW (eml_dmo_nt(i)); END LOOP; RETURN; END;

BGOUG Package Variables What are Package Variables  Globally Declared Variables in Package, outside of a Procedure or Function Definition  Values set by Package Initialization Code  Enable Data Caching

BGOUG Native Compilation How it works?  PL/SQL First is Compiled Down To P-Code  C Source Code is Generated from P-Code  Native Compiler is invoked Creating a 'C' Shared Object Library  Subsequent Calls to PL/SQL Object are Run by the 'C' Library NComp and Performance

Agenda ETL Concepts ETL Process Development - Recommendations –Oracle Database Configuration –PL/SQL Techniques –Database Features Conclusion BGOUG

ETL – recommendations Database Features and Utilities  External Tables( 9i )  Transportable Tablespaces  DML Exception Handling( 10g R2 )  Regular Expressions Support( 10g R1 )  SQL*Loader  Direct Path INSERT  Parallel DML Statements BGOUG

Database Features External tables  File can be Queried as if it is a Real Database Table Can Sort, Aggregate, Filter Rows, etc.  External File Can be Queried in Parallel  Oracle 9i - Read-Only using SQL*Loader Engine  Only read-only access to external files  Oracle 10g - Read-Write using Data Pump Engine  Can do read/write operations with external files Transportable Tablespaces  Oracle 10g - transport across different platforms

BGOUG Database Features DML Exception Handling ( New in 10g R2 )  Catch the Error and Move On: Error Logging Clause  Enabling: SQL> exec dbms_errlog.CREATE_ERROR_LOG ('ACCOUNTS','ERR_ACCOUNTS'); SQL> insert into accounts select * from accounts_ny log errors into err_accounts reject limit 200; SQL> select ORA_ERR_NUMBER$, ORA_ERR_MESG$, ACC_NO from err_accounts;

BGOUG Database Features Regular Expression Support ( New in 10g R1 ) SQL*Loader Direct Path Insert  SQL*Loader  CREATE TABLE AS SELECT …  INSERT /*+ APPEND*/ … SELECT Parallel DML Statements

BGOUG Agenda ETL Concepts ETL Process Development - Recommendations –Oracle Database Configuration –PL/SQL Techniques –Database Features Conclusion

BGOUG Example create package with PIPELINED Function.... FUNCTION transform (new_data SYS_REFCURSOR) RETURN _demo_nt_t PIPELINED PARALLEL_ENABLE ( PARTITION new_data BY ANY ) IS.... Transformation is Just a Simple INSERT as SELECT  Elegant solution to Parallel, Transactional Co-Processing INSERT /*+ append nologging*/ INTO... SELECT /*+ parallel(a,4)*/ FROM.. TABLE( CAST( package.pipe_func_name( select * from table_3 ) as TYPE ) a);

BGOUG Conclusion High Perofmance ETL Solution

BGOUG Recommended Readings – Sites – tmlhttp:// tml – – – – –

BGOUG Recommended Readings – Books / /qid= /sr=2-1/ref=pd_bbs_b_2_1/ ?v=glance&s=books

BGOUG Recommended Readings – Books / /ref=pd_sim_b_1/ ?%5Fencoding=UTF8&v=glance

BGOUG Recommended Readings – Books / /qid= /sr=2- 2/ref=pd_bbs_b_2_2/ ?v=glance&s=books

BGOUG Questions or Comments Boyan Boev