Edition-Based Redefinition

Similar documents
Exploring Edition-Based Redefinition

<Insert Picture Here> Edition-based redefinition: the key to online application upgrade

Oracle In-Memory & Data Warehouse: The Perfect Combination?

Scripting OBIEE Is UDML and XML all you need?

Online Operations in Oracle 12.2

Creating and Managing Tables Schedule: Timing Topic

Application Containers an Introduction

Oracle Database 10g: Introduction to SQL

Application Containers an Introduction

Query Optimizer MySQL vs. PostgreSQL

Query Optimizer MySQL vs. PostgreSQL

Oracle Database New Performance Features

Application Containers an Introduction

5. Single-row function

Oracle PLSQL Training Syllabus

PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL)

ORACLE TRAINING. ORACLE Training Course syllabus ORACLE SQL ORACLE PLSQL. Oracle SQL Training Syllabus

Chapter 1 SQL and Data

You'll even like your Data Guard more with Flashback

Database Programming with PL/SQL

Oracle Database 12c: Program with PL/SQL Duration: 5 Days Method: Instructor-Led

Proje D2K. CMM (Capability Maturity Model) level Project Standard:- Corporate Trainer s Profile

UNIT-IV (Relational Database Language, PL/SQL)

Identifying Performance Problems in a Multitenant Environment

Oracle User Administration

ORACLE 12C NEW FEATURE. A Resource Guide NOV 1, 2016 TECHGOEASY.COM

Question: Which statement would you use to invoke a stored procedure in isql*plus?

Vendor: Oracle. Exam Code: 1Z Exam Name: Oracle Database 11g: Program with PL/ SQL. Version: Demo

SQL Interview Questions

Oracle Database: Program with PL/SQL

Designing for Performance: Database Related Worst Practices ITOUG Tech Day, 11 November 2016, Milano (I) Christian Antognini

Oracle Database: Introduction to SQL Ed 2

Oracle Developer Track Course Contents. Mr. Sandeep M Shinde. Oracle Application Techno-Functional Consultant

Oracle Database: Program with PL/SQL Ed 2

Oracle Database 12c R2: Program with PL/SQL Ed 2 Duration: 5 Days

Oracle Database: SQL and PL/SQL Fundamentals NEW

Conditionally control code flow (loops, control structures). Create stored procedures and functions.

Oracle Database: SQL and PL/SQL Fundamentals

Oracle Database 11g: Program with PL/SQL

Die Wundertüte DBMS_STATS: Überraschungen in der Praxis

Oracle Database: SQL and PL/SQL Fundamentals Ed 2

Oracle Exam 1z0-144 Oracle Database 11g: Program with PL/SQL Version: 8.5 [ Total Questions: 103 ]

Introduction to Computer Science and Business

Pitfalls & Surprises with DBMS_STATS: How to Solve Them


Oracle Database 18c New Performance Features

Introduction p. 1 The Logical and Physical View of Tables p. 1 Database Types p. 4 NULLs p. 6 DDL and DML Statements p. 7 Column and Table Constraint

Oracle Database 11g: SQL and PL/SQL Fundamentals

A Unit of SequelGate Innovative Technologies Pvt. Ltd. All Training Sessions are Completely Practical & Real-time

Oracle Database 11g: Program with PL/SQL Release 2

Oracle 1z z0-146 Oracle Database 11g: Advanced PL/SQL. Practice Test. Version QQ:

R12.2 Development and Deployment of Customizations

Oracle Database: Introduction to SQL

1Z0-144 Q&As Oracle Database 11g: Program with PL/ SQL

Object-Relational Mapping Tools let s talk to each other!

Oracle Database: Introduction to SQL

Lab # 2. Data Definition Language (DDL) Eng. Alaa O Shama

Real Application Security Administration

Database Rolling Upgrade with Transient Logical Standby Database DOAG Day High Availability Robert Bialek Principal Consultant

Oracle - Oracle Database: Program with PL/SQL Ed 2

Oracle Syllabus Course code-r10605 SQL

IT Certification Exams Provider! Weofferfreeupdateserviceforoneyear! h ps://

Lecture 08. Spring 2018 Borough of Manhattan Community College

Introduction to Oracle Objects

Misc. Triggers Views Roles Sequences - Synonyms. Eng. Mohammed Alokshiya. Islamic University of Gaza. Faculty of Engineering

ORACLE VIEWS ORACLE VIEWS. Techgoeasy.com

Oracle 1Z Oracle9i: Program with PL/SQL. Download Full Version :

ORACLE APPLICATIONS R12.2, EBR, ONLINE PATCHING - MEANS LOT OF WORK FOR DEVELOPERS. Ajith Narayanan 25 th Feb 2015, Bangalore, India

ORACLE DATABASE 12C INTRODUCTION

DATA AND SCHEMA MODIFICATIONS CHAPTERS 4,5 (6/E) CHAPTER 8 (5/E)

Oracle Database: Introduction to SQL

Sqlplus To Create The Plan_table In Your Schema

Analytic Views: Use Cases in Data Warehouse. Dani Schnider, Trivadis AG DOAG Conference, 21 November 2017

Review -Chapter 4. Review -Chapter 5

Oracle Database 12c: New Features for Administrators Duration: 5 Days

Oracle Database 12c SQL Fundamentals

Oracle PL SQL Training & Certification

SQL is an English like language consisting of commands to store, retrieve, maintain & regulate access to your database.

Lab # 4. Data Definition Language (DDL)

PL/SQL MOCK TEST PL/SQL MOCK TEST IV

Get Groovy with ODI Trivadis

Oracle Database 11g & PL/SQL

Chapter 2. DB2 concepts

Oracle Database: Introduction to SQL/PLSQL Accelerated

PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL)

Edition-Based Redefinition

Database Sharding with Oracle RDBMS

1 Prepared By Heena Patel (Asst. Prof)

DumpsKing. Latest exam dumps & reliable dumps VCE & valid certification king

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine.

Domain Services Clusters Centralized Management & Storage for an Oracle Cluster Environment Markus Flechtner

ASSIGNMENT NO 2. Objectives: To understand and demonstrate DDL statements on various SQL objects

SQL+PL/SQL. Introduction to SQL

Where are we? Week -4: Data definition (Creation of the schema) Week -3: Data definition (Triggers) Week -1: Transactions and concurrency in ORACLE.

Installation Guide. Version Last updated: November. tryfoexnow.com 1 of 3

Overview. Data Integrity. Three basic types of data integrity. Integrity implementation and enforcement. Database constraints Transaction Trigger

Basant Group of Institution

Security Benefits of Implementing Database Vault. -Arpita Ghatak

Actual4Test. Actual4test - actual test exam dumps-pass for IT exams

IZ0-144Oracle 11g PL/SQL Certification (OCA) training

Transcription:

Edition-Based Redefinition Janina Patolla Trivadis AG, Basel Basel Baden Bern Brugg Lausanne Zurich Düsseldorf Frankfurt/M. Freiburg i. Br. Hamburg Munich Stuttgart Vienna

Introduction Upgrading critical applications can be very difficult. Problems: long downtimes cannot be scheduled periodically For such applications we'd prefer online upgrades. Up to Oracle 11g Release 1 no real support With Oracle 11g Release 2 and Edition-based Redefinition, real support for implementing online upgrades. Oracle Database New Features 11g for Developers Edition Based Redefinition 2

Agenda Editions Editioned Objects Editioning Views Data are always part of the game. Crossedition Triggers Limitations Oracle Database New Features 11g for Developers Edition Based Redefinition 3

Concept As of Oracle Database 11g Release 2 an object is identified by: its name the user (schema) it belongs to nothing new so far its EDITION The aim of the edition support several copies (editions) of a given object Objects with several copies editioned objects. Objects that cannot have several copies noneditioned objects, have no edition. In data dictionary, edition is set to NULL. Oracle Database New Features 11g for Developers Edition Based Redefinition 4

@ Online Upgrade Using Editions EMAIL May.Ling@xx.com Tom.Kerr@xx.com Ina.Ries@ght.de RECIPIENT May.Ling Tom.Kerr Ina.Ries DOMAIN xx.com xx.com ght.de PERSONS_TAB HR_PKG PERSONS Ora$Base PERS_PKG HR_PKG PERS_PKG PERSONS FCT RCT Edi_1 Oracle Database New Features 11g for Developers Edition Based Redefinition 5

Editionable Object Types Editionable object types FUNCTION LIBRARY PACKAGE and PACKAGE BODY PROCEDURE SYNONYM TRIGGER TYPE and TYPE BODY VIEW Noneditionable object types do not support editions TABLE PUBLIC SYNONYM Oracle Database New Features 11g for Developers Edition Based Redefinition 6

Enabling Editions for a User Editioned objects can only be owned by users that have been explicitly enabled to do so. SQL> ALTER USER cha ENABLE EDITIONS; The operation of enabling a user to create editioned objects is irreversible! Oracle Database New Features 11g for Developers Edition Based Redefinition 7

Creating Editions (1) Every database must have at least one edition. A database supports several editions organized as a "hierarchy" with one root edition (by default ORA$BASE) and a parent-child relationship between every other edition. ORA$BASE REL1 REL2 REL3 The CREATE EDITION statement is used to create an edition. It requires the CREATE ANY EDITION system privilege. SQL> CREATE EDITION rel1 AS CHILD OF ora$base; SQL> CREATE EDITION rel2 AS CHILD OF rel1; SQL> CREATE EDITION rel3 AS CHILD OF rel2; Oracle Database New Features 11g for Developers Edition Based Redefinition 8

Creating Editions (2) Default: new edition can only be used by the user who created it by SYS. Grant USE ON EDITION privilege for other users SQL> GRANT USE ON EDITION rel2 TO cha; SQL> GRANT USE ON EDITION rel3 TO PUBLIC; Oracle Database New Features 11g for Developers Edition Based Redefinition 9

Selecting Editions Specify session edition when connection is created, APIs (e.g. OCI and JDBC) tools (e.g. SQL*Plus and Data Pump) Property DEFAULT_EDITION specifies session default By default, the property is set to ORA$BASE. Session edition can also be modified ALTER SESSION statement SQL> ALTER SESSION SET EDITION = rel1; May be used with ON-LOGON Triggers Oracle Database New Features 11g for Developers Edition Based Redefinition 10

Dropping Editions The DROP EDITION is used to drop an edition. It requires the DROP ANY EDITION system privilege. In addition, the following conditions must be met: The edition is not the latest database edition. The edition is not the default database edition. The edition is not in use as session edition. The edition is either the root or the leaf of the hierarchy. If the edition is the leaf of the hierarchy and it still has associated objects, the CASCADE option must be specified. If the edition is the root of the hierarchy, the child edition must not inherit objects from the root edition. Dropping an edition that is no longer used is optional. Oracle Database New Features 11g for Developers Edition Based Redefinition 11

Agenda Editions Editioned Objects Editioning Views Data are always part of the game. Crossedition Triggers Limitations Oracle Database New Features 11g for Developers Edition Based Redefinition 12

Creating Editioned Objects Editioned objects are created like any other object. Set edition before creating object SQL> ALTER SESSION SET EDITION = rel1; SQL> CREATE OR REPLACE PROCEDURE hello IS 2 BEGIN 3 dbms_output.put_line('hello from REL1'); 4 END; 5 / Enabling editions for a user with existing object: objects are associated with the root edition Oracle Database New Features 11g for Developers Edition Based Redefinition 13

Redefining Editioned Objects (1) The typical steps that are carried out to redefine editioned objects are the following. Create a new edition and set it as session edition. Redefine the editioned objects and ensure that all objects are valid. Check whether the application works as expected with the new edition. Permanently switch to the new edition. Oracle Database New Features 11g for Developers Edition Based Redefinition 14

Redefining Editioned Objects (2) When a new edition is created, all objects that are associated with the parent edition are inherited by the child edition. objects not associated with the child edition only made visible to the child edition. To redefine editioned objects, select the new edition alter, add, drop or recompile editioned object (DDL statements) SQL> ALTER SESSION SET EDITION = rel2; SQL> CREATE OR REPLACE PROCEDURE hello IS 2 BEGIN 3 dbms_output.put_line('hello from REL2'); 4 END; 5 / Oracle Database New Features 11g for Developers Edition Based Redefinition 15

Agenda Editions Editioned Objects Editioning Views Data are always part of the game. Crossedition Triggers Limitations Oracle Database New Features 11g for Developers Edition Based Redefinition 16

Editioning Views (1) Tables are not editionable. If data is part of revisioning, every table should be covered with an editioning view in the application all references to tables are replaced with references to editioning views. An editioning views is a regular view with a few special characteristics: It only supports projections (no restrictions, joins, aggregations, ). It supports DML triggers. It does not support INSTEAD OF triggers. Oracle Database New Features 11g for Developers Edition Based Redefinition 17

Editioning Views (2) To create an editioning view, use EDITIONING keyword in the CREATE VIEW statement. SQL> DESCRIBE persons Name Null? Type ----------------------- -------- ---------------- ID NOT NULL NUMBER(10) FIRST_NAME NOT NULL VARCHAR2(100) LAST_NAME NOT NULL VARCHAR2(100) EMAIL NOT NULL VARCHAR2(100) SQL> RENAME persons TO persons_tab; SQL> CREATE EDITIONING VIEW persons AS 2 SELECT id, first_name AS firstname, 3 last_name AS lastname, email 4 FROM persons_tab; Oracle Database New Features 11g for Developers Edition Based Redefinition 18

Agenda Editions Editioned Objects Editioning Views Data are always part of the game. Crossedition Triggers Limitations Oracle Database New Features 11g for Developers Edition Based Redefinition 19

Crossedition Triggers (1) During upgrade, editioning views may be set in read-only editioned views based on tables that have to be redefined should be set in read-only mode. Whenever possible If setting editioned views to read-only is not an option, crossedition triggers have to be used Oracle Database New Features 11g for Developers Edition Based Redefinition 20

Forward Crossedition Triggers (1) Forward crossedition trigger transform a row from the old structure into the new structure Forward crossedition trigger is created in the new edition The old one should never be modified Fires when a DML statement is executed by a session using an ancestor edition of the trigger edition Forward crossedition trigger are explicitly defined specifying the FORWARD CROSSEDITION clause Oracle Database New Features 11g for Developers Edition Based Redefinition 21

Forward Crossedition Triggers (2) SQL> ALTER TABLE persons_tab ADD ( 2 email_recipient VARCHAR2(100), 3 email_domain VARCHAR2(100) 4 ); SQL> CREATE TRIGGER persons_fc_trg 2 BEFORE INSERT OR UPDATE ON persons_tab FOR EACH ROW 3 FORWARD CROSSEDITION 4 DISABLE 5 BEGIN 6 :new.email_recipient := 7 regexp_substr(:new.email,'(.*)@',1,1,null,1); 8 :new.email_domain := 9 regexp_substr(:new.email,'@(.*)',1,1,null,1); 10 END; 11 / Oracle Database New Features 11g for Developers Edition Based Redefinition 22

Forward Crossedition Triggers (3) Data Migration The data already stored in the redefined table has to be converted in the new structure as well. Idea: fire the trigger for every row already stored in the table Reuse logic Performance? DBMS_SQL.PARSE function for trigger application To avoid an inconsistent state: Enable the forward edition trigger. Wait for every transaction on the redefined table to be committed or rolled back (use DBMS_UTILITY.WAIT_ON_PENDING_DML). Start a PL/SQL block that fires the trigger for every row. Oracle Database New Features 11g for Developers Edition Based Redefinition 23

Forward Crossedition Triggers (4) Data Migration SQL> DECLARE 2 c INTEGER; 3 r INTEGER; 4 BEGIN 5 c := dbms_sql.open_cursor; 6 dbms_sql.parse( 7 c => c, 8 statement => 'UPDATE persons' 9 'SET email_domain = email_domain', 10 language_flag => dbms_sql.native, 11 apply_crossedition_trigger => 'persons_fc_trg' 12 ); 13 r := dbms_sql.execute(c); 14 dbms_sql.close_cursor(c); 15 COMMIT; 16 END; 17 / Oracle Database New Features 11g for Developers Edition Based Redefinition 24

Reverse Crossedition Triggers (1) Reverse crossedition trigger are used when old and new edition are used concurrently Reverse crossedition trigger transforms a row from new structure to old structure. Reverse crossedition trigger is created in new edition and fires when a DML statement is executed by a session using the trigger edition(or a descendent) Reverse crossedition trigger are explicitly defined specifying the REVERSE CROSSEDITION clause. Oracle Database New Features 11g for Developers Edition Based Redefinition 25

Reverse Crossedition Triggers (2) SQL> CREATE TRIGGER persons_rc_trg 2 BEFORE INSERT OR UPDATE ON persons_tab FOR EACH ROW 3 REVERSE CROSSEDITION 4 DISABLE 5 BEGIN 6 :new.email := :new.email_recipient 7 '@' 8 :new.email_domain; 9 END; 10 / Oracle Database New Features 11g for Developers Edition Based Redefinition 26

@ Online Upgrade Final Steps EMAIL May.Ling@xx.com Tom.Kerr@xx.com Ina.Ries@ght.de RECIPIENT May.Ling Tom.Kerr Ina.Ries DOMAIN xx.com xx.com ght.de PERSONS_TAB HR_PKG PERSONS Ora$Base PERS_PKG HR_PKG PERS_PKG PERSONS FCT RCT Edi_1 Oracle Database New Features 11g for Developers Edition Based Redefinition 27

Agenda Editions Editioned Objects Editioning Views Data are always part of the game. Crossedition Triggers Limitations Oracle Database New Features 11g for Developers Edition Based Redefinition 28

Limitations There are two important implementation limitations related to the hierarchies that can be built with editions: Every edition can have at most one child. Every database has one, and only one, root edition. VER11 CRM10 CRM11 CRM12 ORA$BASE VER10 VER20 HR1 HR2 HR3 The possibility of tying the default edition to a database service is not available. Indexes and constraints can only be created on tables. Hence, there is no way to take advantage of editions with them. Oracle Database New Features 11g for Developers Edition Based Redefinition 29

Edition-Based Redefinition Core Messages Data are always part of the game. Edition-based redefinition provides completely new features that make online upgrades possible. The complexity of such upgrades should not be underestimated. Oracle Database New Features 11g for Developers Edition Based Redefinition 30