SlideShare una empresa de Scribd logo
1 de 44
Tales from a Parallel Universe:Using 11gR2’s Edition Based Redefinitions (in APEX) Roel Hartman
EBR and APEX? Sorry, you can’t do it... Questions? John’s suggestion....
Who am I? ,[object Object]
Presenter at UKOUG (3x), OOW (3x), ODTUG (2x)roelhartman.blogspot.com No. 3
Tom Kytesays:
Unplanned Downtime Physical Standby Database Logical Standby Database RAC The Case
Unplanned Downtime
Planned Downtime Database Upgrade Streams Rolling Upgrade using Logical Standby Database Application Maintenance Online Index Rebuild Online Table Redefinition The Case
Planned Downtime
Planned Downtime  Application Upgrade Create objects Replace objects Drop objects Recompilation The Case
Keep the Shop open Prepare new Release  Cut over Randall Version 2 2 Boo 1 Version 1 Sulley 1 + 2
Edition Schema Object Type Object Name Session runs in the context of an Edition Parallel Universes
SQL>ALTER USER HR ENABLE EDITIONS; USER ALTERED. SQL> ALTER USER HR DISABLE EDITIONS; ALTER USER HR DISABLE EDITIONS               * ERROR at line 1: ORA-00922: missing or invalid option SQL>
SQL> select * from all_editions; EDITION_NAME PARENT_EDITION_NAME USA ------------ ------------------- --- ORA$BASE                         YES SQL>
SQL> CREATE EDITION HR_RELEASE2 AS CHILD OF ORA$BASE; Edition created. SQL> CREATE EDITION OE_RELEASE2 AS CHILD OF ORA$BASE; CREATE EDITION OE_RELEASE2 AS CHILD OF ORA$BASE; * ERROR at line 1: ORA-38807: Implementation restriction: an edition can have only one child
ORA$BASE HR OE HR_RELEASE2 HR’ OE_RELEASE2 OE’ One Child – One Parent
Editionable PL/SQL Objects Packages Procedures Functions Triggers Views Synonyms Types Not everything is editionable... Not Editionable Tables Materialized Views DB Links
Table X Table Y ORA$BASE PL/SQL (A) PL/SQL (B) HR_RELEASE2 PL/SQL (A) PL/SQL (B) PL/SQL (B’)
“Instead-of-table” Only one table in the from clause No expressions, only columns Can have “regular” table triggers Same execution plan Editioning Views are the new tables Editioning Views are Editionable.... Editioning View
Editioning View Data is the same View is different Depends on your position / edition
Table X_t Table Y_t ORA$BASE Editioning View X Editioning View Y PL/SQL (A) PL/SQL (B) HR_RELEASE2 Editioning View Y’ PL/SQL (A) PL/SQL (B) PL/SQL (B’)
Old situation : One column NAME New situation : FIRST_NAME / LAST_NAME Cross Edition Triggers Forward Reverse Only on a Table Editionable In the newedition! How to handle Table changes?
Cross Edition Triggers NAME FIRST_NAME LAST_NAME “split” “concat” RELEASE 2 ORA$BASE RELEASE 3 ForwardCrossEditionTrigger ReverseCrossEditionTrigger Session A Session B Session C
Chain of forward / reverse Xedition triggers in decendent / ancestor editions Forward Xedition DML fires Forward Xedition triggers only (not regular triggers) The same for Reverse Xedition DML Xedition DML fires only other Xedition trigger (in same edition) if there is an ordering (follows xxx clause) Advanced principles
Forward Xedition isn’t fired in own edition Fill FIRST_NAME / LAST_NAME from NAME Fire the Xedition trigger only Use dbms_utility.wait_on_pending_dml() to prevent “lost updates” Use applying_crossedition_trigger function to prevent “collision” Use IGNORE_ROW_ON_DUPKEY_INDEX / CHANGE_DUPKEY_ERROR_INDEX hint (mandate!) to prevent collision Apply changes - 1 DBMS_Sql.Parse( c => The_Cursor, Language_Flag => DBMS_Sql.Native, Statement => 'update emp set empno = empno', Apply_Crossedition_Trigger => 'Fwd_Xed');
Apply changes - 2 CREATE OR REPLACE TRIGGER trigger1 BEFORE INSERT OR UPDATE ON table1   FOR EACH ROW CROSSEDITION DECLARE row_already_present EXCEPTION;   PRAGMA EXCEPTION_INIT(row_already_present, -38911); BEGIN   IF APPLYING_CROSSEDITION_TRIGGER THEN     /* Trigger is running because of serendipitous change.        Insert new row into table2 unless it is already there. */     INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(table2(key)) */     INTO table2     VALUES(:new.key, :new.value, to_date('1900-01-01', 'YYYY-MM-DD'));   ELSE     /* Trigger is running because you are applying transform.        If tranform has not yet inserted new row in table2, insert new row;        otherwise, update new row. */     BEGIN       INSERT /*+ CHANGE_DUPKEY_ERROR_INDEX(table2(key)) */       INTO table2       VALUES(:new.key, :new.value, SYSTIMESTAMP);     EXCEPTION WHEN row_already_present       THEN         UPDATE table2         SET value = :new.value, last_updated = SYSTIMESTAMP         WHERE key = :new.key;     END;   END IF; END;
Rename your Tables Create Editioning Views Reroute Privileges Recreate Triggers Recompile all PL/SQL Apply VPD Policies Prepare your Application Your last Planned Downtime
Prepare your Application 1 Renameyour tables 2 Createeditioning views 3 Reroute privileges Your last Planned Downtime 4 Recreatetriggers 5 Recompile PL/SQL 6 Apply VPD policies
grant use on edition to <user> alter database default edition=<x> alter session set edition=<x> dbms_session.set_edition_deferred( <x> ) sys.dbms_sys_sql.parse (_as_user) sys_context SQL*Plus : show edition Opening up an Edition
SQL>GRANT USE ON EDITION HR_RELEASE2 TO SCOTT; Grant succeeded. SQL> CONNECT SCOTT/TIGER Connected. SQL> select sys_context('userenv', 'current_edition_name') current_edition_name from dual;  CURRENT_EDITION_NAME -------------------- ORA$BASE
SQL>ALTER SESSION SET EDITION=HR_RELEASE2; Session altered. SQL> select sys_context('userenv', 'current_edition_name') current_edition_name from dual;  CURRENT_EDITION_NAME -------------------- HR_RELEASE2
Rolling back an upgrade Retiring an Edition Only the root or a leaf No objects are inherited (anymore) Not currently in use Not the DB default edition Recompile objects (reuse settings) Dropping an Edition
*_EDITIONS *_EDITION_COMMENTS *_VIEWS_AE *_SOURCE_AE *_OBJECTS_AE *_ERRORS_AE *_EDITIONING_VIEWS_AE *_EDITIONING_VIEW_COLS_AE DBMS_EDITIONS_UTILITIES.SET_EDITIONING_VIEWS_READ_ONLY DBMS_SESSION.SET_EDITION_DEFERRED( <EDITION_NAME> ) New Database Stuff
EBR and APEX - 1 ,[object Object]
DBMS_SESSION.SET_EDITION_DEFERRED
Session Pooling,[object Object]
Build on – views on - Editioning Views Four (!) -tier architecture Edition your Views or PL/SQL Functions Use Authorization Schemes EBR and APEX - 3 UI / APEX (Regular) View Editioning View Table

Más contenido relacionado

La actualidad más candente

DB2 LUW - Backup and Recovery
DB2 LUW - Backup and RecoveryDB2 LUW - Backup and Recovery
DB2 LUW - Backup and Recovery
imranasayed
 
[Altibase] 11 replication part4 (conflict resolution)
[Altibase] 11 replication part4 (conflict resolution)[Altibase] 11 replication part4 (conflict resolution)
[Altibase] 11 replication part4 (conflict resolution)
altistory
 
Sql tuning guideline
Sql tuning guidelineSql tuning guideline
Sql tuning guideline
Sidney Chen
 

La actualidad más candente (20)

R12 d49656 gc10-apps dba 13
R12 d49656 gc10-apps dba 13R12 d49656 gc10-apps dba 13
R12 d49656 gc10-apps dba 13
 
R12 d49656 gc10-apps dba 18
R12 d49656 gc10-apps dba 18R12 d49656 gc10-apps dba 18
R12 d49656 gc10-apps dba 18
 
Phoenix h basemeetup
Phoenix h basemeetupPhoenix h basemeetup
Phoenix h basemeetup
 
DB2 LUW - Backup and Recovery
DB2 LUW - Backup and RecoveryDB2 LUW - Backup and Recovery
DB2 LUW - Backup and Recovery
 
Les 18 space
Les 18 spaceLes 18 space
Les 18 space
 
DB2 utilities
DB2 utilitiesDB2 utilities
DB2 utilities
 
Optimizing Your Cloud Applications in RightScale
Optimizing Your Cloud Applications in RightScaleOptimizing Your Cloud Applications in RightScale
Optimizing Your Cloud Applications in RightScale
 
R12.2 dba
R12.2 dbaR12.2 dba
R12.2 dba
 
Online Statistics Gathering for ETL
Online Statistics Gathering for ETLOnline Statistics Gathering for ETL
Online Statistics Gathering for ETL
 
R12 d49656 gc10-apps dba 08
R12 d49656 gc10-apps dba 08R12 d49656 gc10-apps dba 08
R12 d49656 gc10-apps dba 08
 
SAP HANA System Replication - Setup, Operations and HANA Monitoring
SAP HANA System Replication - Setup, Operations and HANA MonitoringSAP HANA System Replication - Setup, Operations and HANA Monitoring
SAP HANA System Replication - Setup, Operations and HANA Monitoring
 
Sq lite
Sq liteSq lite
Sq lite
 
Mule for each scope header collection
Mule for each scope header collectionMule for each scope header collection
Mule for each scope header collection
 
Les10
Les10Les10
Les10
 
Oracle11g R2 - Edition Based Redefinition for On Line Application Upgrade
Oracle11g R2 - Edition Based Redefinition for On Line Application UpgradeOracle11g R2 - Edition Based Redefinition for On Line Application Upgrade
Oracle11g R2 - Edition Based Redefinition for On Line Application Upgrade
 
[Altibase] 11 replication part4 (conflict resolution)
[Altibase] 11 replication part4 (conflict resolution)[Altibase] 11 replication part4 (conflict resolution)
[Altibase] 11 replication part4 (conflict resolution)
 
Spring Cloud Config
Spring Cloud ConfigSpring Cloud Config
Spring Cloud Config
 
Sql tuning guideline
Sql tuning guidelineSql tuning guideline
Sql tuning guideline
 
Fig 9-03
Fig 9-03Fig 9-03
Fig 9-03
 
Useful PL/SQL Supplied Packages
Useful PL/SQL Supplied PackagesUseful PL/SQL Supplied Packages
Useful PL/SQL Supplied Packages
 

Similar a Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

My sql with querys
My sql with querysMy sql with querys
My sql with querys
NIRMAL FELIX
 
Creating a database
Creating a databaseCreating a database
Creating a database
Rahul Gupta
 
Java class 8
Java class 8Java class 8
Java class 8
Edureka!
 
ii bcom dbms SQL Commands.docx
ii bcom dbms SQL Commands.docxii bcom dbms SQL Commands.docx
ii bcom dbms SQL Commands.docx
lakshmi77
 

Similar a Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX (20)

Oracle SQL AND PL/SQL
Oracle SQL AND PL/SQLOracle SQL AND PL/SQL
Oracle SQL AND PL/SQL
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
Oracle 11g SQL Overview
Oracle 11g SQL OverviewOracle 11g SQL Overview
Oracle 11g SQL Overview
 
My sql with querys
My sql with querysMy sql with querys
My sql with querys
 
Creating a database
Creating a databaseCreating a database
Creating a database
 
Columnrename9i
Columnrename9iColumnrename9i
Columnrename9i
 
Data Definition Language (DDL)
Data Definition Language (DDL) Data Definition Language (DDL)
Data Definition Language (DDL)
 
Database models and DBMS languages
Database models and DBMS languagesDatabase models and DBMS languages
Database models and DBMS languages
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
Introduction to Oracle Database.pptx
Introduction to Oracle Database.pptxIntroduction to Oracle Database.pptx
Introduction to Oracle Database.pptx
 
Les10
Les10Les10
Les10
 
My sql.ppt
My sql.pptMy sql.ppt
My sql.ppt
 
Les10 Creating And Managing Tables
Les10 Creating And Managing TablesLes10 Creating And Managing Tables
Les10 Creating And Managing Tables
 
Sql 
statements , functions & joins
Sql 
statements , functions  &  joinsSql 
statements , functions  &  joins
Sql 
statements , functions & joins
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Java class 8
Java class 8Java class 8
Java class 8
 
Oracle sql material
Oracle sql materialOracle sql material
Oracle sql material
 
Adbms
AdbmsAdbms
Adbms
 
ii bcom dbms SQL Commands.docx
ii bcom dbms SQL Commands.docxii bcom dbms SQL Commands.docx
ii bcom dbms SQL Commands.docx
 

Más de Roel Hartman

Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Roel Hartman
 

Más de Roel Hartman (20)

Wizard of ORDS
Wizard of ORDSWizard of ORDS
Wizard of ORDS
 
APEX Bad Practices
APEX Bad PracticesAPEX Bad Practices
APEX Bad Practices
 
Tweaking the interactive grid
Tweaking the interactive gridTweaking the interactive grid
Tweaking the interactive grid
 
Docker for Dummies
Docker for DummiesDocker for Dummies
Docker for Dummies
 
A deep dive into APEX JET charts
A deep dive into APEX JET chartsA deep dive into APEX JET charts
A deep dive into APEX JET charts
 
My Top 5 APEX JavaScript API's
My Top 5 APEX JavaScript API'sMy Top 5 APEX JavaScript API's
My Top 5 APEX JavaScript API's
 
Mastering universal theme
Mastering universal themeMastering universal theme
Mastering universal theme
 
APEX Developers : Do More With LESS !
APEX Developers : Do More With LESS !APEX Developers : Do More With LESS !
APEX Developers : Do More With LESS !
 
Ten Tiny Things To Try Today - Hidden APEX5 Gems Revealed
Ten Tiny Things To Try Today - Hidden APEX5 Gems RevealedTen Tiny Things To Try Today - Hidden APEX5 Gems Revealed
Ten Tiny Things To Try Today - Hidden APEX5 Gems Revealed
 
Best of both worlds: Create hybrid mobile applications with Oracle Applicatio...
Best of both worlds: Create hybrid mobile applications with Oracle Applicatio...Best of both worlds: Create hybrid mobile applications with Oracle Applicatio...
Best of both worlds: Create hybrid mobile applications with Oracle Applicatio...
 
APEX printing with BI Publisher
APEX printing with BI PublisherAPEX printing with BI Publisher
APEX printing with BI Publisher
 
Troubleshooting APEX Performance Issues
Troubleshooting APEX Performance IssuesTroubleshooting APEX Performance Issues
Troubleshooting APEX Performance Issues
 
Automated testing APEX Applications
Automated testing APEX ApplicationsAutomated testing APEX Applications
Automated testing APEX Applications
 
5 Cool Things you can do with HTML5 and APEX
5 Cool Things you can do with HTML5 and APEX5 Cool Things you can do with HTML5 and APEX
5 Cool Things you can do with HTML5 and APEX
 
Striving for Perfection: The Ultimate APEX Application Architecture
Striving for Perfection: The Ultimate APEX Application ArchitectureStriving for Perfection: The Ultimate APEX Application Architecture
Striving for Perfection: The Ultimate APEX Application Architecture
 
XFILES, the APEX 4 version - The truth is in there
XFILES, the APEX 4 version - The truth is in thereXFILES, the APEX 4 version - The truth is in there
XFILES, the APEX 4 version - The truth is in there
 
Done in 60 seconds - Creating Web 2.0 applications made easy
Done in 60 seconds - Creating Web 2.0 applications made easyDone in 60 seconds - Creating Web 2.0 applications made easy
Done in 60 seconds - Creating Web 2.0 applications made easy
 
Creating sub zero dashboard plugin for apex with google
Creating sub zero dashboard plugin for apex with googleCreating sub zero dashboard plugin for apex with google
Creating sub zero dashboard plugin for apex with google
 
Integration of APEX and Oracle Forms
Integration of APEX and Oracle FormsIntegration of APEX and Oracle Forms
Integration of APEX and Oracle Forms
 
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...Developing A Real World Logistic Application With Oracle Application - UKOUG ...
Developing A Real World Logistic Application With Oracle Application - UKOUG ...
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Tales from a Parallel Universe: Using Oracle 11gR2's Edition Based Redefinition in combination with APEX

  • 1. Tales from a Parallel Universe:Using 11gR2’s Edition Based Redefinitions (in APEX) Roel Hartman
  • 2. EBR and APEX? Sorry, you can’t do it... Questions? John’s suggestion....
  • 3.
  • 4. Presenter at UKOUG (3x), OOW (3x), ODTUG (2x)roelhartman.blogspot.com No. 3
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. Unplanned Downtime Physical Standby Database Logical Standby Database RAC The Case
  • 13. Planned Downtime Database Upgrade Streams Rolling Upgrade using Logical Standby Database Application Maintenance Online Index Rebuild Online Table Redefinition The Case
  • 15. Planned Downtime Application Upgrade Create objects Replace objects Drop objects Recompilation The Case
  • 16.
  • 17. Keep the Shop open Prepare new Release Cut over Randall Version 2 2 Boo 1 Version 1 Sulley 1 + 2
  • 18. Edition Schema Object Type Object Name Session runs in the context of an Edition Parallel Universes
  • 19. SQL>ALTER USER HR ENABLE EDITIONS; USER ALTERED. SQL> ALTER USER HR DISABLE EDITIONS; ALTER USER HR DISABLE EDITIONS * ERROR at line 1: ORA-00922: missing or invalid option SQL>
  • 20. SQL> select * from all_editions; EDITION_NAME PARENT_EDITION_NAME USA ------------ ------------------- --- ORA$BASE YES SQL>
  • 21. SQL> CREATE EDITION HR_RELEASE2 AS CHILD OF ORA$BASE; Edition created. SQL> CREATE EDITION OE_RELEASE2 AS CHILD OF ORA$BASE; CREATE EDITION OE_RELEASE2 AS CHILD OF ORA$BASE; * ERROR at line 1: ORA-38807: Implementation restriction: an edition can have only one child
  • 22. ORA$BASE HR OE HR_RELEASE2 HR’ OE_RELEASE2 OE’ One Child – One Parent
  • 23. Editionable PL/SQL Objects Packages Procedures Functions Triggers Views Synonyms Types Not everything is editionable... Not Editionable Tables Materialized Views DB Links
  • 24. Table X Table Y ORA$BASE PL/SQL (A) PL/SQL (B) HR_RELEASE2 PL/SQL (A) PL/SQL (B) PL/SQL (B’)
  • 25. “Instead-of-table” Only one table in the from clause No expressions, only columns Can have “regular” table triggers Same execution plan Editioning Views are the new tables Editioning Views are Editionable.... Editioning View
  • 26.
  • 27. Editioning View Data is the same View is different Depends on your position / edition
  • 28. Table X_t Table Y_t ORA$BASE Editioning View X Editioning View Y PL/SQL (A) PL/SQL (B) HR_RELEASE2 Editioning View Y’ PL/SQL (A) PL/SQL (B) PL/SQL (B’)
  • 29. Old situation : One column NAME New situation : FIRST_NAME / LAST_NAME Cross Edition Triggers Forward Reverse Only on a Table Editionable In the newedition! How to handle Table changes?
  • 30. Cross Edition Triggers NAME FIRST_NAME LAST_NAME “split” “concat” RELEASE 2 ORA$BASE RELEASE 3 ForwardCrossEditionTrigger ReverseCrossEditionTrigger Session A Session B Session C
  • 31. Chain of forward / reverse Xedition triggers in decendent / ancestor editions Forward Xedition DML fires Forward Xedition triggers only (not regular triggers) The same for Reverse Xedition DML Xedition DML fires only other Xedition trigger (in same edition) if there is an ordering (follows xxx clause) Advanced principles
  • 32. Forward Xedition isn’t fired in own edition Fill FIRST_NAME / LAST_NAME from NAME Fire the Xedition trigger only Use dbms_utility.wait_on_pending_dml() to prevent “lost updates” Use applying_crossedition_trigger function to prevent “collision” Use IGNORE_ROW_ON_DUPKEY_INDEX / CHANGE_DUPKEY_ERROR_INDEX hint (mandate!) to prevent collision Apply changes - 1 DBMS_Sql.Parse( c => The_Cursor, Language_Flag => DBMS_Sql.Native, Statement => 'update emp set empno = empno', Apply_Crossedition_Trigger => 'Fwd_Xed');
  • 33. Apply changes - 2 CREATE OR REPLACE TRIGGER trigger1 BEFORE INSERT OR UPDATE ON table1 FOR EACH ROW CROSSEDITION DECLARE row_already_present EXCEPTION; PRAGMA EXCEPTION_INIT(row_already_present, -38911); BEGIN IF APPLYING_CROSSEDITION_TRIGGER THEN /* Trigger is running because of serendipitous change. Insert new row into table2 unless it is already there. */ INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(table2(key)) */ INTO table2 VALUES(:new.key, :new.value, to_date('1900-01-01', 'YYYY-MM-DD')); ELSE /* Trigger is running because you are applying transform. If tranform has not yet inserted new row in table2, insert new row; otherwise, update new row. */ BEGIN INSERT /*+ CHANGE_DUPKEY_ERROR_INDEX(table2(key)) */ INTO table2 VALUES(:new.key, :new.value, SYSTIMESTAMP); EXCEPTION WHEN row_already_present THEN UPDATE table2 SET value = :new.value, last_updated = SYSTIMESTAMP WHERE key = :new.key; END; END IF; END;
  • 34. Rename your Tables Create Editioning Views Reroute Privileges Recreate Triggers Recompile all PL/SQL Apply VPD Policies Prepare your Application Your last Planned Downtime
  • 35. Prepare your Application 1 Renameyour tables 2 Createeditioning views 3 Reroute privileges Your last Planned Downtime 4 Recreatetriggers 5 Recompile PL/SQL 6 Apply VPD policies
  • 36. grant use on edition to <user> alter database default edition=<x> alter session set edition=<x> dbms_session.set_edition_deferred( <x> ) sys.dbms_sys_sql.parse (_as_user) sys_context SQL*Plus : show edition Opening up an Edition
  • 37. SQL>GRANT USE ON EDITION HR_RELEASE2 TO SCOTT; Grant succeeded. SQL> CONNECT SCOTT/TIGER Connected. SQL> select sys_context('userenv', 'current_edition_name') current_edition_name from dual; CURRENT_EDITION_NAME -------------------- ORA$BASE
  • 38. SQL>ALTER SESSION SET EDITION=HR_RELEASE2; Session altered. SQL> select sys_context('userenv', 'current_edition_name') current_edition_name from dual; CURRENT_EDITION_NAME -------------------- HR_RELEASE2
  • 39. Rolling back an upgrade Retiring an Edition Only the root or a leaf No objects are inherited (anymore) Not currently in use Not the DB default edition Recompile objects (reuse settings) Dropping an Edition
  • 40. *_EDITIONS *_EDITION_COMMENTS *_VIEWS_AE *_SOURCE_AE *_OBJECTS_AE *_ERRORS_AE *_EDITIONING_VIEWS_AE *_EDITIONING_VIEW_COLS_AE DBMS_EDITIONS_UTILITIES.SET_EDITIONING_VIEWS_READ_ONLY DBMS_SESSION.SET_EDITION_DEFERRED( <EDITION_NAME> ) New Database Stuff
  • 41.
  • 43.
  • 44. Build on – views on - Editioning Views Four (!) -tier architecture Edition your Views or PL/SQL Functions Use Authorization Schemes EBR and APEX - 3 UI / APEX (Regular) View Editioning View Table
  • 45. EBR and APEX – Cool demo
  • 47. Applications never nevernever access tables Application sets the edition Alter DAD’s edition (EPG only)! Be aware!! Dropping objects drops inheritance No branching Best Practices
  • 48. Short time Long(er) time Only for a specific group SaaS environment Parallel Application Versions
  • 49. Different versions in the same schema No more planned downtime! Ease of maintenance Less redo Less risk So saving $$$ Summary & conclusions
  • 50. Edition-Based Redefinition: Testing Live Application Upgrades (Without Actually Being Live) - Ms Melanie Caffrey Today at 14:15 Other sessions @UKOUG
  • 51. Tom Kyte column(s) in Oracle Magazine Jan/Feb 2010 (http://www.oracle.com/technology/oramag/oracle/10-jan/o10asktom.html) Bryn's Whitepaper "Edition-Based Redefinition a new capability in Oracle Database 11g Release 2 to support online application upgrade". July 2009 (http://www.oracle.com/technology/deploy/availability/pdf/edition_based_redefinition.pdf) Documentation in "Oracle Database Advanced Application Developer's Guide 11g Release 2" (http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10471/adfns_editions.htm). References
  • 52. Question Time That’s all Folks! My blog : http://roelhartman.blogspot.com My e-mail : roel.hartman@logica.com

Notas del editor

  1. 0:02 / 0:04Over 15 years experience in the Oracle field. Started with RDBMS v5, Oracle Case, Forms 2.3, RPT/RPF. All the way to the latest version of Designer, Developer, RDBMS (took part in the 11g beta test).Frequent contributor of Oracle APEX Forum – Not &gt; 4000 posts, but I’ve got work to do.BloggerWorking for Logica for over 13 years now as a Software Architect, NL-Lead Technical Architect OracleI set op the model for our Factory for Automated Migration of Oracle (u) Software. A repeatable solution for the migrations of Oracle Designer and Oracle Forms from earlier version to the latest version.Not a native English speaker – as you might have noticed (or will notice)APEX Experience?Forms Experience?APEX 2 Forms conversion experience?APEX 3.2 Early Adopters Release: article in Oghvisie &amp; Oracle Scene
  2. 7 years!
  3. 1. Physical Standby DatabaseStandby database is called “physical” if the physical structure of stand by exactly matches with stand by structure. Archived redo log transferred from primary database will be directly applied to the stand by database.2. Logical Standby DatabaseStand by database is called “logical”, the physical structure of both databases do not match and from the archived redo log we create SQL statements then these statements will be applied to stand by database.
  4. Online Index Rebuild (9i):When the ONLINE keyword is used as part of the CREATE or ALTER syntax the current index is left intact while a new copy of the index is built, allowing DML to access the old index. Any alterations to the old index are recorded in a Index Organized Table known as a &quot;journal table&quot;. Once the rebuild is complete the alterations from the journal table are merged into the new index. This may take several passes depending on the frequency of alterations to the index. The process will skip any locked rows and commit every 20 rows. Once the merge operation is complete the data dictionary is updated and the old index is dropped. DML access is only blocked during the data dictionary updates, which complete very quickly.Online Table Redefinition (9i):Prior to Oracle9i table redefinition was only possible using export/import which meant the table was offline during the process, or the move syntax which locked DML during the operation. Neither of these methods is suitable for large OLTP tables as the downtime can be considerable. To solve this problem Oracle9i has introduced Online Table Redefinitions using the DBMS_REDEFINITION package.The process is similar to online rebuilds of indexes in that the original table is left online while a new copy of the table is built. DML operations on the original table are stored in an temporary table for interim updates. Once the new table is complete the interim updates are merged into it and the names of the original and the new table are swapped in the data dictionary. This step requires a DML lock but it is only held for a short time. At this point all DML is processed against the new table. The interim updates are automatically discarded, but the original table, with it&apos;s new name, has to be discarded manually
  5. While Boo is implementing Version2, Sulley continues working in Version 1When Boo is finished, Randall starts a new session in Version 2, while Sulley stills does his thing in Version 1
  6. NotEditionedTables X and Y are noteditionable, sothoseobjectsaren’t part of anyeditionBase ReleasePL/SQL Object A reads/writes to Table X and calls PL/SQL Object BPL/SQL Object B reads/writes to Table YRelease 2PL/SQL Object B is replacedby B’. PL/SQL Object A calls PL/SQL Object B’ nowPL/SQL Object B’ reads/writes to Table YPL/SQL Object A is “virtually present”
  7. NotEditionedFor Release 2 column C is redundant and columns D and E are added.To keep the base release running column C isn’tdropped (yet).Youcan drop column C eventuallywheneveryone is using Release 2.Base ReleasePL/SQL Object A reads/writes to Editioning View XPL/SQL Object B reads/writes to Editioning View YRelease 2Edition View Y is replacedby Y’, without column C, butwith columns D and EPL/SQL Object B is replacedby B’. PL/SQL Object A calls PL/SQL Object B’ nowPL/SQL Object B’ reads/writes to Edition View Y’
  8. Update in base ReleasefiresForwardCrossEditionTrigger in Release 2Update in Release 2FiresReverseCrossEditionTrigger in Release 2Update in Release 3FiresReverseCrossEditionTrigger in Release 2
  9. Forward Xedition isn’t fired in own editionSo how to create the “new” information =&gt; FIRST_NAME and LAST_NAME from NAMEIGNORE_ROW_ON_DUPKEY_INDEX : Sort of Merge statement.CHANGE_DUPKEY_ERROR_INDEX : Changes an Duplicate Key error from ORA-00001 to ORA-38911
  10. Forward Xedition isn’t fired in own editionSo how to create the “new” information =&gt; FIRST_NAME and LAST_NAME from NAMEIGNORE_ROW_ON_DUPKEY_INDEX HintWhen a statement of the form INSERT INTO target subquery runs, a unique key for some rows to be inserted might collide with existing rows. Suppose that you want your application to ignore such collisions and insert the rows that do not collide with existing rows.Before Release 11.2, you had to write a PL/SQL program which, in a block with a NULL handler for the DUP_VAL_ON_INDEX exception, selected the source rows and then inserted them, one at a time, into the target.As of Release 11.2, you do not have to write a PL/SQL program. You can use the IGNORE_ROW_ON_DUPKEY_INDEX hint in an INSERT statement, which is easier to write and runs much faster.CHANGE_DUPKEY_ERROR_INDEX HintWhen an INSERT or UPDATE statement runs, a unique key might collide with existing rows.Before Release 11.2, the collision caused error ORA-00001. You could tell that a collision had occurred, but you could not tell where.As of Release 11.2, you can use the CHANGE_DUPKEY_ERROR_INDEX hint in an INSERT or UPDATE statement, specifying that when a unique key violation occurs for a specified index or set of columns, ORA-38911 is reported instead of ORA-00001. This hint is especially helpful when implementing crossedition triggers.
  11. alter database default edition = &lt;x&gt; -&gt; has as side effect : grant use on edition &lt;x&gt; to publicsys.dbms_sys_sql.parse(_as_user) has additional parameters: Editionapply_crossedition_triggerfire_apply_trigger
  12. alter database default edition = &lt;x&gt; -&gt; has as side effect : grant use on edition &lt;x&gt; to publicsys.dbms_sys_sql.parse(_as_user) has additional parameters: Editionapply_crossedition_triggerfire_apply_trigger
  13. * = ALL, USER or DBA
  14. ALTER SESSION SET EDITION doesn’t work. Must be a top-level SQL statement. We can’t do that in APEX.DBMS_SESSION.SET_EDITION_DEFERRED sets the edition of yourcurrentsession (mightbe different fromyournextsession) select owner, object_name, object_id from all_objects where object_type = &apos;EDITION&apos;; select ses.sid, ses.username, ses.session_edition_id, obj.object_namefrom v_$sessionses, all_objectsobjwhere username in (‘ANONYMOUS’,’APEX_PUBLIC_USER’)And ses.session_edition_id = obj.object_id(ses_id.sql)
  15. FAIL : /home/oracle/OraHome_1/Apache/Apache/bin/apachectl start: execinghttpdSyntax error on line 48 of /home/oracle/OraHome_1/Apache/modplsql/conf/dads.conf:Invalid command &apos;PlsqlDatabaseEdition&apos;, perhaps mis-spelled or defined by a module not included in the server configuration = BUG!!
  16. That way we can separate the user-interface-layer (the way the information is rendered in the browser), the business-layer (what data is shown and what rules the input should comply to) and the data-layer (the editioning views and the tables itself). This way a three-tier-architecture is not sufficient: we even need a four-tier-architecture!