SlideShare a Scribd company logo
dbi services
Edition Based Redefinition




                           Jérôme Witt
                           Consultant - Oracle Certified Professional 11g
                           Mobile +41 79 961 27 73
                           jerome.witt@dbi-services.com
                           www.dbi-services.com




1   www.dbi-services.com                                08.11.2012 © dbi services
Edition Based Redefinition
Agenda



                  Agenda
                  i.       Introduction
                  ii.      Concept
                  iii.     Basics
                  iv.      Redefining objects
                  v.       Advanced functionalities
                  vi.      Limits




2   www.dbi-services.com                              08.11.2012 © dbi services
Edition Based Redefinition
Introduction

 Upgrading applications can be difficult
 Short or long downtimes can not be scheduled
 Implementation of online upgrades are desirable


 As of Oracle Database 11gR2 with Oracle Edition
  Based Redefinition (aka. EBR) online application
  upgrades are now supported


 Announced as “the killer feature” at the OOW 2009



3    www.dbi-services.com                   08.11.2012 © dbi services
Edition Based Redefinition
       Introduction


                             • Creation of new objects
Application upgrade




                             • Changing objects
                                (alter and create or replace)


                             • Drop redundant objects                      Downtime


                                                                             EBR
                             • Convert or migrate data


                             • Resume normal operations

       4              www.dbi-services.com                      08.11.2012 © dbi services
Edition Based Redefinition
Agenda



                  Agenda
                  i.       Introduction
                  ii.      Concept
                  iii.     Basics
                  iv.      Redefining objects
                  v.       Advanced functionalities
                  vi.      Limits




5   www.dbi-services.com                              08.11.2012 © dbi services
Edition Based Redefinition
Concept(1)

 As of Oracle 11gR2 an object is identified by
     His name and the schema it belongs to
     And now also to an EDITION
       SQL> desc DBA_OBJECTS
        Name                  Null?    Type
        ------------------ -------- ----------------
        . . .
        EDITION_NAME                     VARCHAR2(30)


 Allows to support several copies of an object
     Objects which might have copies are called “editioned objects”
 All other objects are “non editionable”


6     www.dbi-services.com                         08.11.2012 © dbi services
Edition Based Redefinition
Concept (2)

 Which objects are “editionable” ?
      SYNONYM              All PL/SQL objects
      VIEW                    PACKAGE and PACKAGE BODY
                               PROCEDURE
                               FUNCTION
                               LIBRARY
                               TRIGGER
                               TYPE and TYPE BODY




 A non-editonable object cannot depend on an
  editonable object


7   www.dbi-services.com                 08.11.2012 © dbi services
Edition Based Redefinition
Concept(3)

 Editions are organized hierarchically «parent-child»

    ORA$BASE                  ED1      ED2                 ED3

                        • OBJ_1                      • OBJ_1
                        • OBJ_2     • OBJ_2
                        • OBJ_3                      • OBJ_3


                              ED2




8      www.dbi-services.com                   08.11.2012 © dbi services
Edition Based Redefinition
Concept(4)

 Editions are organized hierarchically «parent-child»

    ORA$BASE                  ED1                 ED2                ED3

                        • OBJ_1                                • OBJ_1
                        • OBJ_2           • OBJ_2
                        • OBJ_3                                • OBJ_3



 Inheritance
      When an edition is created all objects associated with the parent
       are inherited by the child. They become «inherited»
      Objects re-created or altered in an edition become “actualized”
       (i.e. objects OBJ_2 & OBJ_3 of the edition ED3)
      Inherited & actual objects are “visible”
9      www.dbi-services.com                             08.11.2012 © dbi services
Edition Based Redefinition
Agenda



                   Agenda
                   i.       Introduction
                   ii.      Concept
                   iii.     Basics
                   iv.      Redefining objects
                   v.       Advanced functionalities
                   vi.      Limits




10   www.dbi-services.com                              08.11.2012 © dbi services
Edition Based Redefinition
Basics (1)

 Creating editions
      Database default edition «ORA$BASE»
          Database creation or upgrade to Oracle 11.2
          Has no actual editioned objects
     SQL> CREATE EDITION <ed_name> {AS CHILD OF ora$base};


 Enabling editions
     SQL> ALTER USER <schema> ENABLE EDITIONS {FORCE};
      Editioned objects can only be owned by schemas that have
       been explicitly enabled
      FORCE if schema has potentially editionable objects
      By the way DISABLE EDTIONS doesn’t exists !

11     www.dbi-services.com                              08.11.2012 © dbi services
Edition Based Redefinition
Basics (2)

 Granting editions
     SQL> GRANT USE ON EDITION <ed_name> TO <schema>;


 Selecting editions
     SQL> ALTER SESSION SET EDITION =<ed_name>;


 Retrieving current and session edition
     SQL> SHOW EDITION;

     SQL> SELECT
           SYS_CONTEXT('USERENV', 'CURRENT_EDITION_NAME'),
           SYS_CONTEXT('USERENV', 'SESSION_EDITION_NAME')
        FROM dual;

12     www.dbi-services.com                   08.11.2012 © dbi services
Edition Based Redefinition
Basics (3)

 Enabling an edition database wide
     SQL> ALTER DATABASE DEFAULT EDITION=<ed_name>;

     SQL> SELECT property_value FROM database_properties
          WHERE property_name = 'DEFAULT_EDITION';

 Selecting edition at connection time
     DBMS_SERVICE.CREATE_SERVICE(
        service_name => '<ORACLE_SID.DB_DOMAIN>',
        . . .
        edition       => '<ed_name>');

 EBR integrated with
      Oracle Call Interface        JDBC
      Oracle Restart (srvctl)
13     www.dbi-services.com                   08.11.2012 © dbi services
Edition Based Redefinition
Basics (4)

 Display all database editions
      Views {DBA|ALL}_EDITIONS


 Display all objects editions
      Views {DBA|ALL|USER}_OBJECTS_AE


 View current edition from an object
      Views {DBA|ALL|USER}_OBJECTS.EDITION_NAME




 And so on …

14    www.dbi-services.com                 08.11.2012 © dbi services
Edition Based Redefinition
Agenda



                   Agenda
                   i.       Introduction
                   ii.      Concept
                   iii.     Basics
                   iv.      Redefining objects
                   v.       Advanced functionalities
                   vi.      Limits




15   www.dbi-services.com                              08.11.2012 © dbi services
Edition Based Redefinition
Redefining objects(1)




     SQL> BEGIN
            raiseSalary(
                p_title_in   => 'COM_DBISERVICES . . . ',
                p_rate_in    => 1.10,
                p_max_sal_in => 50000 );
          END;
     /

16    www.dbi-services.com                   08.11.2012 © dbi services
Edition Based Redefinition
 Redefining objects(2)

PROCEDURE raiseSalary(. . .) IS
  . . .
  CURSOR cur_emp IS SELECT * FROM EMPLOYEES FOR UPDATE;
BEGIN
  OPEN cur_emp;
  LOOP
     FETCH cur_emp INTO rec_emp;
     . . .
     SELECT upper(job_title) INTO v_cur_title FROM hr.jobs
         WHERE job_id = rec_emp.job_id;
     IF v_cur_title = v_title_in
         AND rec_emp.salary*p_rate_in <= p_max_sal_in
    THEN
       -- Do some other checks on employee
       UPDATE . . .
     END IF;
  END LOOP;
  CLOSE cur_emp;
  COMMIT;
END;
 17    www.dbi-services.com                        08.11.2012 © dbi services
Edition Based Redefinition
 Redefining objects(3)

PROCEDURE raiseSalary(. . .) IS
  . . .
  CURSOR cur_emp IS
    SELECT e.employee_id from hr.employees e, hr.jobs j
    WHERE e.job_id = j.job_id AND upper(j.job_title) = v_title_in
    AND e.salary*p_rate_in <= p_max_sal_in;
BEGIN
  OPEN cur_emp;
  LOOP
    FETCH cur_emp BULK COLLECT INTO v_empid_list LIMIT 1000;
    EXIT WHEN v_empid_list.COUNT = 0;

      -- Do some other checks on employee
      FORALL i IN v_empid_list.FIRST .. v_empid_list.LAST
        UPDATE hr.employees SET salary=salary*p_rate_in
          WHERE employee_id=v_empid_list(i);

  END LOOP;
  CLOSE cur_emp; COMMIT;
END;
 18      www.dbi-services.com                       08.11.2012 © dbi services
Edition Based Redefinition
Redefining objects(3)

 Typical EBR redefinition steps
     1. Create the new edition
     2. Set the edition as session edition
     3. Redefine the objects
     4. Permanently switch to the new edition


 To “redefine” objects it’s necessary to select the new
  edition and either re-compile or recreate objects


 Consider application roll out strategy



19     www.dbi-services.com                     08.11.2012 © dbi services
Edition Based Redefinition
Redefining objects(4)




20   www.dbi-services.com    08.11.2012 © dbi services
Edition Based Redefinition
Agenda



                   Agenda
                   i.       Introduction
                   ii.      Concept
                   iii.     Basics
                   iv.      Redefining objects
                   v.       Advanced functionalities
                   vi.      Limits




21   www.dbi-services.com                              08.11.2012 © dbi services
Edition Based Redefinition
Advanced functionalities(1)

 Views
      Editionable (of course)
      Support only INSTEAD OF triggers


 Editioning views
      Selects a subset of the columns from a single base table
      Optionally, provide aliases for columns
      Doesn’t support indexes nor constraints
      No performance penalty for accessing base table
      Support any type of triggers
       (especially CROSSEDITION TRIGGERS)
     SQL> CREATE EDITIONING VIEW <name> AS SELECT ...;

22     www.dbi-services.com                        08.11.2012 © dbi services
Edition Based Redefinition
Advanced functionalities(2)

 Crossedition triggers
      Propagate data changes made by the old edition into the new
       edition’s columns, or vice-versa.
      From type FORWARD or REVERSE
      They are temporary!

     SQL> CREATE OR REPLACE TRIGGER <trigger_name>
       BEFORE INSERT OR UPDATE ON <table_name>
       FOR EACH ROW
       FORWARD CROSSEDITION
       DISABLE
     BEGIN
     . . .
     END <trigger_name>;
     /

23     www.dbi-services.com                       08.11.2012 © dbi services
Edition Based Redefinition
Advanced functionalities(3)


                              New Edition : ED_V1
          C_Pool
          ED_V1                    EMPLOYEES
                              First     Last    Phone
                              Name     Name      Nbr




                                 EMPLOYEES_TAB
                                   EMPLOYEES
                               First    Last    Phone
                               Name    Name      Nbr


24   www.dbi-services.com                 08.11.2012 © dbi services
Edition Based Redefinition
Advanced functionalities(4)


                                                  ED_V2
                                    New Edition : ED_V1
          C_Pool
          ED_V1                          EMPLOYEES
                                        EMPLOYEES
                            First     First Phone
                                     Last     Last    Phone
                                                     Dial   Int
                            Name     Name
                                    Name     Name
                                             Nbr       Nbr PhNbr
                                                     Code


                               FWD_TRG

                               REV_TRG

                                       EMPLOYEES_TAB
                                      EMPLOYEES_TAB
                            First      First Phone
                                     Last       Last Phone Int
                                                     Dial
                            Name      Name Nbr
                                    Name       Name Code
                                                       Nbr PhNbr


25   www.dbi-services.com                       08.11.2012 © dbi services
Edition Based Redefinition
Advanced functionalities(5)


                                    New Edition : ED_V2
          C_Pool
          ED_V1                         EMPLOYEES
                            First    Last   Phone    Dial        Int
                            Name    Name     Nbr     Code       PhNbr


                               FWD_TRG

                               REV_TRG

                                      EMPLOYEES_TAB
          C_Pool
          ED_V2             First    Last   Phone    Dial        Int
                            Name    Name     Nbr     Code       PhNbr


26   www.dbi-services.com                       08.11.2012 © dbi services
Edition Based Redefinition
Advanced functionalities(2)

 Hot roll-over “bulk forward”
      Wait for pending DMLs
     DBMS_UTILITY.WAIT_ON_PENDING_DML(
                 tables => '<Base_Table>',
                 timeout => timeout,
                 scn => scn
             );

      Apply transformation
      DBMS_SQL.PARSE(
        c                          =>   c,
        Language_Flag              =>   DBMS_SQL.NATIVE,
        Statement=> 'UPDATE employees   SET ID = ID',
        Apply_Crossedition_Trigger =>   '<CRED_TRG_FWD>'
       );

27     www.dbi-services.com                    08.11.2012 © dbi services
Edition Based Redefinition
Agenda



                   Agenda
                   i.       Introduction
                   ii.      Concept
                   iii.     Basics
                   iv.      Redefining objects
                   v.       Advanced functionalities
                   vi.      Limits




28   www.dbi-services.com                              08.11.2012 © dbi services
Edition Based Redefinition
Limits

 Performance & Tuning
      Indexes & constraints must be added to the base table
      To limit negative performance impact specify an INDEX hint
       within the crossedition triggers
      Editioning views accept SQL optimizer hints
          Logical column names must be mapped to an index on the
           corresponding physical column in the base table
     SQL> SELECT /*+ INDEX (edview1 idx1)*/ email
            FROM edview1 WHERE last_name='King';


 Can not drop retired editions!
      Bugs (11.2.0.3) – do not drop edition ORA$BASE
 One of the least known Oracle database feature
29     www.dbi-services.com                           08.11.2012 © dbi services
dbi services
Any Questions? Please Do Ask!




                            Jérôme Witt
                            Consultant - Oracle Certified Professional 11g
                            Mobile +41 79 961 27 73
                            jerome.witt@dbi-services.com
                            www.dbi-services.com


         „We look forward to working with you!“


30   www.dbi-services.com                                08.11.2012 © dbi services

More Related Content

ODP
Java EE and Glassfish
PDF
Java EE 7 overview
PDF
Unit 06: The Web Application Extension for UML
PDF
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Aries
PPTX
Hibernate in Action
PPTX
LeverX SAP 7.02 Navigation Essentials
PDF
Unit 05: Physical Architecture Design
PPTX
[JSS2015] Eradiction des deadlocks
Java EE and Glassfish
Java EE 7 overview
Unit 06: The Web Application Extension for UML
OSGi Community Event 2010 - Enterprise OSGi in WebSphere and Apache Aries
Hibernate in Action
LeverX SAP 7.02 Navigation Essentials
Unit 05: Physical Architecture Design
[JSS2015] Eradiction des deadlocks

Viewers also liked (16)

PPTX
High performance jss 2012
PPTX
JSS2013 : Hekaton
PPTX
[JSS2015] In memory and operational analytics
PPTX
Datit207 scénarios hybrides entre sql server et windows azure
PPTX
PPTX
[JSS2015] - Document db et nosql
PPTX
Serveurs core et virtualisation
PPTX
Jss2014 performance counters and dmvs
PPTX
JSS2013 : Haute disponibilité
PPTX
Haute disponibilité jss2012
PDF
SQL Server 2008 'Best Practices' - Stéphane Haby, dbi services - Mövenpick La...
PPTX
JSS2013 : Statistiques
PPTX
Always on les solutions de haute disponibilité avec sql server 2012 (dat302)
PPTX
[JSS2015] Nouveautés SQL Server 2016:Sécurité,Temporal & Stretch Tables
PDF
How to Make Awesome SlideShares: Tips & Tricks
PDF
Getting Started With SlideShare
High performance jss 2012
JSS2013 : Hekaton
[JSS2015] In memory and operational analytics
Datit207 scénarios hybrides entre sql server et windows azure
[JSS2015] - Document db et nosql
Serveurs core et virtualisation
Jss2014 performance counters and dmvs
JSS2013 : Haute disponibilité
Haute disponibilité jss2012
SQL Server 2008 'Best Practices' - Stéphane Haby, dbi services - Mövenpick La...
JSS2013 : Statistiques
Always on les solutions de haute disponibilité avec sql server 2012 (dat302)
[JSS2015] Nouveautés SQL Server 2016:Sécurité,Temporal & Stretch Tables
How to Make Awesome SlideShares: Tips & Tricks
Getting Started With SlideShare
Ad

Similar to Tune my Code! Code-Versionen testen via Edition-Based Redef. - Jérôme Witt, dbi services (20)

PDF
Presentation online application upgrade of oracle's bug db with edition-ba...
PDF
Editioning use in ebs
PDF
Editioning use in ebs
PDF
EDITION & TARGET EDITION & Edition-Based Redefinition (EBR) in Oracle
PDF
King_EditionBasedRedefinition_oracle12c.pdf
PPTX
Edition based redefinition joords
PDF
How to upgrade your application with no downtime (using edition-based redefin...
PPTX
Oracle11g R2 - Edition Based Redefinition for On Line Application Upgrade
PDF
Edition Based Redefinition Made Easy - Oren Nakdimon
PDF
Basic - Oracle Edition Based Redefinition Presentation
 
PPTX
Edition based redefinition joords
PDF
Ebr the key_to_online_application_upgrade at amis25
PPTX
Edition Based Redefinition
PDF
Whats new in_postgres_enterprise_db_20130124
 
PPTX
Oracle applications r12.2, ebr, online patching means lot of work for devel...
PPTX
Edition Based Redefinition - Continuous Database Application Evolution with O...
PPTX
Introducing and Demonstrating Oracle Database 11gR2's Killer Feature – Editio...
PDF
SQL Server 2012 : réussir la migration - Stéphane Haby - Antonio De Santo - d...
PPTX
Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefiniti...
PDF
DBI Advanced Tutorial 2007
Presentation online application upgrade of oracle's bug db with edition-ba...
Editioning use in ebs
Editioning use in ebs
EDITION & TARGET EDITION & Edition-Based Redefinition (EBR) in Oracle
King_EditionBasedRedefinition_oracle12c.pdf
Edition based redefinition joords
How to upgrade your application with no downtime (using edition-based redefin...
Oracle11g R2 - Edition Based Redefinition for On Line Application Upgrade
Edition Based Redefinition Made Easy - Oren Nakdimon
Basic - Oracle Edition Based Redefinition Presentation
 
Edition based redefinition joords
Ebr the key_to_online_application_upgrade at amis25
Edition Based Redefinition
Whats new in_postgres_enterprise_db_20130124
 
Oracle applications r12.2, ebr, online patching means lot of work for devel...
Edition Based Redefinition - Continuous Database Application Evolution with O...
Introducing and Demonstrating Oracle Database 11gR2's Killer Feature – Editio...
SQL Server 2012 : réussir la migration - Stéphane Haby - Antonio De Santo - d...
Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefiniti...
DBI Advanced Tutorial 2007
Ad

More from dbi services (9)

PDF
Tune my Database! Mehr Oracle SQL Performance über SQLHC - Yann Neuhaus, Nico...
PDF
Tune my Application Server! Java Appl. Performance mit JVMD - Gérard Wisson, ...
PDF
Oracle OEM 12C : monitoring nouvelle génération - Pierre Sicot - dbi services
PDF
Linux Containers : dupliquer Linux à volonté - David Hueber - Grégory Steulet...
PDF
Windows Server Core : environnement pour SQL Server 2012 - Stéphane Haby - db...
PDF
Grid Control 11g: Vorteile in der Software Administration - Yann Neuhaus, dbi...
PDF
SQL Server 'code name Denali' - Stéphane Haby / Antonio De Santo, dbi service...
PDF
Oracle GoldenGate - Herve Schweitzer, dbi services - Hilton Basel 5/2011
PDF
Oracle Grid Control 11g - Yann Neuhaus, dbi services - Hilton Basel, 5/2011
Tune my Database! Mehr Oracle SQL Performance über SQLHC - Yann Neuhaus, Nico...
Tune my Application Server! Java Appl. Performance mit JVMD - Gérard Wisson, ...
Oracle OEM 12C : monitoring nouvelle génération - Pierre Sicot - dbi services
Linux Containers : dupliquer Linux à volonté - David Hueber - Grégory Steulet...
Windows Server Core : environnement pour SQL Server 2012 - Stéphane Haby - db...
Grid Control 11g: Vorteile in der Software Administration - Yann Neuhaus, dbi...
SQL Server 'code name Denali' - Stéphane Haby / Antonio De Santo, dbi service...
Oracle GoldenGate - Herve Schweitzer, dbi services - Hilton Basel 5/2011
Oracle Grid Control 11g - Yann Neuhaus, dbi services - Hilton Basel, 5/2011

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
1. Introduction to Computer Programming.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPT
Teaching material agriculture food technology
PPTX
Spectroscopy.pptx food analysis technology
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
Machine Learning_overview_presentation.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Approach and Philosophy of On baking technology
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Tartificialntelligence_presentation.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Encapsulation theory and applications.pdf
1. Introduction to Computer Programming.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
MIND Revenue Release Quarter 2 2025 Press Release
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Teaching material agriculture food technology
Spectroscopy.pptx food analysis technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
NewMind AI Weekly Chronicles - August'25-Week II
Machine Learning_overview_presentation.pptx
MYSQL Presentation for SQL database connectivity
Approach and Philosophy of On baking technology
Spectral efficient network and resource selection model in 5G networks
Digital-Transformation-Roadmap-for-Companies.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Tartificialntelligence_presentation.pptx

Tune my Code! Code-Versionen testen via Edition-Based Redef. - Jérôme Witt, dbi services

  • 1. dbi services Edition Based Redefinition Jérôme Witt Consultant - Oracle Certified Professional 11g Mobile +41 79 961 27 73 jerome.witt@dbi-services.com www.dbi-services.com 1 www.dbi-services.com 08.11.2012 © dbi services
  • 2. Edition Based Redefinition Agenda Agenda i. Introduction ii. Concept iii. Basics iv. Redefining objects v. Advanced functionalities vi. Limits 2 www.dbi-services.com 08.11.2012 © dbi services
  • 3. Edition Based Redefinition Introduction  Upgrading applications can be difficult  Short or long downtimes can not be scheduled  Implementation of online upgrades are desirable  As of Oracle Database 11gR2 with Oracle Edition Based Redefinition (aka. EBR) online application upgrades are now supported  Announced as “the killer feature” at the OOW 2009 3 www.dbi-services.com 08.11.2012 © dbi services
  • 4. Edition Based Redefinition Introduction • Creation of new objects Application upgrade • Changing objects (alter and create or replace) • Drop redundant objects Downtime EBR • Convert or migrate data • Resume normal operations 4 www.dbi-services.com 08.11.2012 © dbi services
  • 5. Edition Based Redefinition Agenda Agenda i. Introduction ii. Concept iii. Basics iv. Redefining objects v. Advanced functionalities vi. Limits 5 www.dbi-services.com 08.11.2012 © dbi services
  • 6. Edition Based Redefinition Concept(1)  As of Oracle 11gR2 an object is identified by  His name and the schema it belongs to  And now also to an EDITION SQL> desc DBA_OBJECTS Name Null? Type ------------------ -------- ---------------- . . . EDITION_NAME VARCHAR2(30)  Allows to support several copies of an object  Objects which might have copies are called “editioned objects”  All other objects are “non editionable” 6 www.dbi-services.com 08.11.2012 © dbi services
  • 7. Edition Based Redefinition Concept (2)  Which objects are “editionable” ?  SYNONYM  All PL/SQL objects  VIEW  PACKAGE and PACKAGE BODY  PROCEDURE  FUNCTION  LIBRARY  TRIGGER  TYPE and TYPE BODY  A non-editonable object cannot depend on an editonable object 7 www.dbi-services.com 08.11.2012 © dbi services
  • 8. Edition Based Redefinition Concept(3)  Editions are organized hierarchically «parent-child» ORA$BASE ED1 ED2 ED3 • OBJ_1 • OBJ_1 • OBJ_2 • OBJ_2 • OBJ_3 • OBJ_3 ED2 8 www.dbi-services.com 08.11.2012 © dbi services
  • 9. Edition Based Redefinition Concept(4)  Editions are organized hierarchically «parent-child» ORA$BASE ED1 ED2 ED3 • OBJ_1 • OBJ_1 • OBJ_2 • OBJ_2 • OBJ_3 • OBJ_3  Inheritance  When an edition is created all objects associated with the parent are inherited by the child. They become «inherited»  Objects re-created or altered in an edition become “actualized” (i.e. objects OBJ_2 & OBJ_3 of the edition ED3)  Inherited & actual objects are “visible” 9 www.dbi-services.com 08.11.2012 © dbi services
  • 10. Edition Based Redefinition Agenda Agenda i. Introduction ii. Concept iii. Basics iv. Redefining objects v. Advanced functionalities vi. Limits 10 www.dbi-services.com 08.11.2012 © dbi services
  • 11. Edition Based Redefinition Basics (1)  Creating editions  Database default edition «ORA$BASE»  Database creation or upgrade to Oracle 11.2  Has no actual editioned objects SQL> CREATE EDITION <ed_name> {AS CHILD OF ora$base};  Enabling editions SQL> ALTER USER <schema> ENABLE EDITIONS {FORCE};  Editioned objects can only be owned by schemas that have been explicitly enabled  FORCE if schema has potentially editionable objects  By the way DISABLE EDTIONS doesn’t exists ! 11 www.dbi-services.com 08.11.2012 © dbi services
  • 12. Edition Based Redefinition Basics (2)  Granting editions SQL> GRANT USE ON EDITION <ed_name> TO <schema>;  Selecting editions SQL> ALTER SESSION SET EDITION =<ed_name>;  Retrieving current and session edition SQL> SHOW EDITION; SQL> SELECT SYS_CONTEXT('USERENV', 'CURRENT_EDITION_NAME'), SYS_CONTEXT('USERENV', 'SESSION_EDITION_NAME') FROM dual; 12 www.dbi-services.com 08.11.2012 © dbi services
  • 13. Edition Based Redefinition Basics (3)  Enabling an edition database wide SQL> ALTER DATABASE DEFAULT EDITION=<ed_name>; SQL> SELECT property_value FROM database_properties WHERE property_name = 'DEFAULT_EDITION';  Selecting edition at connection time DBMS_SERVICE.CREATE_SERVICE( service_name => '<ORACLE_SID.DB_DOMAIN>', . . . edition => '<ed_name>');  EBR integrated with  Oracle Call Interface  JDBC  Oracle Restart (srvctl) 13 www.dbi-services.com 08.11.2012 © dbi services
  • 14. Edition Based Redefinition Basics (4)  Display all database editions  Views {DBA|ALL}_EDITIONS  Display all objects editions  Views {DBA|ALL|USER}_OBJECTS_AE  View current edition from an object  Views {DBA|ALL|USER}_OBJECTS.EDITION_NAME  And so on … 14 www.dbi-services.com 08.11.2012 © dbi services
  • 15. Edition Based Redefinition Agenda Agenda i. Introduction ii. Concept iii. Basics iv. Redefining objects v. Advanced functionalities vi. Limits 15 www.dbi-services.com 08.11.2012 © dbi services
  • 16. Edition Based Redefinition Redefining objects(1) SQL> BEGIN raiseSalary( p_title_in => 'COM_DBISERVICES . . . ', p_rate_in => 1.10, p_max_sal_in => 50000 ); END; / 16 www.dbi-services.com 08.11.2012 © dbi services
  • 17. Edition Based Redefinition Redefining objects(2) PROCEDURE raiseSalary(. . .) IS . . . CURSOR cur_emp IS SELECT * FROM EMPLOYEES FOR UPDATE; BEGIN OPEN cur_emp; LOOP FETCH cur_emp INTO rec_emp; . . . SELECT upper(job_title) INTO v_cur_title FROM hr.jobs WHERE job_id = rec_emp.job_id; IF v_cur_title = v_title_in AND rec_emp.salary*p_rate_in <= p_max_sal_in THEN -- Do some other checks on employee UPDATE . . . END IF; END LOOP; CLOSE cur_emp; COMMIT; END; 17 www.dbi-services.com 08.11.2012 © dbi services
  • 18. Edition Based Redefinition Redefining objects(3) PROCEDURE raiseSalary(. . .) IS . . . CURSOR cur_emp IS SELECT e.employee_id from hr.employees e, hr.jobs j WHERE e.job_id = j.job_id AND upper(j.job_title) = v_title_in AND e.salary*p_rate_in <= p_max_sal_in; BEGIN OPEN cur_emp; LOOP FETCH cur_emp BULK COLLECT INTO v_empid_list LIMIT 1000; EXIT WHEN v_empid_list.COUNT = 0; -- Do some other checks on employee FORALL i IN v_empid_list.FIRST .. v_empid_list.LAST UPDATE hr.employees SET salary=salary*p_rate_in WHERE employee_id=v_empid_list(i); END LOOP; CLOSE cur_emp; COMMIT; END; 18 www.dbi-services.com 08.11.2012 © dbi services
  • 19. Edition Based Redefinition Redefining objects(3)  Typical EBR redefinition steps 1. Create the new edition 2. Set the edition as session edition 3. Redefine the objects 4. Permanently switch to the new edition  To “redefine” objects it’s necessary to select the new edition and either re-compile or recreate objects  Consider application roll out strategy 19 www.dbi-services.com 08.11.2012 © dbi services
  • 20. Edition Based Redefinition Redefining objects(4) 20 www.dbi-services.com 08.11.2012 © dbi services
  • 21. Edition Based Redefinition Agenda Agenda i. Introduction ii. Concept iii. Basics iv. Redefining objects v. Advanced functionalities vi. Limits 21 www.dbi-services.com 08.11.2012 © dbi services
  • 22. Edition Based Redefinition Advanced functionalities(1)  Views  Editionable (of course)  Support only INSTEAD OF triggers  Editioning views  Selects a subset of the columns from a single base table  Optionally, provide aliases for columns  Doesn’t support indexes nor constraints  No performance penalty for accessing base table  Support any type of triggers (especially CROSSEDITION TRIGGERS) SQL> CREATE EDITIONING VIEW <name> AS SELECT ...; 22 www.dbi-services.com 08.11.2012 © dbi services
  • 23. Edition Based Redefinition Advanced functionalities(2)  Crossedition triggers  Propagate data changes made by the old edition into the new edition’s columns, or vice-versa.  From type FORWARD or REVERSE  They are temporary! SQL> CREATE OR REPLACE TRIGGER <trigger_name> BEFORE INSERT OR UPDATE ON <table_name> FOR EACH ROW FORWARD CROSSEDITION DISABLE BEGIN . . . END <trigger_name>; / 23 www.dbi-services.com 08.11.2012 © dbi services
  • 24. Edition Based Redefinition Advanced functionalities(3) New Edition : ED_V1 C_Pool ED_V1 EMPLOYEES First Last Phone Name Name Nbr EMPLOYEES_TAB EMPLOYEES First Last Phone Name Name Nbr 24 www.dbi-services.com 08.11.2012 © dbi services
  • 25. Edition Based Redefinition Advanced functionalities(4) ED_V2 New Edition : ED_V1 C_Pool ED_V1 EMPLOYEES EMPLOYEES First First Phone Last Last Phone Dial Int Name Name Name Name Nbr Nbr PhNbr Code FWD_TRG REV_TRG EMPLOYEES_TAB EMPLOYEES_TAB First First Phone Last Last Phone Int Dial Name Name Nbr Name Name Code Nbr PhNbr 25 www.dbi-services.com 08.11.2012 © dbi services
  • 26. Edition Based Redefinition Advanced functionalities(5) New Edition : ED_V2 C_Pool ED_V1 EMPLOYEES First Last Phone Dial Int Name Name Nbr Code PhNbr FWD_TRG REV_TRG EMPLOYEES_TAB C_Pool ED_V2 First Last Phone Dial Int Name Name Nbr Code PhNbr 26 www.dbi-services.com 08.11.2012 © dbi services
  • 27. Edition Based Redefinition Advanced functionalities(2)  Hot roll-over “bulk forward”  Wait for pending DMLs DBMS_UTILITY.WAIT_ON_PENDING_DML( tables => '<Base_Table>', timeout => timeout, scn => scn );  Apply transformation DBMS_SQL.PARSE( c => c, Language_Flag => DBMS_SQL.NATIVE, Statement=> 'UPDATE employees SET ID = ID', Apply_Crossedition_Trigger => '<CRED_TRG_FWD>' ); 27 www.dbi-services.com 08.11.2012 © dbi services
  • 28. Edition Based Redefinition Agenda Agenda i. Introduction ii. Concept iii. Basics iv. Redefining objects v. Advanced functionalities vi. Limits 28 www.dbi-services.com 08.11.2012 © dbi services
  • 29. Edition Based Redefinition Limits  Performance & Tuning  Indexes & constraints must be added to the base table  To limit negative performance impact specify an INDEX hint within the crossedition triggers  Editioning views accept SQL optimizer hints  Logical column names must be mapped to an index on the corresponding physical column in the base table SQL> SELECT /*+ INDEX (edview1 idx1)*/ email FROM edview1 WHERE last_name='King';  Can not drop retired editions!  Bugs (11.2.0.3) – do not drop edition ORA$BASE  One of the least known Oracle database feature 29 www.dbi-services.com 08.11.2012 © dbi services
  • 30. dbi services Any Questions? Please Do Ask! Jérôme Witt Consultant - Oracle Certified Professional 11g Mobile +41 79 961 27 73 jerome.witt@dbi-services.com www.dbi-services.com „We look forward to working with you!“ 30 www.dbi-services.com 08.11.2012 © dbi services