SlideShare uma empresa Scribd logo
1 de 357
Baixar para ler offline
NOTE

     itty bitty fonts in this
           presentation


               SQL> exec sample_font




Can you read this ?
                                       1
Connor McDonald
    OracleDBA



                co.uk




                        2
3
bio slide




            4
Connor McDonald
6
"why bother?"




                7
2007   2008       2009     2010     2011   2012     2013      2014     2015



11g    11.1.0.7     11.2
                                      11g
                                  desupported

                                                management
                                                 visibility



                                                                     11.1.0.6
"why bother?"
   (part 2)




                9
don’t reinvent
Connor McDonald 11g for developers
there's a lot in 11g !




                         12
<apology>




</apology>
some cool things....




                       14
some not so cool things....




                              15
"11g is now production"




                          16
17
11g   ≠
          18
19
coolness barometer




                     20
first impressions




                    21
22
ORA-01017: invalid username/password; logon denied




                                                     23
ORA-28000: the account is locked




                                   24
case sensitive passwords




                           25
default profile tightened




                            26
password complexity




                      27
be patient




             28
29
snippets




           30
snippets #1:

sqlplus BLOBS




                31
10g and below




                32
SQL> select PASSPORT_PHOTO
  2 from    PERSON
  3 where surname = 'MCDONALD'
  4 /
SP2-0678: Column type can not be displayed by SQL*Plus




                                                     33
SQL>   select PASSPORT_PHOTO
  2    from   PERSON
  3    where surname = 'MCDONALD'
  4    /

MUGSHOT_BLOB
-----------------------------------------------------
D0CF11E0A1B11AE1000000000000000000000000000000003E000
02300000001000000FEFFFFFF0000000020000000




                                                        34
snippets #2:

sqlplus error logging




                        35
SQL> set errorlogging on




                           36
SQL> set errorlogging on

SQL> desc SPERRORLOG

 Name                                    Type
 -------------------------------------   ----------------
 USERNAME                                VARCHAR2(256)
 TIMESTAMP                               TIMESTAMP(6)
 SCRIPT                                  VARCHAR2(1024)
 IDENTIFIER                              VARCHAR2(256)
 MESSAGE                                 CLOB
 STATEMENT                               CLOB




                                                            37
SQL> select * from THE_WRONG_NAME;
select * from THE_WRONG_NAME
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> desc THE_WRONG_NAME;

ERROR:
ORA-04043: object THE_WRONG_NAME does not exist

SQL> grant execute on P to NOT_A_USER;

grant execute on P to NOT_A_USER
                      *
ERROR at line 1:
ORA-01917: user or role 'NOT_A_USER' does not exist


                                                      38
SQL> select timestamp, message, statement
  2 from SPERRORLOG;

TIMESTAMP
-----------------------------------------------------
MESSAGE
-----------------------------------------------------
STATEMENT
-----------------------------------------------------
01-APR-08 02.29.58.000000 PM
ORA-00942: table or view does not exist
select * from THE_WRONG_NAME

01-APR-08 02.29.58.000000 PM
ORA-04043: object THE_WRONG_NAME does not exist
desc THE_WRONG_NAME;

01-APR-08 02.30.04.000000 PM
ORA-01917: user or role "NOT_A_USER" does not exist
grant execute on P to NOT_A_USER

                                                        39
SQL> set errorlogging on
SQL> @create_all_objects




installation scripts



            works on 10g too…
                                40
snippets #3:

sqlplus transaction safety




                             41
42
SQL> set exitcommit




                      43
snippets #4:

dbms_utility.get_sql_hash




                            44
SQL> select hash_value
  2 from    v$sql
  3 where sql_text = 'SELECT 99 FROM DUAL';

HASH_VALUE
----------
 835694897




                                              45
SQL> declare
  2    h1 raw(16);
  3    h2 number;                     = 835694897
  4    n int;
  5 begin
  6    n :=
  7      dbms_utility.get_sql_hash(
  8         'SELECT 99 FROM DUAL'||chr(0) ,h1,h2);
  9    dbms_output.put_line(h1);
 10 end;
 11 /
F1D44D227DC0C4E0C719280B31B1CF31
                         31B1CF31



                                                 46
snippets #5:

  listagg




               47
classical problem




                    48
SQL> select deptno, ename
  2 from    emp
  3 order by 1,2;

    DEPTNO   ENAME
----------   ----------
        10   CLARK
        10   KING
        10   MILLER
        20   ADAMS
        20   FORD
        20   JONES
        20   SCOTT
        20   SMITH
        30   ALLEN
        30   BLAKE
        30   JAMES
        30   MARTIN
        30   TURNER
        30   WARD

                            49
DEPTNO   MEMBERS
----------   -------------------------------------
        10   CLARK,KING,MILLER
        20   SMITH,JONES,SCOTT,ADAMS,FORD
        30   ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES




                                                     50
SQL> select deptno , rtrim(ename,',') enames
  2 from ( select deptno,ename,rn
  3         from emp
  4         model
  5         partition by (deptno)
  6         dimension by (
  7            row_number() over
  8             (partition by deptno order by ename) rn
  9               )
 10         measures (cast(ename as varchar2(40)) ename)
 11         rules
 12         ( ename[any]
 13             order by rn desc = ename[cv()]||','||ename[cv()+1])
 14         )
 15   where rn = 1
 16   order by deptno;

    DEPTNO   ENAMES
----------   ----------------------------------------
        10   CLARK,KING,MILLER
        20   ADAMS,FORD,JONES,SCOTT,SMITH
        30   ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD

                                                        - Rob Van Wijk   51
SQL>   select deptno,
  2           substr(max(sys_connect_by_path(ename, ',')), 2) members
  3    from (select deptno, ename,
  4                 row_number ()
  5                   over (partition by deptno order by empno) rn
  6          from emp)
  7    start with rn = 1
  8    connect by prior rn = rn - 1
  9    and prior deptno = deptno
 10    group by deptno
 11    /

    DEPTNO   MEMBERS
----------   ---------------------------------------------------------
        30   ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
        20   SMITH,JONES,SCOTT,ADAMS,FORD
        10   CLARK,KING,MILLER




                                                      - Anon        52
SQL>   select deptno,
  2       xmltransform
  3       ( sys_xmlagg
  4           ( sys_xmlgen(ename)
  5           ),
  6         xmltype
  7         (
  8            '<?xml version="1.0"?><xsl:stylesheet version="1.0"
  9    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 10               <xsl:template match="/">
 11                 <xsl:for-each select="/ROWSET/ENAME">
 12                   <xsl:value-of select="text()"/>;</xsl:for-each>
 13               </xsl:template>
 14             </xsl:stylesheet>'
 15         )
 16      ).getstringval() members
 17    from emp
 18    group by deptno;

    DEPTNO   MEMBERS
----------   --------------------------------------------------------
        10   CLARK;MILLER;KING;
        20   SMITH;FORD;ADAMS;SCOTT;JONES;
        30   ALLEN;JAMES;TURNER;BLAKE;MARTIN;WARD;
                                                      - Laurent Schneider 53
SQL>   create or replace type string_agg_type as object
  2    (
  3       total varchar2(4000),
  4
  5         static function
  6              ODCIAggregateInitialize(sctx IN OUT string_agg_type )
  7              return number,
  8
  9         member function
 10              ODCIAggregateIterate(self IN OUT string_agg_type ,
 11                                   value IN varchar2 )
 12              return number,
 13
 14         member function
 15              ODCIAggregateTerminate(self IN string_agg_type,
 16                                     returnValue OUT varchar2,
 17                                     flags IN number)
 18              return number,
 19
 20         member function
 21              ODCIAggregateMerge(self IN OUT string_agg_type,
 22                                 ctx2 IN string_agg_type)
 23              return number
 24    );
 25    /
                                                        - Tom Kyte       54
55
SQL> select deptno,
  2         listagg( ename, ',')
  3           within group (order by empno) members
  4 from    emp
  5 group by deptno;

    DEPTNO   MEMBERS
----------   -----------------------------------------
        10   CLARK,KING,MILLER
        20   SMITH,JONES,SCOTT,ADAMS,FORD
        30   ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES




                                                         56
Feature:

real time sql monitoring




                           57
58
select e.department_id, sum(salary)
from   emp e,
       job_hist j
where e.employee_id = j.employee_id
and    extract(year from e.hire_date) > 1985
and    j.end_date > j.start_date + 1
and    j.start_date >= e.hire_date
group by e.department_id




                                               59
v$sql_plan




             60
-----------------------------------------------------------------------------
| Id | Operation            | Name     | Rows | Bytes |TempSpc| Cost (%CPU)|
-----------------------------------------------------------------------------
|   0 | SELECT STATEMENT    |          |    36M| 2742M|        | 10998 (48)|
|   1 | HASH GROUP BY       |          |    36M| 2742M|        | 10998 (48)|
|* 2 |    HASH JOIN         |          |    36M| 2742M| 3728K| 9137 (37)|
|* 3 |     TABLE ACCESS FULL| JOB_HIST | 88761 | 2687K|        |   147   (3)|
|* 4 |     TABLE ACCESS FULL| EMP      |   877K|    40M|       | 3028    (2)|
-----------------------------------------------------------------------------




                                                                                61
62
SQL> select
  2    DBMS_SQLTUNE.REPORT_SQL_MONITOR(
  3       sql_id=>'d3ncuxj7629bf',
  4       report_level=>'ALL',
  5       type=>'HTML') as report
  6 from dual;




                                          63
Connor McDonald 11g for developers
Connor McDonald 11g for developers
Connor McDonald 11g for developers
Feature:

     statistics enhancements




67
                               67
68
69
cardinality is everything




70
                                 70
same with Oracle




71
                        71
some real(ish) data




72
                           72
SQL> desc VEHICLE

     Name                       Null?      Type
     -------------------------- --------   -------------
     ID                                    NUMBER
     MAKE                                  VARCHAR2(6)
     MODEL                                 VARCHAR2(6)

 SQL> select count(*)
   2 from    VEHICLE;

     COUNT(*)
 ------------
    2,157,079

73
                                                           73
default stats not enough




74
                                74
SQL> select count(*)
  2 from    VEHICLE
  3 where MAKE = 'HOLDEN';

  COUNT(*)
----------
    415387



------------------------------------------------------------
| Id | Operation          | Name    | Rows | Bytes | Cost |
------------------------------------------------------------
|   0 | SELECT STATEMENT |          |     1 |     7 |   138|
|   1 | SORT AGGREGATE    |         |     1 |     7 |      |
|* 2 |    INDEX RANGE SCAN| MAKE_IX | 55310 |   378K|   138|
------------------------------------------------------------

75
                                                               75
histogram




76
                 76
SQL> begin
       2    dbms_stats.gather_table_stats(user,'VEHICLE',
       3      method_opt=>'for all columns size 1,'||
       4                  'for columns MAKE size 254,'||
       5                  'for columns MODEL size 254');
       6 end;
       7 /

     PL/SQL procedure successfully completed.




77
                                                            77
SQL> select count(*)
  2 from    VEHICLE
  3 where MAKE = 'HOLDEN';

  COUNT(*)
----------
    415387



-----------------------------------------------------------
| Id | Operation          | Name    | Rows | Bytes | Cost |
-----------------------------------------------------------
|   0 | SELECT STATEMENT |          |     1 |     7 | 1024|
|   1 | SORT AGGREGATE    |         |     1 |     7 |       |
|* 2 |    INDEX RANGE SCAN| MAKE_IX |   418K| 2859K| 1024|
-----------------------------------------------------------


78
                                                                78
make AND model




79
                      79
SQL>   select   count(*)
  2    from     VEHICLE
  3    where    MAKE = 'HOLDEN'
  4    and      MODEL = 'COMMODORE';

  COUNT(*)
----------
    214468

--------------------------------------------------------------------
| Id | Operation                         | Name     | Rows | Bytes |
---------------------------------------------------------------------
|   0 | SELECT STATEMENT                 |          |     1 |    14 |
|   1 | SORT AGGREGATE                   |          |     1 |    14 |
|   2 |   BITMAP CONVERSION COUNT        |          | 39527 |   540K|
|   3 |    BITMAP AND                    |          |       |        |
|   4 |     BITMAP CONVERSION FROM ROWIDS|          |       |        |
|* 5 |       INDEX RANGE SCAN            | MODEL_IX |       |        |
|   6 |     BITMAP CONVERSION FROM ROWIDS|          |       |        |
|* 7 |       INDEX RANGE SCAN            | MAKE_IX |        |        |
---------------------------------------------------------------------
  80
                                                                         80
three things




81
                    81
50% of Holdens are Commodores




82
                                     82
83
84
     84
no correlation



            10g and before

85
                             85
----------------------------------------------------------
| Id | Operation                         | Rows | Bytes |
----------------------------------------------------------
|   0 | SELECT STATEMENT                 |     1 |    14 |
|   1 | SORT AGGREGATE                   |     1 |    14 |
|   2 |   BITMAP CONVERSION COUNT        | 39527 |   540K|




  86
                                                         86
SQL> select count(*) from VEHICLE where model = 'COMMODORE';

  COUNT(*)
----------
    214468

SQL> select count(*) from VEHICLE where make = 'HOLDEN';

  COUNT(*)
----------
    415387                         Prob(xy)=Prob(x)*Prob(y)
SQL> select (214468/2157079)*
 2          (415387/2157079)*
 3          2157079 EST_ROWS from dual;

       EST_ROWS
---------------
     41299.9334   ≈ 39527
87
                                                               87
SQL> select
       2    DBMS_STATS.CREATE_EXTENDED_STATS(
       3        user, 'VEHICLE','(MAKE,MODEL)') tag
       4 from dual;

     TAG
     ----------------------------------
     SYS_STU8QPK2S$PEWHARK2CP3#1F#G

     SQL> select COLUMN_NAME,NUM_DISTINCT
       2 from    USER_TAB_COLS
       3 where table_name = 'VEHICLE'

     COLUMN_NAME                    NUM_DISTINCT
     ------------------------------ ------------
     ID                                  2157079
     MAKE                                     39
     MODEL                                   292
     SYS_STU8QPK2S$PEWHARK2CP3#1F#G
88
                                                      88
SQL> begin
  2   dbms_stats.gather_table_stats(user,'VEHICLE',
  3     method_opt=>
  4      'for columns SYS_STU8QPK2S$PEWHARK2CP3#1F#G size 254');
  5 end;
  6 / SQL> begin
         2    dbms_stats.gather_table_stats(user,'VEHICLE',
PL/SQL procedure method_opt=> completed.
         3        successfully
         4         'for columns (make,model) size 254');
         5 end;
         6 /

       PL/SQL procedure successfully completed.




 89
                                                              89
SQL>   select   count(*)
  2    from     VEHICLE
  3    where    MAKE = 'HOLDEN'
  4    and      MODEL = 'COMMODORE';

  COUNT(*)
----------
    214468



-------------------------------------------------------------
| Id | Operation           | Name    | Rows | Bytes | Cost |
------------------------------------------------------------
|   0 | SELECT STATEMENT   |         |     1 |    14 | 1956|
|   1 | SORT AGGREGATE     |         |     1 |    14 |      |
|* 2 |    TABLE ACCESS FULL| VEHICLE |   220K| 3018K| 1956|
-------------------------------------------------------------

 90
                                                                90
actual versus estimate




91
                              91
SQL>   select   /*+ GATHER_PLAN_STATISTICS */ count(*)
  2    from     VEHICLE
  3    where    MAKE = 'HOLDEN'
  4    and      MODEL = 'COMMODORE';

  COUNT(*)
----------
    214468

SQL> SELECT *
  2 FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(
  3              NULL, NULL, 'ALLSTATS LAST'));

----------------------------------------------------------------
| Id | Operation           | Name    | Starts | E-Rows | A-Rows |
----------------------------------------------------------------
|   1 | SORT AGGREGATE     |         |      1 |      1 |      1 |
|* 2 |    TABLE ACCESS FULL| VEHICLE |      1 |    220K|    214K|
-----------------------------------------------------------------
 92
                                                                    92
its just another column




93
                               93
SQL> select "SYS_STU8QPK2S$PEWHARK2CP3#1F#G"
       2 from vehicle
       3 where rownum < 10;

     SYS_STU8QPK2S$PEWHARK2CP3#1F#G
     ------------------------------
                         1.2706E+19
                         1.8075E+19
                         7.9949E+18
                         1.1730E+19
                         6.7142E+18
                         1.1730E+19
                         1.0779E+19
                         5.4051E+18
                         7.3555E+18


94
                                                    94
forget ...




95
                  95
SQL> SELECT extension_name, extension
       2 FROM    USER_STAT_EXTENSIONS
       3 WHERE table_name = 'VEHICLE';

     EXTENSION_NAME                 EXTENSION
     ------------------------------ -----------------
     SYS_STU8QPK2S$PEWHARK2CP3#1F#G ("MAKE","MODEL")




96
                                                        96
SQL> select SYS_OP_COMBINED_HASH(make,model) hashval,
       2         "SYS_STU8QPK2S$PEWHARK2CP3#1F#G" colval
       3 from VEHICLE
       4 where rownum < 10;

        HASHVAL       COLVAL
     ----------   ----------
     1.2706E+19   1.2706E+19
     1.8075E+19   1.8075E+19
     7.9949E+18   7.9949E+18
     1.1730E+19   1.1730E+19
     6.7142E+18   6.7142E+18
     1.1730E+19   1.1730E+19
     1.0779E+19   1.0779E+19
     5.4051E+18   5.4051E+18
     7.3555E+18   7.3555E+18

97
                                                             97
PARSING IN CURSOR #28

     alter table "SH"."VEHICLE" add
         (SYS_STU8QPK2S$PEWHARK2CP3#1F#G
            as (SYS_OP_COMBINED_HASH(MAKE,MODEL))
     virtual BY USER for statistics);

     END OF STMT




98
                                                    98
virtual column




99
                      99
SYS_OP_COMBINED_HASH




100
                             100
hash means equality




101
                            101
SQL>   select   count(*)
  2    from     VEHICLE
  3    where    MAKE in ('FORD','HOLDEN')
  4    and      MODEL = 'COMMODORE';

  COUNT(*)
----------
    214468

-----------------------------------------------------------------------
| Id | Operation             | Name             | Rows | Bytes | Cost
-----------------------------------------------------------------------
|   0 | SELECT STATEMENT     |                  |     1 |    14 | 1921
|   1 | SORT AGGREGATE       |                  |     1 |    14 |
|* 2 |    VIEW               | index$_join$_001 | 77818 | 1063K| 1921
|* 3 |     HASH JOIN         |                  |       |       |
|* 4 |      INDEX RANGE SCAN | MODEL_IX         | 77818 | 1063K|    502
|   5 |     INLIST ITERATOR |                   |       |       |
|* 6 |       INDEX RANGE SCAN| MAKE_IX          | 77818 | 1063K| 2086
-----------------------------------------------------------------------

 102
                                                                     102
can we solve this ?




103
                            103
two enhancements




104
                         104
adaptive cursor sharing

               11.1


105
                                105
11.2




106
             106
much


       much

         better
              107
108
recall




109
               109
cardinality




110
                    110
actual versus estimate




111
                               111
employ someone....




112
                           112
SQL>   select   /*+ GATHER_PLAN_STATISTICS */
                count(*)
  2    from     VEHICLE
  3    where    MAKE = 'HOLDEN'
  4    and      MODEL = 'COMMODORE';

  COUNT(*)
----------
    214468

SQL> SELECT *
  2 FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(
  3              NULL, NULL, 'ALLSTATS LAST'));
                                                    "ok"
-----------------------------------------------------------------
| Id | Operation           | Name    | Starts | E-Rows | A-Rows |
-----------------------------------------------------------------
|   1 | SORT AGGREGATE     |         |      1 |      1 |      1 |
|* 2 |    TABLE ACCESS FULL| VEHICLE |      1 |    220K|    214K|
-----------------------------------------------------------------
 113
                                                                113
114
      114
but just maybe ....




115
                            115
... someone already is




116
                               116
100,000 rows
SQL>   create table EMP as
  2    select rownum empno,
  3        mod(rownum,10) jobid,
  4        mod(rownum,10)*1000 salary,
  5        mod(rownum,50)+1 deptno
  6    from dual
  7    connect by rownum < 100000;
                                         100 rows
SQL>   create table DEPT as
  2    select rownum deptno,
  3          'dept'||rownum dname
  4    from dual
  5    connect by rownum <= 100;


                                                   117
SQL> exec dbms_stats.gather_table_stats(user,'EMP');

SQL> exec dbms_stats.gather_table_stats(user,'DEPT');



SQL> create index EMP_IX on EMP ( deptno );

SQL> create index DEPT_IX on DEPT ( deptno );




                                                        118
SQL>   select e.empno, d.dname                     hard to
  2    from emp e, dept d
  3    where d.deptno = e.deptno                   optimize
  4    and e.jobid = 1
  5    and e.salary > 5000;
    4 and e.jobid = 1
no rows selected

    5 and e.salary > 5000;
----------------------------------------------------------------
| Id | Operation                     | Name    | Rows | Bytes |
----------------------------------------------------------------
|   0 | SELECT STATEMENT             |         |       |       |
|   1 | MERGE JOIN                   |         | 4444 | 104K |
|   2 |   TABLE ACCESS BY INDEX ROWID| DEPT    |   100 | 1000 |
|   3 |    INDEX FULL SCAN           | DEPT_IX |   100 |       |
|* 4 |    SORT JOIN                  |         | 4444 | 62216 |
|* 5 |     TABLE ACCESS FULL         | EMP     | 4444 | 62216 |
----------------------------------------------------------------


                                                                   119
re-run the query




                   120
no changes to anything




                         121
SQL>   select e.empno, d.dname
  2    from emp e, dept d
  3    where d.deptno = e.deptno
  4    and e.jobid = 1
  5    and e.salary > 5000;
no rows selected

---------------------------------------------------
| Id | Operation           | Name | Rows | Bytes |
---------------------------------------------------
|   0 | SELECT STATEMENT   |      |       |       |
|* 1 | HASH JOIN           |      |    89 | 2136 |
|   2 |   TABLE ACCESS FULL| DEPT |     1 |    10 |
|* 3 |    TABLE ACCESS FULL| EMP | 4444 | 62216 |
---------------------------------------------------


                                                      122
11.2




       123
the optimizer knows what "hard" is




                                     124
cardinality feedback loop




                            125
its not continuous learning




                              126
several restrictions




                       127
SQL tuning advisor fallback




                              128
Feature:

result cache




               129
130
SQL> create table MY_TMP as
  2 select ....

Table created.

SQL>   select ...
  2    from   ...
  3    where COL in ( select COL from MY_TMP )
  4    and ...




                                                 131
cache the results of queries




                               132
GTT, plsql table, ...




               hard...


                        single session,
                        expiry issues...
                                           133
memory

SQL> SELECT name, value
  2 FROM    v$parameter
  3 WHERE name LIKE 'result_cache%';

NAME                             VALUE
------------------------------   -----------
result_cache_mode                MANUAL
result_cache_max_size            1081344
result_cache_max_result          5
result_cache_remote_expiration   0




                                               %
                                                   134
SQL>   set autotrace traceonly stat
SQL>   set timing on
SQL>   select owner, count(*)
  2    from   T
  3    group by owner
  4    /

29 rows selected.

Elapsed: 00:00:03.98

Statistics
-----------------------------------------------------
          0 recursive calls
          1 db block gets
      32192 consistent gets
      32184 physical reads
         96 redo size
         [snip]

                                                        135
SQL> /

29 rows selected.

Elapsed: 00:00:03.80

Statistics
-----------------------------------------------------
          0 recursive calls
          1 db block gets
      32192 consistent gets
      32184 physical reads
         96 redo size
         [snip]




                                                        136
SQL>   set autotrace traceonly stat
SQL>   set timing on
SQL>   select /*+ RESULT_CACHE */ owner, count(*)
  2    from   T
  3    group by owner
  4    /

29 rows selected.

Elapsed: 00:00:03.80

Statistics
-----------------------------------------------------
          0 recursive calls
          1 db block gets
      32192 consistent gets
      32184 physical reads
         96 redo size
         [snip]



                                                        137
SQL>   set autotrace traceonly stat
SQL>   set timing on
SQL>   select /*+ RESULT_CACHE */ owner, count(*)
  2    from   T
  3    group by owner
  4    /

29 rows selected.

Elapsed: 00:00:00.04     !!!!!!!!!!!!

Statistics
-----------------------------------------------------
          0 recursive calls
          0 db block gets
          0 consistent gets
          0 physical reads
          0 redo size
         [snip]



                                                        138
cross session




                139
session 1
 SQL>   select /*+ RESULT_CACHE */ owner, count(*)
   2    from   T
   3    group by owner
   4    /

 29 rows selected.

 Elapsed: 00:00:03.80



    session 2
           SQL>   select /*+ RESULT_CACHE */ owner, count(*)
             2    from   T
             3    group by owner
             4    /

           29 rows selected.

           Elapsed: 00:00:00.04

                                                               140
automatic expiry




                   141
SQL>   set timing on
SQL>   select /*+ RESULT_CACHE */ owner, count(*)
  2    from   T
  3    group by owner
  4    /

29 rows selected.

Elapsed: 00:00:00.05

SQL> delete from T where rownum = 1;

1 row deleted.

SQL>   select /*+ RESULT_CACHE */ owner, count(*)
  2    from   T
  3    group by owner
  4    /
                                           active txn
Elapsed: 00:00:03.91

                                                    142
SQL> commit;

Commit complete.

SQL>   select /*+ RESULT_CACHE */ owner, count(*)
  2    from   T
  3    group by owner
  4    /

Elapsed: 00:00:03.91         reinstantiate cache
SQL>   select /*+ RESULT_CACHE */ owner, count(*)
  2    from   T
  3    group by owner
  4    /

Elapsed: 00:00:00.04



                             voila!
                                                    143
11.2




       144
part of table definition




                           145
alter table T result_cache (mode force);




                                           146
dependencies




               147
v$result_cache_objects
v$result_cache_dependency




                            148
SQL>   select
  2       r.name,
  3        listagg(o.name,' ') within group ( order by o.name ) as obj
  4    from    v$result_cache_objects r,
  5            v$result_cache_dependency d,
  6            sys.obj$ o
  7    where r.type = 'Result'
  8    and     r.id =d.result_id
  9    and     d.object_no=o.obj#
 10    group by r.name;

NAME                                             OBJ
------------------------------------------------ ----------------
select /*+ RESULT_CACHE */ owner, count(*)       T
from   T
group by owner

select /*+ RESULT_CACHE */ owner, count(*)         T1 T
from   T, T1
group by owner




                                                                         149
plsql too




            150
SQL> desc COUNTRY_SALES

  Name                Null?      Type
  -----------------   --------   ------------
  CTRY                NOT NULL   VARCHAR2(10)
  CRNCY               NOT NULL   VARCHAR2(3)
  AMOUNT                         NUMBER
  PRODUCT                        VARCHAR2(20)
  TXN_DATE                       DATE
  QUANTITY                       NUMBER(3)




"summarise the sales in $AUD"



                                                151
currency conversion function




                               152
slower...                obscure...




            SOA
       ...awfully complicated
                                      153
SQL> create or replace
  2 function CURRENCY_CONVERT(code varchar2) return number is
  3    l_service sys.utl_dbws.service;
  4    l_call     sys.utl_dbws.call;
  5    l_result   sys.anydata;
  6
  7    l_wsdl     varchar2(100);
  8    l_ns       varchar2(100);

       [snip]

 15   begin
 16     l_ns   := 'http://www.webservicex.net/currencyconvertor.asmx';
 17     l_wsdl := 'http://www.webservicex.net/currencyconvertor.asmx?wsdl';

       [snip]

 28
 29    l_result := SYS.UTL_DBWS.INVOKE (
 30      call_handle => l_call,
 31      input_params => l_input_params);

       [snip]

 46     return sys.anydata.accessnumber(l_result);
 47   end;
 48   /

Function created.
                                                                              154
SQL> select sum(CURRENCY_CONVERT(crncy)*amount) tot
  2 from    COUNTRY_SALES
  3 /

       TOT
----------
   4799.62

Elapsed: 00:00:45.36




                                                      155
156
SQL> create or replace
  2 function CURRENCY_CONVERT(code varchar2) return number RESULT_CACHE is
  3    l_service sys.utl_dbws.service;
  4    l_call     sys.utl_dbws.call;
  5    l_result   sys.anydata;
  6
  7    l_wsdl     varchar2(100);
  8    l_ns       varchar2(100);

       [snip]

 15   begin
 16     l_ns   := 'http://www.webservicex.net/currencyconvertor.asmx';
 17     l_wsdl := 'http://www.webservicex.net/currencyconvertor.asmx?wsdl';

       [snip]

 28
 29    l_result := SYS.UTL_DBWS.invoke (
 30      call_handle => l_call,
 31      input_params => l_input_params);

       [snip]

 46     return sys.anydata.accessnumber(l_result);
 47   end;
 48   /

Function created.
                                                                              157
SQL>   select sum(CURRENCY_CONVERT(crncy)*amount) tot
  2    from   COUNTRY_SALES
  3    where rownum < 100
  4    /

       TOT
----------
   4799.62                              inter-row
Elapsed: 00:00:15.78                  cache benefit
SQL> /

       TOT
----------
   4799.62                              all values
Elapsed: 00:00:00.02                      cached

                                                        158
explain plan




               159
SQL>   select /*+ RESULT_CACHE */ owner, max(object_id)
  2    from   T
  3    group by owner
  4    /

--------------------------------------------------------------------------
| Id | Operation            | Name                       | Rows | Bytes |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT    |                            |    19 |   171 |
|   1 | RESULT CACHE        | b82qdu5m139yr3fbna1x5r6g2d |       |       |
|   2 |   HASH GROUP BY     |                            |    19 |   171 |
|   3 |    TABLE ACCESS FULL| T                          | 2201K|    18M |
--------------------------------------------------------------------------




                         indeterminate
                                                                             160
SQL> select status
  2 from    v$result_cache_objects
  3 where cache_id = 'b82qdu5m139yr3fbna1x5r6g2d';

STATUS
---------
Published



 ?   New -
     Published -
                   Result is still under construction
                   Result is available for use
     Bypass -      Result will be bypassed from use
     Expired -     Result has exceeded expiration time
     Invalid -     Result is no longer available for use



                                                           161
select /*+ RESULT_CACHE */ …




           two people, same query




                               select /*+ RESULT_CACHE */ …

                                                              162
when in doubt...

...try to break it




                     163
164
165
166
SQL>   create or replace
  2    function SLOW(n number) return number
  3    is
  4    begin
  5      dbms_lock.sleep(1);
  6      return n;
  7    end;
  8    /

Function created.




                                               167
SQL> select /*+ RESULT_CACHE */ owner, slow(object_id)
  2 from    T
  3 where rownum <= 120;

Elapsed: 00:02:01.13
--------------------------------------------------------------------------
| Id | Operation            | Name                       | Rows | Bytes |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT    |                            |   119 | 1071 |
|   1 | RESULT CACHE        | 14tnr7dxmvkp3244d69tw72z4p |       |       |
|* 2 |    COUNT STOPKEY     |                            |       |       |
|   3 |    TABLE ACCESS FULL| T                          |   119 | 1071 |
--------------------------------------------------------------------------




                                                                             168
SQL> select /*+ RESULT_CACHE */ owner, slow(object_id)
  2 from    T
  3 where rownum < 120;

[5 seconds later...]

OWNERSQL> select status         SLOW(OBJECT_ID)
       2 from    v$result_cache_objects
------------------------------ ---------------
SYS    3 where cache_id = '14tnr7dxmvkp3244d69tw72z4p';
                                             20
SYS                                          46
SYS STATUS 2
  session                                    28
SYS  ---------                               15
SYS  New                                     29
  SQL> select /*+ RESULT_CACHE */ owner, slow(object_id)
[still from
    2 executing...]
               T
    3 where rownum < 120;

 [executing...]

 Elapsed: 00:03:03.54   !!!!!!!!!

                                                           169
SQL> select sid,
  2         decode(lockwait,null,status,'BLOCKED') status
  3 from v$session
  4 where username = 'CONNOR';

       SID   STATUS
----------   --------
       131   ACTIVE
       143   BLOCKED




                        uh oh....



                                                            170
PARSING IN CURSOR #5 len=82 dep=0 uid=88 oct=3 lid=88

select /*+ RESULT_CACHE */ owner, slow(data_object_id)
from   T
where rownum < 120
END OF STMT

PARSE #5:c=15625,e=28756,p=0,cr=0,cu=0,mis=1,r=0,tim=202781578
EXEC #5:c=0,e=60,p=0,cr=0,cu=0,mis=0,r=0,tim=202781659

WAIT   #5:   nam='enq:   RC   -   Result   Cache:   Contention'   ela=   10005714
WAIT   #5:   nam='enq:   RC   -   Result   Cache:   Contention'   ela=   10002485
WAIT   #5:   nam='enq:   RC   -   Result   Cache:   Contention'   ela=   10002804
WAIT   #5:   nam='enq:   RC   -   Result   Cache:   Contention'   ela=   10002549
WAIT   #5:   nam='enq:   RC   -   Result   Cache:   Contention'   ela=   10005258
WAIT   #5:   nam='enq:   RC   -   Result   Cache:   Contention'   ela=   10002461

WAIT #5: nam='direct path read' ela= 13770 file number=4 ...
WAIT #5: nam='direct path read' ela= 25 file number=4 ...
[etc]




                                                                                    171
better in 11.2




                 172
PARSING IN CURSOR #5 len=82 dep=0 uid=88 oct=3 lid=88

select /*+ RESULT_CACHE */ owner, slow(data_object_id)
from   T
where rownum < 120
END OF STMT

PARSE #5:c=15625,e=28756,p=0,cr=0,cu=0,mis=1,r=0,tim=202781578
EXEC #5:c=0,e=60,p=0,cr=0,cu=0,mis=0,r=0,tim=202781659

WAIT #5: nam='enq: RC - Result Cache: Contention' ela= 10005714

WAIT #5: nam='direct path read' ela= 13770 file number=4 ...
WAIT #5: nam='direct path read' ela= 25 file number=4 ...
...




                                                                  173
"take care....."

                   174
175
not too short....



why bother with result cache?
                           176
not too long....



might lock other people out
                          177
Feature:

compound triggers




                    178
example: table audit




                       179
SQL> desc T

 Name                            Null?      Type
 -----------------------------   --------   -------------
 OWNER                           NOT NULL   VARCHAR2(30)
 OBJECT_NAME                     NOT NULL   VARCHAR2(30)


SQL> desc T_AUDIT

 Name                            Null?    Type
 -----------------------------   -------- --------------
 AUDIT_DATE                               DATE
 AUDIT_ACTION                             CHAR(1)
 OWNER                           NOT NULL VARCHAR2(30)
 OBJECT_NAME                     NOT NULL VARCHAR2(30)



                                                            180
SQL>   create or replace
  2    trigger AUDIT_TRG
  3    after insert or update or delete on T
  4    for each row
  5    declare
  6      v_action varchar2(1) := case when updating then 'U'
  7                          when deleting then 'D' else 'I' end;
  8    begin
  9      if updating or inserting then
 10          insert into T_AUDIT
 11          values (sysdate
 12                 ,v_action
 13                 ,:new.owner
 14                 ,:new.object_name);
 15      else
 16          insert into T_AUDIT
 17          values (sysdate
 18                 ,v_action
 19                 ,:old.owner
 20                 ,:old.object_name);
 21      end if;
 22    end;
 23    /

Trigger created.
                                                                    181
works but slow...




                    182
SQL> insert      into T
   2 select      owner, object_name
   3 from        all_objects
insert where
   4 into T      rownum <= 10000;
select owner, object_name
from   all_objects
10000 rownum <= 10000
where   rows created.
call     count       cpu    elapsed     disk     query    current         rows
------- ------   ------- ---------- -------- --------- ----------   ----------
Parse        1      0.01       0.00        0         0          0            0
Execute      1      3.10       3.05       88       123      10642        10000
Fetch        0      0.00       0.00        0         0          0            0
------- ------   ------- ---------- -------- --------- ----------   ----------
total        2      3.12       3.06       88       123      10642        10000

INSERT INTO T_AUDIT
VALUES (SYSDATE ,:B3 ,:B1 ,:B2 )


call     count       cpu    elapsed     disk     query    current         rows
------- ------   ------- ---------- -------- --------- ----------   ----------
Parse        1      0.00       0.00        0         0          0            0
Execute 10000       0.79       0.97        2       109      10845        10000
Fetch        0      0.00       0.00        0         0          0            0
------- ------   ------- ---------- -------- --------- ----------   ----------
total    10001      0.79       0.97        2       109      10845        10000

                                                                             183
bulk binding


          "hard"

                   184
create or replace
package T_PKG is

  type each_row is record ( action varchar2(1),
                            owner varchar2(30),
                            object_name varchar2(30)
                           );

  type row_list is table of each_row
        index by pls_integer;

  g    row_list;

end;
/




                                                       185
create or replace
trigger AUDIT_TRG1
before insert or update or delete on T
begin
  t_pkg.g.delete;
end;
/




                                         186
create or replace
trigger AUDIT_TRG2
after insert or update or delete on T
for each row
begin
  if updating or inserting then
     t_pkg.g(t_pkg.g.count+1).owner       := :new.owner;
     t_pkg.g(t_pkg.g.count).object_name   := :new.object_name;
  else
     t_pkg.g(t_pkg.g.count).owner         := :old.owner;
     t_pkg.g(t_pkg.g.count).object_name   := :old.object_name;
  end if;
end;
/




                                                                 187
create or replace
trigger AUDIT_TRG3
after insert or update or delete on T
declare
  v_action varchar2(1) :=
     case when updating then 'U'
          when deleting then 'D'
          else 'I' end;
begin
  forall i in 1 .. t_pkg.g.count
      insert into T_AUDIT
      values (
         sysdate,
         v_action,
         t_pkg.g(i).owner,
         t_pkg.g(i).object_name);
  t_pkg.g.delete;
end;
/

                                        188
SQL> insert       into T
   2 select       owner, object_name
   3 from         all_objects
 insert into T
   4 where        rownum <= 10000;
 select owner, object_name
 from   all_objects
10000 rows created.
 where rownum <= 10000

 call     count        cpu   elapsed     disk      query    current         rows
 ------- ------    ------- --------- -------- ---------- ----------   ----------
 Parse        1       0.00      0.00        0         33          0            0
 Execute      1       0.56      0.58        0         91      10653        10000
 Fetch        0       0.00      0.00        0          0          0            0
 ------- ------    ------- --------- -------- ---------- ----------   ----------
 total        2       0.56      0.59        0        124      10653        10000

 INSERT INTO T_AUDIT
 VALUES
  ( SYSDATE, :B1 , :B2 , :B3 )


 call     count        cpu   elapsed     disk      query    current         rows
 ------- ------    ------- --------- -------- ---------- ----------   ----------
 Parse        1       0.00      0.00        0          0          0            0
 Execute      1       0.04      0.03        0         90        478        10000
 Fetch        0       0.00      0.00        0          0          0            0
 ------- ------    ------- --------- -------- ---------- ----------   ----------
 total        2       0.04      0.03        0         90        478        10000
                                                                               189
additional package



         no one did it ....



                     three triggers

                                      190
11g compound triggers




                        191
create or replace
trigger AUDIT_TRG for insert or update or delete on T
compound trigger

  before statement is
  begin
    ...
  end before statement;

  after each row is
  begin
     ...
  end after each row;

  after statement is
  begin
    ...
  end after statement;

end;
/
                                                        192
SQL>   create or replace
  2    trigger AUDIT_TRG for insert or update or delete on T compound trigger
  3
  4      type each_row is record ( action varchar2(1),
  5                                owner varchar2(30),
  6                                object_name varchar2(30));
  7      type   row_list is table of each_row index by pls_integer;
  8      g      row_list;
  9      v_action varchar2(1) :=
 10        case when updating then 'U' when deleting then 'D' else 'I' end;
 11
 12    before statement is
 13    begin
 14      g.delete;
 15    end before statement;
 16
 17    after each row is
 18    begin
 19
 20      if updating or inserting   then
 21        g(g.count+1).owner       := :new.owner;
 22        g(g.count).object_name   := :new.object_name;
 23      else
 24        g(g.count).owner         := :old.owner;
 25        g(g.count).object_name   := :old.object_name;
 26      end if;
 27    end after each row;
 28
 29    after statement is
 30    begin
 31      forall i in 1 .. g.count
 32          insert into T_AUDIT
 33          values (sysdate,v_action,g(i).owner,g(i).object_name);
 34      g.delete;
 35    end after statement;
 36
 37    end;
 38    /
                                                                                193
Trigger created.
one more thing on triggers...




                                194
the 107 slides you didn't see




                                195
SQL>   create or replace
  2    trigger AUDIT_TRG
  3    after insert or update or delete on T
  4    for each row
  5    declare
  6      v_action varchar2(1) :=
  7        case when updating then 'U'
  8             when deleting then 'D' else 'I' end case;
  9    begin
 10      if updating or inserting then
 11         insert into T_AUDIT
 12         values(sysdate,v_action,:new.owner,:new.object_name);
 13      else
 14         insert into T_AUDIT
 15         values(sysdate,v_action,:old.owner,:old.object_name);
 16      end if;
 17    end;
 18    /

Warning: Trigger created with compilation errors.

SQL> sho err
Errors for TRIGGER AUDIT_TRG:

LINE/COL ERROR
-------- -----------------------------------------------------------------
4/46     PLS-00103: Encountered the symbol "CASE" when expecting one of
         the following:
         * & = - + ; < / > at in is mod remainder not rem
         <an exponent (**)> <> or != or ~= >= <= <> and or like like2        196
SQL>   create or replace
  2    trigger AUDIT_TRG
  3    after insert or update or delete on T
  4    for each row
  5    declare
  6      v_action varchar2(1) :=
  7        case when updating then 'U'
  8             when deleting then 'D' else 'I' end;
  9    begin
 10      if updateing or inserting then
 11         insert into T_AUDIT
 12         values(sysdate,v_action,:new.owner,:new.object_name);
 13      else
 14         insert into T_AUDIT
 15         values(sysdate,v_action,:old.owner,:old.object_name);
 16      end if;
 17    end;
 18    /

Warning: Trigger created with compilation errors.

SQL> sho err
Errors for TRIGGER AUDIT_TRG:

LINE/COL   ERROR
--------   -----------------------------------------------------------------
6/3        PL/SQL: Statement ignored
6/6        PLS-00201: identifier 'UPDATEING' must be declared

                                                                               197
SQL>   create or replace
  2    trigger AUDIT_TRG
  3    after insert or update or delete on T
  4    for each row
  5    declare
  6      v_action varchar2(1) :=
  7        case when updating then 'U'
  8             when deleting then 'D' else 'I' end;
  9    begin
 10      if updating or inserting then
 11         insert into TAUDIT
 12         values(sysdate,v_action,:new.owner,:new.object_name);
 13      else
 14         insert into T_AUDIT
 15         values(sysdate,v_action,:old.owner,:old.object_name);
 16      end if;
 17    end;
 18    /

Warning: Trigger created with compilation errors.

SQL> sho err
Errors for TRIGGER AUDIT_TRG:

LINE/COL   ERROR
--------   ------------------------------------------------------
7/6        PL/SQL: SQL Statement ignored
7/18       PL/SQL: ORA-00942: table or view does not exist

                                                                    198
SQL>   create or replace
  2    trigger AUDIT_TRG
  3    after insert or update or delete on T
  4    for each row
  5    declare
  6      v_action varchar2(1) :=
  7        case when updating then 'U'
  8             when deleting then 'D' else 'I' end;
  9    begin
 10      if updating or inserting then
 11         insert into T_AUDIT
 12         values(sysdate,v_action,:new.owner,new.object_name);
 13      else
 14         insert into T_AUDIT
 15         values(sysdate,v_action,:old.owner,:old.object_name);
 16      end if;
 17    end;
 18    /

Warning: Trigger created with compilation errors.

SQL> sho err
Errors for TRIGGER AUDIT_TRG:

LINE/COL   ERROR
--------   ---------------------------------------------------------
10/6       PL/SQL: SQL Statement ignored
11/45      PL/SQL: ORA-00984: column not allowed here

                                                                       199
etc etc etc




              200
Which of the following is the largest ?




                                          201
T




    202
SQL> insert into T values ('X','Y');

insert into T values ('X','Y')
            *
ERROR at line 1:
ORA-04098: trigger 'CONNOR.AUDIT_TRG' is
   invalid and failed re-validation




                                           203
Feature:

11g disabled triggers




                        204
SQL>   create or replace
  2    trigger AUDIT_TRG
  3    after insert or update or delete on T
  4    for each row
  5    DISABLE
  6    declare
  7      v_action varchar2(1) :=
  8         case when updating then 'U'
  9              when deleting then 'D' else 'I' end;
 10    begin
 11      if updating or inserting then
 12          insert into T_AUDIT
 13          values(sysdate,v_action,:new.owner,:new.object_name);
 14      else
 15          insert into T_AUDIT
 16          values(sysdate,v_action,:old.owner,old.object_name);
 17      end if;
 18    end;
 19    /

Warning: Trigger created with compilation errors.


                                                                     205
SQL> select status from user_triggers
  2 where trigger_name = 'AUDIT_TRG';

STATUS
--------
DISABLED

SQL> insert into T values ('X','Y');

1 row created.




                                        206
Feature:

Dependency tracking




                      207
10g and below




                208
SQL> create table T ( x number, y number );

Table created.

SQL> create or replace
  2 view MY_VIEW as
  3 select x,y from T;

View created.




                                              209
SQL> alter table T add Z number;

Table altered.

SQL> select status
  2 from user_objects
  3 where object_name = 'MY_VIEW';

STATUS
-------
INVALID




                                     210
11g




      211
better granularity




                     212
SQL> alter table T add Z number;

Table altered.

SQL> select status
  2 from user_objects
  3 where object_name = 'MY_VIEW';

STATUS
-------
VALID




                                     213
plsql too




            214
quick review




               215
"always use packages"




                        216
ALL production code !




                        217
218
break the invalidation chain




                               219
proc A   proc B   proc C   proc D




pack A   pack B   pack C   pack D



body A   body B   body C   body D


                                    220
11g




      221
change the spec as well !




                            222
pack A   pack B   pack C   pack D




body A   body B   body C   body D




                                    223
SQL>   create or replace
  2    package PKG is
  3      procedure P1;
  4    end;
  5    /

        SQL> create or replace
Package created.
           2 procedure PRC is
           3 begin
SQL> create or replace
           4    pkg.p1;
  2 package body PKG is
  3        5 end;
       procedure P1 is
  4      x6 /
           number;
  5      begin
  6       Procedure created.
            x := 1;
  7      end;
  8    end;
  9    /

Package body created.


                                 224
SQL>   create or replace
  2    package PKG is
  3      procedure P1;
  4      procedure P2;
  5    end;
  6    /

Package created.

SQL>   create or replace
  2    package body PKG is
  3      procedure P1 is
  4        x number;
  5      begin
  6        x := 1;
  7      end;
  8
  9      procedure p2 is
 10         x number;
 11      begin
 12         x := myseq.nextval;
 13      end;
 14    end;
 15    /

Package body created.
                                  225
SQL> select status

                                 10g and below
  2 from user_objects
  3 where object_name = 'PRC';

STATUS
-------
INVALID




SQL> select status

                                      11g
  2 from user_objects
  3 where object_name = 'PRC';

STATUS
-------
VALID


                                                 226
package D




            227
the order is important




                         228
SQL>   create or replace
  2    package PKG is
  3      procedure p1;
  4    end;
  5    /

Package created.

SQL>   create or replace
  2    package body PKG is
  3      procedure p1 is
  4        x number;
  5      begin
  6        x := 1;
  7      end;
  8
  9    end;
 10    /

Package body created.


                             229
SQL>   create or replace
  2    package PKG is
  3      procedure p2;
  4      procedure p1;
  5    end;
  6    /

Package created.

SQL>   create or replace
  2    package body PKG is
  3      procedure p2 is
  4        x number;
  5      begin
  6        x := myseq.nextval;
  7      end;
  8
  9      procedure p1 is
 10        x number;
 11      begin
 12        x := 1;
 13      end;
 14
 15    end;
 16    /

Package body created.            230
moral of the story




                     231
change package bodies
     (as before)




                        232
add to bottom of specs




                         233
this is NOT about package state




                                  234
SQL>   create or replace
  2    package PKG is
  3      procedure p1;
  4    end;
  5    /

Package created.

SQL>   create or replace
  2    package body PKG is
  3
  4      my_global_var date;
  5
  6      procedure p1 is
  7         x number;
  8      begin
  9         if my_global_var is null then
 10           my_global_var := sysdate;
 11         end if;
 12      end;
 13    end;
 14    /

Package body created.

                                            235
SQL> create or replace
  2  procedure PRC is
  3  begin
                 SQL> create or replace
  4    pkg.p1;
                    2 package body PKG is
  5  end;
                    3
  6  /
                    4   my_global_var date;
                    5
Procedure created.
                    6   procedure p1 is
                    7     x number;
SQL> exec PRC;
                    8   begin
                    9     if my_global_var is null then
SQL> exec PRC;
                   10        my_global_var := sysdate;
                   11     end if;
BEGIN PRC; END;
                   12   end;
                   13 end;
*
                   14 /
ERROR at line 1:
ORA-04068: existing state of packages has been discarded
                 Package body created.
ORA-04061: existing state of package body "PKG" has been invalidated
ORA-04065: not executed, altered or dropped package body "PKG"
ORA-06508: PL/SQL: could not find program unit being called: "PKG"
ORA-06512: at "PRC", line 3
ORA-06512: at line 1
                                                                   236
minimise global variables



  keep stateful data separate


              store types separately


                                       237
you may have noticed...




                          238
SQL>   create or replace
  2    package body PKG is
  3      procedure p2 is
  4        x number;
  5      begin
  6        x := myseq.nextval;
  7      end;
  8
  9     procedure p1 is
 10       x number;
 11     begin
 12       x := 1;
 13     end;
 14
 15    end;
 16    /

Package body created.

                                 239
Direct sequence access




                         240
241
can we reduce the risk further ?




                                   242
Feature:

editions




           243
SQL> create or replace
  2 procedure THE_SINGLE_MOST_IMPORTANT_PROC_IN_MY_APP is
     begin
        ....




                                                            244
11.2




       245
246
"version control"




                    247
package PKG is      package PKG(V2) is

select COL1, COL2   select COL1, NEW_COL
from   MY_VIEW      from   MY_VIEW(V2)




      both in active use !

                                           248
SQL> desc DBA_EDITIONS

 Name                          Null?      Type
 ----------------------------- --------   -------------
 EDITION_NAME                  NOT NULL   VARCHAR2(30)
 PARENT_EDITION_NAME                      VARCHAR2(30)
 USABLE                                   VARCHAR2(3)




                                                          249
SQL> select *
  2 from    DBA_EDITIONS;

EDITION_NAME PARENT_EDITION USABLE
------------ -------------- ------
ORA$BASE                    YES




                                     250
PKG1   PKG2   PKG3   PKG4   PKG5   ora$base




PKG1          PKG3          PKG5   version2




                                          251
no space =

probably editionable




                       252
indexes




          253
Invisible indexes




                    254
tables




         255
views




        256
create view V_MY_TABLE   as
             select V1_COL1      as   col1,
                    V1_COL2      as   col2,            version1
                    V1_COL3      as   col3,
                    V1_ONLY_COL4 as   col4,
             from   MY_TABLE

SQL> desc MY_TABLE
 Name                          Null?      Type
 ----------------------------- --------   -----------------
 V1_COL1                                  NUMBER
 V1_COL2                                  DATE
 V1_COL3                                  VARCHAR2(10)
 V1_ONLY_COL4                             VARCHAR2(10)
 V2_NEWCOL5                               DATE
 V2_NEWCOL6                               NUMBER


             create view V_MY_TABLE   as
             select V1_COL1      as   col1,
                    V1_COL2      as   col2,
                    V1_COL3      as   col3,            version2
                    V2_NEWCOL5   as   col5,
                    V2_NEWCOL6   as   col6
             from   MY_TABLE
                                                                  257
editioning views
  (special)




                   258
basic example




                259
SQL> desc EMP

 Name                          Null?      Type
 ----------------------------- --------   -------------
 EMPNO                         NOT NULL   NUMBER(4)
 ENAME                                    VARCHAR2(10)
 JOB                                      VARCHAR2(9)
 MGR                                      NUMBER(4)
 HIREDATE                                 DATE
 SAL                                      NUMBER(7,2)
 COMM                                     NUMBER(7,2)
 DEPTNO                                   NUMBER(2)




                                                          260
SQL>   create or replace
  2    package body EMP_MAINT is
  3      procedure hire_emp(p_empno emp.empno%type,
  4                          p_ename emp.ename%type,
  5                          p_job    emp.job%type,
  6                          p_sal    emp.sal%type,
  7                          p_deptno emp.deptno%type) is
  8      begin
  9         insert into EMP
 10           (empno,ename,job,sal,deptno)
 11         values
 12           (p_empno,p_ename,p_job,p_sal,p_deptno);
 13      end;
 14    end;
 15    /

Package body created.




                                                            261
version 2




            262
SQL> desc EMP

 Name                          Null?      Type
 ----------------------------- --------   -------------
 EMPNO                         NOT NULL   NUMBER(4)
 ENAME                                    VARCHAR2(10)
 JOB                                      VARCHAR2(9)
 MGR                                      NUMBER(4)
 HIREDATE         Contract/Permanent      DATE
 SAL                                      NUMBER(7,2)
 COMM                                     NUMBER(7,2)
 DEPTNO                                   NUMBER(2)
 ETYPE                                    VARCHAR2(10)
 TERMINATION_DATE                         DATE


                      End of Contract



                                                          263
old style




            264
SQL> alter table EMP add ETYPE VARCHAR2(1);

Table altered.

SQL> alter table EMP add TERMINATION_DATE   DATE;

Table altered.

SQL> update EMP set ETYPE = 'Permanent';

14 rows updated.

SQL> alter table EMP modify ETYPE not null;

Table altered.

SQL> alter table EMP add constraint
  2    EMP_CHK01 check ( ETYPE in ('Contract',
                                    'Permanent'));

Table altered.
                                                     265
broken application




                     266
SQL> exec EMP_MAINT.HIRE_EMP(1,'Sue','SALES',10,10)

BEGIN EMP_MAINT.HIRE_EMP(1,'Sue','SALES',10,10); END;

*
ERROR at line 1:
ORA-01400: cannot insert NULL into ("SCOTT"."EMP"."ETYPE")
ORA-06512: at "SCOTT.EMP_MAINT", line 8
ORA-06512: at line 1




                                                             267
outage




         268
SQL>   create or replace
  2    package body EMP_MAINT is
  3      procedure hire_emp(p_empno emp.empno%type,
  4                          p_ename emp.ename%type,
  5                          p_job    emp.job%type,
  6                          p_sal    emp.sal%type,
  7                          p_deptno emp.deptno%type,
  8                          p_etype emp.etype%type,
  9                          p_term   emp.termination_date%type) is
 10      begin
 11         insert into EMP
 12           (empno,ename,job,sal,deptno,etype,termination_date)
 13         values
 14           (p_empno,p_ename,p_job,p_sal,p_deptno,p_etype,p_term);
 15      end;
 16    end;
 17    /

Package body created.



                                                                       269
now with editions




                    270
step 1




         271
enable editions




                  272
SQL> alter user SCOTT enable editions;

User altered.




                                         273
this is a big deal




                     274
Enabling editions is retroactive and irreversible.


                              - 11g2 doc



                                                 275
step 2




         276
abstract your tables




                       277
SQL> alter table EMP rename to "_EMP";

Table altered.

SQL> create or replace
  2 editioning view EMP as
  3 select * from "_EMP";

View created.

SQL> exec dbms_utility.compile_schema(user)

PL/SQL procedure successfully completed.


                                              278
obtuse


_EMP


         279
SQL> select * from _EMP;

select * from _EMP
              *
ERROR at line 1:
ORA-00911: invalid character




                               280
may mean an outage


   as you upgrade to 11.2

                            281
SQL> alter table "_EMP" add ETYPE VARCHAR2(1);

Table altered.

SQL> alter table "_EMP" add TERMINATION_DATE   DATE;

Table altered.

SQL> alter table "_EMP" add constraint
  2    EMP_CHK01 check ( ETYPE in ('Contract',
                                   'Permanent'));

Table altered.

SQL> alter table "_EMP" modify ETYPE not null;

Table altered.

                                                       282
create an edition




                    283
SQL> create edition "APP_V2"
  2 /

Edition created.




                               284
SQL> conn SCOTT/TIGER

Connected.

SQL> alter session set edition = APP_V2;

ERROR:
ORA-38802: edition does not exist




                                           285
SQL> grant USE on edition APP_V2 to SCOTT;

Grant succeeded.




                                             286
SQL> alter session set edition = APP_V2;

SQL>   create or replace
  2    editioning view EMP as
  3    select * from "_EMP"
  4    /

View created.




                                           287
SQL> alter session set edition = ORA$BASE;

Session altered.

SQL> desc EMP

 Name                          Null?      Type
 ----------------------------- --------   ----------------
 EMPNO                         NOT NULL   NUMBER(4)
 ENAME                                    VARCHAR2(10)
 JOB                                      VARCHAR2(9)
 MGR                                      NUMBER(4)
 HIREDATE                                 DATE
 SAL                                      NUMBER(7,2)
 COMM                                     NUMBER(7,2)
 DEPTNO                                   NUMBER(2)



                                                             288
SQL> alter session set edition = APP_V2;

Session altered.

SQL> desc EMP

 Name                          Null?      Type
 ----------------------------- --------   ---------------
 EMPNO                         NOT NULL   NUMBER(4)
 ENAME                                    VARCHAR2(10)
 JOB                                      VARCHAR2(9)
 MGR                                      NUMBER(4)
 HIREDATE                                 DATE
 SAL                                      NUMBER(7,2)
 COMM                                     NUMBER(7,2)
 DEPTNO                                   NUMBER(2)
 ETYPE                                    VARCHAR2(10)
 TERMINATION_DATE                         DATE

                                                            289
SQL> select sys_context('USERENV',
  2                     'CURRENT_EDITION_NAME') edt
  3 from dual;

EDT
--------------
APP_V2




                                                      290
SQL>   create or replace
  2    package body EMP_MAINT is
  3      procedure hire_emp(p_empno emp.empno%type,
  4                          p_ename emp.ename%type,
  5                          p_job    emp.job%type,
  6                          p_sal    emp.sal%type,
  7                          p_deptno emp.deptno%type,
  8                          p_etype emp.etype%type,
  9                          p_term   emp.termination_date%type) is
 10      begin
 11         insert into EMP
 12           (empno,ename,job,sal,deptno,etype,termination_date)
 13         values
 14           (p_empno,p_ename,p_job,p_sal,p_deptno,p_etype,p_term);
 15      end;
 16    end;
 17    /

Package body created.



                                                                       291
SQL> alter session set edition = ORA$BASE;

Session altered.

SQL> begin
  2   EMP_MAINT.HIRE_EMP(
  3      p_empno =>1,
  4      p_ename =>'Sue',
  5      p_job    =>'SALES',
  6      p_sal    =>10,
  7      p_deptno =>20);
  8 end;
  9 /

PL/SQL procedure successfully completed.


                                             292
SQL> alter session set edition = APP_V2;

Session altered.

SQL> begin
  2   EMP_MAINT.HIRE_EMP(
  3      p_empno =>2,
  4      p_ename =>'Mike',
  5      p_job    =>'SALES',
  6      p_sal    =>10,
  7      p_deptno =>20,
  8      p_etype =>'Contract'
  9      p_term   =>'10-JAN-2012');
 10 end;
 11 /

PL/SQL procedure successfully completed.

                                           293
we're close....




                  294
ETYPE not null




                 295
SQL> alter session set edition = APP_V2;

Session altered.

SQL> begin
  2   EMP_MAINT.HIRE_EMP(
  3      p_empno =>2,
  4      p_ename =>'Mike',
  5      p_job    =>'SALES',
  6      p_sal    =>10,
  7      p_deptno =>20,
  8      p_etype =>null
  9      p_term   =>'10-JAN-2012');
 10 end;
 11 /

PL/SQL procedure successfully completed.

                                           296
constraints not (natively) editionable




                                     297
SQL> alter table "_EMP" add constraint
  2    EMP_CHK02 check (
  3      SYS_CONTEXT('USERENV',
  4                  'CURRENT_EDITION_NAME')
  5          = 'ORA$BASE'
  6      OR ETYPE is not null
  7      );

Table altered.




                                               298
APP_V2

  "everyone has an ETYPE"



cross edition consistency

   APP_V1 (aka ORA$BASE)

    "what is an ETYPE"

                            299
cross edition triggers




                         300
SQL> alter session set edition = APP_V2;

Session altered.


SQL>   CREATE OR REPLACE TRIGGER emp_v1_to_v2
  2    BEFORE INSERT OR UPDATE ON "_EMP"
  3    FOR EACH ROW
  4    FORWARD CROSSEDITION
  5    DISABLE
  6    BEGIN
  7      :new.etype            := nvl(:new.etype,'Permanent');
  8      :new.termination_date := null;
  9    END;
 10    /

Trigger created.



                                                                 301
SQL>   CREATE OR REPLACE TRIGGER emp_v2_to_v1
  2    BEFORE INSERT OR UPDATE ON "_EMP"
  3    FOR EACH ROW
  4    REVERSE CROSSEDITION
  5    DISABLE
  6    BEGIN
  7      ...
  8      ...
  9    END;
 10    /

Trigger created.




                                                302
both in the new edition


    "the working edition is sacred"


                                      303
SQL> alter session set edition = APP_V2;

Session altered.

SQL> alter trigger EMP_V1_TO_V2 enable;

Trigger altered.




                                           304
all new / modified data




                          305
historical data



uncommitted data


                   306
SQL> alter session set edition = ORA$BASE;

Session altered.

SQL>   declare
  2      ok boolean;
  3      scn number;
  4    begin
  5      ok :=
  6       dbms_utility.wait_on_pending_dml('"_EMP"',10, scn);
  7
  8      if ok then
  9         update EMP set sal=sal;
 10      end if;
 11    end;
 12    /

PL/SQL procedure successfully completed.


                                                                307
SQL> select empno, etype from "_EMP";

     EMPNO   ETYPE
----------   ----------
         1   Contract
         2   Contract
      7369   Permanent
      7499   Permanent
      7521   Permanent
      7566   Permanent
      7654   Permanent
      7698   Permanent
      7782   Permanent
      7788   Permanent
      7839   Permanent
      7844   Permanent
      7876   Permanent
      7900   Permanent
      7902   Permanent
      7934   Permanent
                                        308
or DBMS_SQL




              309
or DBMS_PARALLEL_EXECUTE




                           310
voila !




          311
move people over




                   312
SQL>   create or replace
  2    trigger DEFAULT_EDITION
  3    after logon on database
  4    begin
  5      execute immediate
  6        'alter session set edition = APP_V2';
  7    end;
  8    /




                                                   313
SQL>   create or replace
  2    trigger DEFAULT_EDITION
  3    after logon on database
  4    begin
  5      dbms_session.set_edition_deferred( 'APP_V2' );
  7    end;
  8    /




                                                          314
retire old edition



          optional

                     315
how do I get started




                       316
first.... come clean




                       317
318
stop ... taking ... outages




                              319
before
 you
start
         320
321
more complicated


      than you think....

                           322
enabling editions




                    323
probably the whole database




                              324
cross user consistency




                         325
SQL> connect / as sysdba
Connected.

sys@db112> alter user TO_BE_EDITIONED enable editions;

alter user TO_BE_EDITIONED enable editions
*
ERROR at line 1:
ORA-38819: user TO_BE_EDITIONED owns one or more
objects whose type is editionable and that have
noneditioned dependent objects




                                                         326
SQL> alter user TO_BE_EDITIONED enable editions FORCE;

User altered.




                                                         327
SQL> select owner, object_name, status
  2 from    dba_objects
  3 where owner in (
  4    'TO_BE_EDITIONED',
  5    'NOT_EDITIONED');

OWNER             OBJECT_NAME           STATUS
---------------   -------------------   -------
TO_BE_EDITIONED   EMP                   VALID
NOT_EDITIONED     MY_EMPV               INVALID




                                                  328
possibly not so "online"




                           329
sys@db112> alter user TO_BE_EDITIONED enable editions;

alter user TO_BE_EDITIONED enable editions
*
ERROR at line 1:
ORA-38819: user TO_BE_EDITIONED owns one or more
objects whose type is editionable and that have
noneditioned dependent objects




                                                         330
PARSING IN CURSOR #3 len=487 dep=1 uid=0 oct=3 ...
select d.owner#,
       u.name,
       d.name,
       d.namespace,
       d.stime
from   obj$ d,
       dependency$ dep,
       obj$ p,
       user$ u
where d.obj# = dep.d_obj#
and    p.obj# = dep.p_obj#
and    d.remoteowner is null
and    p.owner# = :1
and    d.owner# = u.user#
and    p.type# in (4,5,7,8,9,10,11,12,13,14,22,87)
and ((u.type# != 2 and bitand(u.spare1, 16) = 0
and    u.user#!= p.owner#)
or    (d.type# not in 4,5,7,8,9,10,11,12,13,14,22,87)))


                                                          331
PARSING IN CURSOR #3 len=487 dep=1 uid=0 oct=3 ...
select d.owner#,
       u.name,
       d.name,              dba_dependencies
       d.namespace,
       d.stime
from   obj$ d,
       dependency$ dep,
       obj$ p,
       user$ u
where d.obj# = dep.d_obj#
and    p.obj# = dep.p_obj#
and    d.remoteowner is null
and    p.owner# = :1
and    d.owner# = u.user#
and    p.type# in (4,5,7,8,9,10,11,12,13,14,22,87)
and ((u.type# != 2 and bitand(u.spare1, 16) = 0
and    u.user#!= p.owner#)
or    (d.type# not in 4,5,7,8,9,10,11,12,13,14,22,87)))


                                                          332
PARSING IN CURSOR #3 len=487 dep=1 uid=0 oct=3 ...
select d.owner#,
       u.name,
       d.name,              dba_dependencies
       d.namespace,
       d.stime
from   obj$ d,
       dependency$ dep,
       obj$ p,
       user$ u                      object_type
where d.obj# = dep.d_obj#
and    p.obj# = dep.p_obj#
and    d.remoteowner is null
and    p.owner# = :1
and    d.owner# = u.user#
and    p.type# in (4,5,7,8,9,10,11,12,13,14,22,87)
and ((u.type# != 2 and bitand(u.spare1, 16) = 0
and    u.user#!= p.owner#)
or    (d.type# not in 4,5,7,8,9,10,11,12,13,14,22,87)))


                                                          333
PARSING IN CURSOR #3 len=487 dep=1 uid=0 oct=3 ...
select d.owner#,
       u.name,
       d.name,
       d.namespace,
       d.stime
from   obj$ d,
       dependency$ dep,
       obj$ p,
       user$ u                      object_type
where d.obj# = dep.d_obj#
and
and
       p.obj# = dep.p_obj#
       d.remoteowner is null  editions_enabled
and    p.owner# = :1
and    d.owner# = u.user#
and    p.type# in (4,5,7,8,9,10,11,12,13,14,22,87)
and ((u.type# != 2 and bitand(u.spare1, 16) = 0
and    u.user#!= p.owner#)
or    (d.type# not in 4,5,7,8,9,10,11,12,13,14,22,87)))


                                                          334
select *
from   DBA_DEPENDENCIES
where ( OWNER in ( SELECT username
                    from   dba_users
                    where EDITIONS_ENABLED = 'N' )
  OR TYPE NOT IN (
           'VIEW','SYNONYM','PROCEDURE','FUNCTION'
          ,'PACKAGE','NON-EXISTENT','PACKAGE BODY'
          ,'TRIGGER','TYPE','TYPE BODY'
          ,'LIBRARY','ASSEMBLY')
  )
and    REFERENCED_OWNER = 'TO_BE_EDITIONED'
and    TYPE IN (
           'VIEW','SYNONYM','PROCEDURE','FUNCTION'
          ,'PACKAGE','NON-EXISTENT','PACKAGE BODY'
          ,'TRIGGER','TYPE','TYPE BODY'
          ,'LIBRARY','ASSEMBLY')
and REFERENCED_OWNER != OWNER


                                                     335
table = data store


      for all versions...

                            336
online upgrade ...




                     337
... is not just editions




                           338
version control
                   create index online
     ddl_timeout
                          fallback
               editions
 constraints
                  column naming
 invisible indexes

                                     339
existing processes / scripts




                               340
drop




       341
rename




         342
edition v1

T1     T2




             edition v2

             T2      T1



                          343
edition v1

 col1 _v1 NUMBER




                   edition v2

                    col1 _v2 DATE



                                    344
edition v1

 T1 (PK=col1,col2)




                     edition v2

                      T1 (PK=col1,col3)



                                          345
contexts

   database links

           queues

                VPD

                      FGA
                            346
347
348
wrap up




          349
lots of things not covered




                             350
11g / 11.2 very very nice




                            351
don't get too carried away




                             352
"Oracle 11g is the greatest
invention in the history of man"
                     - Anon, 2008




                                    353
Connor McDonald 11g for developers
Connor McDonald
    OracleDBA



                co.uk




                        355
ORA-00041
“active time limit exceeded - session terminated”



              www.oracledba.co.uk                   356
<apology>

The presentation author apologises
for the gratuitous use of family album
shots, but since his whole family
came to Melbourne for InSync,
he didn't have much choice.

<apology>
                                         357

Mais conteúdo relacionado

Mais procurados

حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلحل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلMohamed Moustafa
 
SQL Tuning 101 - Sep 2013
SQL Tuning 101 - Sep 2013SQL Tuning 101 - Sep 2013
SQL Tuning 101 - Sep 2013Connor McDonald
 
SQL WORKSHOP::Lecture 11
SQL WORKSHOP::Lecture 11SQL WORKSHOP::Lecture 11
SQL WORKSHOP::Lecture 11Umair Amjad
 
了解Oracle rac brain split resolution
了解Oracle rac brain split resolution了解Oracle rac brain split resolution
了解Oracle rac brain split resolutionmaclean liu
 
COIS 420 - Practice02
COIS 420 - Practice02COIS 420 - Practice02
COIS 420 - Practice02Angel G Diaz
 
MySQL Document Store
MySQL Document StoreMySQL Document Store
MySQL Document StoreI Goo Lee
 
Advanced tips of dbms statas
Advanced tips of dbms statasAdvanced tips of dbms statas
Advanced tips of dbms statasLouis liu
 
Understanding Optimizer-Statistics-for-Developers
Understanding Optimizer-Statistics-for-DevelopersUnderstanding Optimizer-Statistics-for-Developers
Understanding Optimizer-Statistics-for-DevelopersEnkitec
 
12c Mini Lesson - Improved Error Handling in PLSQL
12c Mini Lesson - Improved Error Handling in PLSQL12c Mini Lesson - Improved Error Handling in PLSQL
12c Mini Lesson - Improved Error Handling in PLSQLConnor McDonald
 
MySQL partitions tutorial
MySQL partitions tutorialMySQL partitions tutorial
MySQL partitions tutorialGiuseppe Maxia
 
Mssm及assm下索引叶块分裂的测试
Mssm及assm下索引叶块分裂的测试Mssm及assm下索引叶块分裂的测试
Mssm及assm下索引叶块分裂的测试maclean liu
 
Relational DB Course
Relational DB  Course Relational DB  Course
Relational DB Course Sunny U Okoro
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterI Goo Lee
 

Mais procurados (20)

حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلحل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
 
Px execution in rac
Px execution in racPx execution in rac
Px execution in rac
 
SQL Tuning 101 - Sep 2013
SQL Tuning 101 - Sep 2013SQL Tuning 101 - Sep 2013
SQL Tuning 101 - Sep 2013
 
SQL WORKSHOP::Lecture 11
SQL WORKSHOP::Lecture 11SQL WORKSHOP::Lecture 11
SQL WORKSHOP::Lecture 11
 
Analytic SQL Sep 2013
Analytic SQL Sep 2013Analytic SQL Sep 2013
Analytic SQL Sep 2013
 
了解Oracle rac brain split resolution
了解Oracle rac brain split resolution了解Oracle rac brain split resolution
了解Oracle rac brain split resolution
 
COIS 420 - Practice02
COIS 420 - Practice02COIS 420 - Practice02
COIS 420 - Practice02
 
MySQL Document Store
MySQL Document StoreMySQL Document Store
MySQL Document Store
 
MySQLinsanity
MySQLinsanityMySQLinsanity
MySQLinsanity
 
Advanced tips of dbms statas
Advanced tips of dbms statasAdvanced tips of dbms statas
Advanced tips of dbms statas
 
Understanding Optimizer-Statistics-for-Developers
Understanding Optimizer-Statistics-for-DevelopersUnderstanding Optimizer-Statistics-for-Developers
Understanding Optimizer-Statistics-for-Developers
 
12c Mini Lesson - Improved Error Handling in PLSQL
12c Mini Lesson - Improved Error Handling in PLSQL12c Mini Lesson - Improved Error Handling in PLSQL
12c Mini Lesson - Improved Error Handling in PLSQL
 
MySQL partitions tutorial
MySQL partitions tutorialMySQL partitions tutorial
MySQL partitions tutorial
 
SQL Sort Notes
SQL Sort NotesSQL Sort Notes
SQL Sort Notes
 
mysqlHiep.ppt
mysqlHiep.pptmysqlHiep.ppt
mysqlHiep.ppt
 
Mssm及assm下索引叶块分裂的测试
Mssm及assm下索引叶块分裂的测试Mssm及assm下索引叶块分裂的测试
Mssm及assm下索引叶块分裂的测试
 
Best sql plsql material
Best sql plsql materialBest sql plsql material
Best sql plsql material
 
Relational DB Course
Relational DB  Course Relational DB  Course
Relational DB Course
 
Les09
Les09Les09
Les09
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB Cluster
 

Destaque

WebLogic Diagnostic Framework Dr. Frank Munz / munz & more WLS11g
WebLogic Diagnostic Framework  Dr. Frank Munz / munz & more WLS11gWebLogic Diagnostic Framework  Dr. Frank Munz / munz & more WLS11g
WebLogic Diagnostic Framework Dr. Frank Munz / munz & more WLS11gInSync Conference
 
IBM and Oracle Joint Solution Centre
IBM and Oracle Joint Solution CentreIBM and Oracle Joint Solution Centre
IBM and Oracle Joint Solution CentreInSync Conference
 
Frank munz oracle fusion middleware and aws cloud services in sync11
Frank munz oracle fusion middleware and aws cloud services in sync11Frank munz oracle fusion middleware and aws cloud services in sync11
Frank munz oracle fusion middleware and aws cloud services in sync11InSync Conference
 
In sync10 cliffgodwin-appskeynote-final
In sync10 cliffgodwin-appskeynote-finalIn sync10 cliffgodwin-appskeynote-final
In sync10 cliffgodwin-appskeynote-finalInSync Conference
 
Pythian MySQL - database for the web based economy
Pythian   MySQL - database for the web based economyPythian   MySQL - database for the web based economy
Pythian MySQL - database for the web based economyInSync Conference
 
In Sync Running Apps On Oracle
In Sync  Running Apps On OracleIn Sync  Running Apps On Oracle
In Sync Running Apps On OracleInSync Conference
 
In sync10 cliffgodwin-ebs-final
In sync10 cliffgodwin-ebs-finalIn sync10 cliffgodwin-ebs-final
In sync10 cliffgodwin-ebs-finalInSync Conference
 
Achieving a single view of customer
Achieving a single view of customerAchieving a single view of customer
Achieving a single view of customerInSync Conference
 

Destaque (11)

WebLogic Diagnostic Framework Dr. Frank Munz / munz & more WLS11g
WebLogic Diagnostic Framework  Dr. Frank Munz / munz & more WLS11gWebLogic Diagnostic Framework  Dr. Frank Munz / munz & more WLS11g
WebLogic Diagnostic Framework Dr. Frank Munz / munz & more WLS11g
 
IBM and Oracle Joint Solution Centre
IBM and Oracle Joint Solution CentreIBM and Oracle Joint Solution Centre
IBM and Oracle Joint Solution Centre
 
Frank munz oracle fusion middleware and aws cloud services in sync11
Frank munz oracle fusion middleware and aws cloud services in sync11Frank munz oracle fusion middleware and aws cloud services in sync11
Frank munz oracle fusion middleware and aws cloud services in sync11
 
Mnod linsync10 oba
Mnod linsync10 obaMnod linsync10 oba
Mnod linsync10 oba
 
In sync10 cliffgodwin-appskeynote-final
In sync10 cliffgodwin-appskeynote-finalIn sync10 cliffgodwin-appskeynote-final
In sync10 cliffgodwin-appskeynote-final
 
D linsync10 ofa5yrs
D linsync10 ofa5yrsD linsync10 ofa5yrs
D linsync10 ofa5yrs
 
Pythian MySQL - database for the web based economy
Pythian   MySQL - database for the web based economyPythian   MySQL - database for the web based economy
Pythian MySQL - database for the web based economy
 
In Sync Running Apps On Oracle
In Sync  Running Apps On OracleIn Sync  Running Apps On Oracle
In Sync Running Apps On Oracle
 
In sync10 cliffgodwin-ebs-final
In sync10 cliffgodwin-ebs-finalIn sync10 cliffgodwin-ebs-final
In sync10 cliffgodwin-ebs-final
 
P6 r8
P6 r8P6 r8
P6 r8
 
Achieving a single view of customer
Achieving a single view of customerAchieving a single view of customer
Achieving a single view of customer
 

Semelhante a Connor McDonald 11g for developers

OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersConnor McDonald
 
12c Mini Lesson - Inline PLSQL from SQL
12c Mini Lesson - Inline PLSQL from SQL12c Mini Lesson - Inline PLSQL from SQL
12c Mini Lesson - Inline PLSQL from SQLConnor McDonald
 
Connor McDonald Partitioning
Connor McDonald PartitioningConnor McDonald Partitioning
Connor McDonald PartitioningInSync Conference
 
12c for Developers - Feb 2014
12c for Developers - Feb 201412c for Developers - Feb 2014
12c for Developers - Feb 2014Connor McDonald
 
Latin America Tour 2019 - 10 great sql features
Latin America Tour 2019  - 10 great sql featuresLatin America Tour 2019  - 10 great sql features
Latin America Tour 2019 - 10 great sql featuresConnor McDonald
 
Sangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesSangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesConnor McDonald
 
The Five Best Things To Happen To SQL
The Five Best Things To Happen To SQLThe Five Best Things To Happen To SQL
The Five Best Things To Happen To SQLConnor McDonald
 
UKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresUKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresConnor McDonald
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?Andrej Pashchenko
 
Wellington APAC Groundbreakers tour - SQL Pattern Matching
Wellington APAC Groundbreakers tour - SQL Pattern MatchingWellington APAC Groundbreakers tour - SQL Pattern Matching
Wellington APAC Groundbreakers tour - SQL Pattern MatchingConnor McDonald
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsConnor McDonald
 
Oracle Database 12c Application Development
Oracle Database 12c Application DevelopmentOracle Database 12c Application Development
Oracle Database 12c Application DevelopmentSaurabh K. Gupta
 
SQL techniques for faster applications
SQL techniques for faster applicationsSQL techniques for faster applications
SQL techniques for faster applicationsConnor McDonald
 
Practice 1
Practice 1Practice 1
Practice 1nonamela
 
SQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX DevelopersSQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX DevelopersConnor McDonald
 
Using SQL to process hierarchies
Using SQL to process hierarchiesUsing SQL to process hierarchies
Using SQL to process hierarchiesConnor McDonald
 

Semelhante a Connor McDonald 11g for developers (20)

OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developers
 
12c Mini Lesson - Inline PLSQL from SQL
12c Mini Lesson - Inline PLSQL from SQL12c Mini Lesson - Inline PLSQL from SQL
12c Mini Lesson - Inline PLSQL from SQL
 
Connor McDonald Partitioning
Connor McDonald PartitioningConnor McDonald Partitioning
Connor McDonald Partitioning
 
12c for Developers - Feb 2014
12c for Developers - Feb 201412c for Developers - Feb 2014
12c for Developers - Feb 2014
 
Latin America Tour 2019 - 10 great sql features
Latin America Tour 2019  - 10 great sql featuresLatin America Tour 2019  - 10 great sql features
Latin America Tour 2019 - 10 great sql features
 
Sangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesSangam 2019 - The Latest Features
Sangam 2019 - The Latest Features
 
Flashback ITOUG
Flashback ITOUGFlashback ITOUG
Flashback ITOUG
 
The Five Best Things To Happen To SQL
The Five Best Things To Happen To SQLThe Five Best Things To Happen To SQL
The Five Best Things To Happen To SQL
 
Les01
Les01Les01
Les01
 
UKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresUKOUG 2019 - SQL features
UKOUG 2019 - SQL features
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
 
Wellington APAC Groundbreakers tour - SQL Pattern Matching
Wellington APAC Groundbreakers tour - SQL Pattern MatchingWellington APAC Groundbreakers tour - SQL Pattern Matching
Wellington APAC Groundbreakers tour - SQL Pattern Matching
 
Les01
Les01Les01
Les01
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tips
 
Oracle Database 12c Application Development
Oracle Database 12c Application DevelopmentOracle Database 12c Application Development
Oracle Database 12c Application Development
 
SQL techniques for faster applications
SQL techniques for faster applicationsSQL techniques for faster applications
SQL techniques for faster applications
 
Practice 1
Practice 1Practice 1
Practice 1
 
SQLQueries
SQLQueriesSQLQueries
SQLQueries
 
SQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX DevelopersSQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX Developers
 
Using SQL to process hierarchies
Using SQL to process hierarchiesUsing SQL to process hierarchies
Using SQL to process hierarchies
 

Mais de InSync Conference

Oracle Fusion Middleware for JD Edwards
Oracle Fusion Middleware for JD EdwardsOracle Fusion Middleware for JD Edwards
Oracle Fusion Middleware for JD EdwardsInSync Conference
 
Optim Insync10 Paul Griffin presentation
Optim Insync10 Paul Griffin presentationOptim Insync10 Paul Griffin presentation
Optim Insync10 Paul Griffin presentationInSync Conference
 
Nswh Insync 2010 Ammar Customer Presentation
Nswh Insync 2010 Ammar Customer PresentationNswh Insync 2010 Ammar Customer Presentation
Nswh Insync 2010 Ammar Customer PresentationInSync Conference
 
Insync10 IBM JDE Sol Ed Announcement
Insync10 IBM JDE Sol Ed AnnouncementInsync10 IBM JDE Sol Ed Announcement
Insync10 IBM JDE Sol Ed AnnouncementInSync Conference
 
InSync10 Implement JDE Financial Analytics and Make Better Decisions
InSync10  Implement JDE Financial Analytics and Make Better DecisionsInSync10  Implement JDE Financial Analytics and Make Better Decisions
InSync10 Implement JDE Financial Analytics and Make Better DecisionsInSync Conference
 
Ebs operational reporting at santos evaluation, selection & implementation
Ebs operational reporting at santos evaluation, selection & implementationEbs operational reporting at santos evaluation, selection & implementation
Ebs operational reporting at santos evaluation, selection & implementationInSync Conference
 
Santos change management utility, our alternative to application change manag...
Santos change management utility, our alternative to application change manag...Santos change management utility, our alternative to application change manag...
Santos change management utility, our alternative to application change manag...InSync Conference
 
More effective and more flexible security to lower your total cost of ownersh...
More effective and more flexible security to lower your total cost of ownersh...More effective and more flexible security to lower your total cost of ownersh...
More effective and more flexible security to lower your total cost of ownersh...InSync Conference
 
Improve your JD Edwards audit (and your business) with the right security model
Improve your JD Edwards audit (and your business) with the right security modelImprove your JD Edwards audit (and your business) with the right security model
Improve your JD Edwards audit (and your business) with the right security modelInSync Conference
 
Under the Hood 11g Identity Management
Under the Hood  11g Identity ManagementUnder the Hood  11g Identity Management
Under the Hood 11g Identity ManagementInSync Conference
 
Extending oracle tools final
Extending oracle tools finalExtending oracle tools final
Extending oracle tools finalInSync Conference
 
Oracle strategy for_information_management
Oracle strategy for_information_managementOracle strategy for_information_management
Oracle strategy for_information_managementInSync Conference
 
PeopleSoft Integration broker Performance Tunning
PeopleSoft Integration broker Performance TunningPeopleSoft Integration broker Performance Tunning
PeopleSoft Integration broker Performance TunningInSync Conference
 
Ber in sa with oracle primavera delivered successfully
Ber in sa with oracle primavera  delivered successfullyBer in sa with oracle primavera  delivered successfully
Ber in sa with oracle primavera delivered successfullyInSync Conference
 
Database Support Outsourcing Worst Practices – Avoiding a Recipe for Disaster
Database Support Outsourcing Worst Practices – Avoiding a Recipe for DisasterDatabase Support Outsourcing Worst Practices – Avoiding a Recipe for Disaster
Database Support Outsourcing Worst Practices – Avoiding a Recipe for DisasterInSync Conference
 

Mais de InSync Conference (20)

P6 analytics
P6 analyticsP6 analytics
P6 analytics
 
Upk presentation insync
Upk presentation insync Upk presentation insync
Upk presentation insync
 
Oracle Fusion Middleware for JD Edwards
Oracle Fusion Middleware for JD EdwardsOracle Fusion Middleware for JD Edwards
Oracle Fusion Middleware for JD Edwards
 
In sync10 grc_suite
In sync10 grc_suiteIn sync10 grc_suite
In sync10 grc_suite
 
D linsync10 fusaapps
D linsync10 fusaappsD linsync10 fusaapps
D linsync10 fusaapps
 
Optim Insync10 Paul Griffin presentation
Optim Insync10 Paul Griffin presentationOptim Insync10 Paul Griffin presentation
Optim Insync10 Paul Griffin presentation
 
Nswh Insync 2010 Ammar Customer Presentation
Nswh Insync 2010 Ammar Customer PresentationNswh Insync 2010 Ammar Customer Presentation
Nswh Insync 2010 Ammar Customer Presentation
 
Insync10 IBM JDE Sol Ed Announcement
Insync10 IBM JDE Sol Ed AnnouncementInsync10 IBM JDE Sol Ed Announcement
Insync10 IBM JDE Sol Ed Announcement
 
InSync10 Implement JDE Financial Analytics and Make Better Decisions
InSync10  Implement JDE Financial Analytics and Make Better DecisionsInSync10  Implement JDE Financial Analytics and Make Better Decisions
InSync10 Implement JDE Financial Analytics and Make Better Decisions
 
Life after upgrading to r12
Life after upgrading to r12Life after upgrading to r12
Life after upgrading to r12
 
Ebs operational reporting at santos evaluation, selection & implementation
Ebs operational reporting at santos evaluation, selection & implementationEbs operational reporting at santos evaluation, selection & implementation
Ebs operational reporting at santos evaluation, selection & implementation
 
Santos change management utility, our alternative to application change manag...
Santos change management utility, our alternative to application change manag...Santos change management utility, our alternative to application change manag...
Santos change management utility, our alternative to application change manag...
 
More effective and more flexible security to lower your total cost of ownersh...
More effective and more flexible security to lower your total cost of ownersh...More effective and more flexible security to lower your total cost of ownersh...
More effective and more flexible security to lower your total cost of ownersh...
 
Improve your JD Edwards audit (and your business) with the right security model
Improve your JD Edwards audit (and your business) with the right security modelImprove your JD Edwards audit (and your business) with the right security model
Improve your JD Edwards audit (and your business) with the right security model
 
Under the Hood 11g Identity Management
Under the Hood  11g Identity ManagementUnder the Hood  11g Identity Management
Under the Hood 11g Identity Management
 
Extending oracle tools final
Extending oracle tools finalExtending oracle tools final
Extending oracle tools final
 
Oracle strategy for_information_management
Oracle strategy for_information_managementOracle strategy for_information_management
Oracle strategy for_information_management
 
PeopleSoft Integration broker Performance Tunning
PeopleSoft Integration broker Performance TunningPeopleSoft Integration broker Performance Tunning
PeopleSoft Integration broker Performance Tunning
 
Ber in sa with oracle primavera delivered successfully
Ber in sa with oracle primavera  delivered successfullyBer in sa with oracle primavera  delivered successfully
Ber in sa with oracle primavera delivered successfully
 
Database Support Outsourcing Worst Practices – Avoiding a Recipe for Disaster
Database Support Outsourcing Worst Practices – Avoiding a Recipe for DisasterDatabase Support Outsourcing Worst Practices – Avoiding a Recipe for Disaster
Database Support Outsourcing Worst Practices – Avoiding a Recipe for Disaster
 

Último

GenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncGenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncObject Automation
 
Babel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptxBabel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptxYounusS2
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Digital magic. A small project for controlling smart light bulbs.
Digital magic. A small project for controlling smart light bulbs.Digital magic. A small project for controlling smart light bulbs.
Digital magic. A small project for controlling smart light bulbs.francesco barbera
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdfJamie (Taka) Wang
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 

Último (20)

GenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation IncGenAI and AI GCC State of AI_Object Automation Inc
GenAI and AI GCC State of AI_Object Automation Inc
 
Babel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptxBabel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptx
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Digital magic. A small project for controlling smart light bulbs.
Digital magic. A small project for controlling smart light bulbs.Digital magic. A small project for controlling smart light bulbs.
Digital magic. A small project for controlling smart light bulbs.
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 

Connor McDonald 11g for developers

  • 1. NOTE itty bitty fonts in this presentation SQL> exec sample_font Can you read this ? 1
  • 2. Connor McDonald OracleDBA co.uk 2
  • 3. 3
  • 6. 6
  • 8. 2007 2008 2009 2010 2011 2012 2013 2014 2015 11g 11.1.0.7 11.2 11g desupported management visibility 11.1.0.6
  • 9. "why bother?" (part 2) 9
  • 12. there's a lot in 11g ! 12
  • 15. some not so cool things.... 15
  • 16. "11g is now production" 16
  • 17. 17
  • 18. 11g ≠ 18
  • 19. 19
  • 22. 22
  • 24. ORA-28000: the account is locked 24
  • 29. 29
  • 30. snippets 30
  • 33. SQL> select PASSPORT_PHOTO 2 from PERSON 3 where surname = 'MCDONALD' 4 / SP2-0678: Column type can not be displayed by SQL*Plus 33
  • 34. SQL> select PASSPORT_PHOTO 2 from PERSON 3 where surname = 'MCDONALD' 4 / MUGSHOT_BLOB ----------------------------------------------------- D0CF11E0A1B11AE1000000000000000000000000000000003E000 02300000001000000FEFFFFFF0000000020000000 34
  • 37. SQL> set errorlogging on SQL> desc SPERRORLOG Name Type ------------------------------------- ---------------- USERNAME VARCHAR2(256) TIMESTAMP TIMESTAMP(6) SCRIPT VARCHAR2(1024) IDENTIFIER VARCHAR2(256) MESSAGE CLOB STATEMENT CLOB 37
  • 38. SQL> select * from THE_WRONG_NAME; select * from THE_WRONG_NAME * ERROR at line 1: ORA-00942: table or view does not exist SQL> desc THE_WRONG_NAME; ERROR: ORA-04043: object THE_WRONG_NAME does not exist SQL> grant execute on P to NOT_A_USER; grant execute on P to NOT_A_USER * ERROR at line 1: ORA-01917: user or role 'NOT_A_USER' does not exist 38
  • 39. SQL> select timestamp, message, statement 2 from SPERRORLOG; TIMESTAMP ----------------------------------------------------- MESSAGE ----------------------------------------------------- STATEMENT ----------------------------------------------------- 01-APR-08 02.29.58.000000 PM ORA-00942: table or view does not exist select * from THE_WRONG_NAME 01-APR-08 02.29.58.000000 PM ORA-04043: object THE_WRONG_NAME does not exist desc THE_WRONG_NAME; 01-APR-08 02.30.04.000000 PM ORA-01917: user or role "NOT_A_USER" does not exist grant execute on P to NOT_A_USER 39
  • 40. SQL> set errorlogging on SQL> @create_all_objects installation scripts works on 10g too… 40
  • 42. 42
  • 45. SQL> select hash_value 2 from v$sql 3 where sql_text = 'SELECT 99 FROM DUAL'; HASH_VALUE ---------- 835694897 45
  • 46. SQL> declare 2 h1 raw(16); 3 h2 number; = 835694897 4 n int; 5 begin 6 n := 7 dbms_utility.get_sql_hash( 8 'SELECT 99 FROM DUAL'||chr(0) ,h1,h2); 9 dbms_output.put_line(h1); 10 end; 11 / F1D44D227DC0C4E0C719280B31B1CF31 31B1CF31 46
  • 47. snippets #5: listagg 47
  • 49. SQL> select deptno, ename 2 from emp 3 order by 1,2; DEPTNO ENAME ---------- ---------- 10 CLARK 10 KING 10 MILLER 20 ADAMS 20 FORD 20 JONES 20 SCOTT 20 SMITH 30 ALLEN 30 BLAKE 30 JAMES 30 MARTIN 30 TURNER 30 WARD 49
  • 50. DEPTNO MEMBERS ---------- ------------------------------------- 10 CLARK,KING,MILLER 20 SMITH,JONES,SCOTT,ADAMS,FORD 30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES 50
  • 51. SQL> select deptno , rtrim(ename,',') enames 2 from ( select deptno,ename,rn 3 from emp 4 model 5 partition by (deptno) 6 dimension by ( 7 row_number() over 8 (partition by deptno order by ename) rn 9 ) 10 measures (cast(ename as varchar2(40)) ename) 11 rules 12 ( ename[any] 13 order by rn desc = ename[cv()]||','||ename[cv()+1]) 14 ) 15 where rn = 1 16 order by deptno; DEPTNO ENAMES ---------- ---------------------------------------- 10 CLARK,KING,MILLER 20 ADAMS,FORD,JONES,SCOTT,SMITH 30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD - Rob Van Wijk 51
  • 52. SQL> select deptno, 2 substr(max(sys_connect_by_path(ename, ',')), 2) members 3 from (select deptno, ename, 4 row_number () 5 over (partition by deptno order by empno) rn 6 from emp) 7 start with rn = 1 8 connect by prior rn = rn - 1 9 and prior deptno = deptno 10 group by deptno 11 / DEPTNO MEMBERS ---------- --------------------------------------------------------- 30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES 20 SMITH,JONES,SCOTT,ADAMS,FORD 10 CLARK,KING,MILLER - Anon 52
  • 53. SQL> select deptno, 2 xmltransform 3 ( sys_xmlagg 4 ( sys_xmlgen(ename) 5 ), 6 xmltype 7 ( 8 '<?xml version="1.0"?><xsl:stylesheet version="1.0" 9 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 10 <xsl:template match="/"> 11 <xsl:for-each select="/ROWSET/ENAME"> 12 <xsl:value-of select="text()"/>;</xsl:for-each> 13 </xsl:template> 14 </xsl:stylesheet>' 15 ) 16 ).getstringval() members 17 from emp 18 group by deptno; DEPTNO MEMBERS ---------- -------------------------------------------------------- 10 CLARK;MILLER;KING; 20 SMITH;FORD;ADAMS;SCOTT;JONES; 30 ALLEN;JAMES;TURNER;BLAKE;MARTIN;WARD; - Laurent Schneider 53
  • 54. SQL> create or replace type string_agg_type as object 2 ( 3 total varchar2(4000), 4 5 static function 6 ODCIAggregateInitialize(sctx IN OUT string_agg_type ) 7 return number, 8 9 member function 10 ODCIAggregateIterate(self IN OUT string_agg_type , 11 value IN varchar2 ) 12 return number, 13 14 member function 15 ODCIAggregateTerminate(self IN string_agg_type, 16 returnValue OUT varchar2, 17 flags IN number) 18 return number, 19 20 member function 21 ODCIAggregateMerge(self IN OUT string_agg_type, 22 ctx2 IN string_agg_type) 23 return number 24 ); 25 / - Tom Kyte 54
  • 55. 55
  • 56. SQL> select deptno, 2 listagg( ename, ',') 3 within group (order by empno) members 4 from emp 5 group by deptno; DEPTNO MEMBERS ---------- ----------------------------------------- 10 CLARK,KING,MILLER 20 SMITH,JONES,SCOTT,ADAMS,FORD 30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES 56
  • 57. Feature: real time sql monitoring 57
  • 58. 58
  • 59. select e.department_id, sum(salary) from emp e, job_hist j where e.employee_id = j.employee_id and extract(year from e.hire_date) > 1985 and j.end_date > j.start_date + 1 and j.start_date >= e.hire_date group by e.department_id 59
  • 61. ----------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| ----------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 36M| 2742M| | 10998 (48)| | 1 | HASH GROUP BY | | 36M| 2742M| | 10998 (48)| |* 2 | HASH JOIN | | 36M| 2742M| 3728K| 9137 (37)| |* 3 | TABLE ACCESS FULL| JOB_HIST | 88761 | 2687K| | 147 (3)| |* 4 | TABLE ACCESS FULL| EMP | 877K| 40M| | 3028 (2)| ----------------------------------------------------------------------------- 61
  • 62. 62
  • 63. SQL> select 2 DBMS_SQLTUNE.REPORT_SQL_MONITOR( 3 sql_id=>'d3ncuxj7629bf', 4 report_level=>'ALL', 5 type=>'HTML') as report 6 from dual; 63
  • 67. Feature: statistics enhancements 67 67
  • 68. 68
  • 69. 69
  • 73. SQL> desc VEHICLE Name Null? Type -------------------------- -------- ------------- ID NUMBER MAKE VARCHAR2(6) MODEL VARCHAR2(6) SQL> select count(*) 2 from VEHICLE; COUNT(*) ------------ 2,157,079 73 73
  • 74. default stats not enough 74 74
  • 75. SQL> select count(*) 2 from VEHICLE 3 where MAKE = 'HOLDEN'; COUNT(*) ---------- 415387 ------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost | ------------------------------------------------------------ | 0 | SELECT STATEMENT | | 1 | 7 | 138| | 1 | SORT AGGREGATE | | 1 | 7 | | |* 2 | INDEX RANGE SCAN| MAKE_IX | 55310 | 378K| 138| ------------------------------------------------------------ 75 75
  • 77. SQL> begin 2 dbms_stats.gather_table_stats(user,'VEHICLE', 3 method_opt=>'for all columns size 1,'|| 4 'for columns MAKE size 254,'|| 5 'for columns MODEL size 254'); 6 end; 7 / PL/SQL procedure successfully completed. 77 77
  • 78. SQL> select count(*) 2 from VEHICLE 3 where MAKE = 'HOLDEN'; COUNT(*) ---------- 415387 ----------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | ----------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 7 | 1024| | 1 | SORT AGGREGATE | | 1 | 7 | | |* 2 | INDEX RANGE SCAN| MAKE_IX | 418K| 2859K| 1024| ----------------------------------------------------------- 78 78
  • 80. SQL> select count(*) 2 from VEHICLE 3 where MAKE = 'HOLDEN' 4 and MODEL = 'COMMODORE'; COUNT(*) ---------- 214468 -------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | --------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 14 | | 1 | SORT AGGREGATE | | 1 | 14 | | 2 | BITMAP CONVERSION COUNT | | 39527 | 540K| | 3 | BITMAP AND | | | | | 4 | BITMAP CONVERSION FROM ROWIDS| | | | |* 5 | INDEX RANGE SCAN | MODEL_IX | | | | 6 | BITMAP CONVERSION FROM ROWIDS| | | | |* 7 | INDEX RANGE SCAN | MAKE_IX | | | --------------------------------------------------------------------- 80 80
  • 82. 50% of Holdens are Commodores 82 82
  • 83. 83
  • 84. 84 84
  • 85. no correlation 10g and before 85 85
  • 86. ---------------------------------------------------------- | Id | Operation | Rows | Bytes | ---------------------------------------------------------- | 0 | SELECT STATEMENT | 1 | 14 | | 1 | SORT AGGREGATE | 1 | 14 | | 2 | BITMAP CONVERSION COUNT | 39527 | 540K| 86 86
  • 87. SQL> select count(*) from VEHICLE where model = 'COMMODORE'; COUNT(*) ---------- 214468 SQL> select count(*) from VEHICLE where make = 'HOLDEN'; COUNT(*) ---------- 415387 Prob(xy)=Prob(x)*Prob(y) SQL> select (214468/2157079)* 2 (415387/2157079)* 3 2157079 EST_ROWS from dual; EST_ROWS --------------- 41299.9334 ≈ 39527 87 87
  • 88. SQL> select 2 DBMS_STATS.CREATE_EXTENDED_STATS( 3 user, 'VEHICLE','(MAKE,MODEL)') tag 4 from dual; TAG ---------------------------------- SYS_STU8QPK2S$PEWHARK2CP3#1F#G SQL> select COLUMN_NAME,NUM_DISTINCT 2 from USER_TAB_COLS 3 where table_name = 'VEHICLE' COLUMN_NAME NUM_DISTINCT ------------------------------ ------------ ID 2157079 MAKE 39 MODEL 292 SYS_STU8QPK2S$PEWHARK2CP3#1F#G 88 88
  • 89. SQL> begin 2 dbms_stats.gather_table_stats(user,'VEHICLE', 3 method_opt=> 4 'for columns SYS_STU8QPK2S$PEWHARK2CP3#1F#G size 254'); 5 end; 6 / SQL> begin 2 dbms_stats.gather_table_stats(user,'VEHICLE', PL/SQL procedure method_opt=> completed. 3 successfully 4 'for columns (make,model) size 254'); 5 end; 6 / PL/SQL procedure successfully completed. 89 89
  • 90. SQL> select count(*) 2 from VEHICLE 3 where MAKE = 'HOLDEN' 4 and MODEL = 'COMMODORE'; COUNT(*) ---------- 214468 ------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | ------------------------------------------------------------ | 0 | SELECT STATEMENT | | 1 | 14 | 1956| | 1 | SORT AGGREGATE | | 1 | 14 | | |* 2 | TABLE ACCESS FULL| VEHICLE | 220K| 3018K| 1956| ------------------------------------------------------------- 90 90
  • 92. SQL> select /*+ GATHER_PLAN_STATISTICS */ count(*) 2 from VEHICLE 3 where MAKE = 'HOLDEN' 4 and MODEL = 'COMMODORE'; COUNT(*) ---------- 214468 SQL> SELECT * 2 FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR( 3 NULL, NULL, 'ALLSTATS LAST')); ---------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | ---------------------------------------------------------------- | 1 | SORT AGGREGATE | | 1 | 1 | 1 | |* 2 | TABLE ACCESS FULL| VEHICLE | 1 | 220K| 214K| ----------------------------------------------------------------- 92 92
  • 93. its just another column 93 93
  • 94. SQL> select "SYS_STU8QPK2S$PEWHARK2CP3#1F#G" 2 from vehicle 3 where rownum < 10; SYS_STU8QPK2S$PEWHARK2CP3#1F#G ------------------------------ 1.2706E+19 1.8075E+19 7.9949E+18 1.1730E+19 6.7142E+18 1.1730E+19 1.0779E+19 5.4051E+18 7.3555E+18 94 94
  • 96. SQL> SELECT extension_name, extension 2 FROM USER_STAT_EXTENSIONS 3 WHERE table_name = 'VEHICLE'; EXTENSION_NAME EXTENSION ------------------------------ ----------------- SYS_STU8QPK2S$PEWHARK2CP3#1F#G ("MAKE","MODEL") 96 96
  • 97. SQL> select SYS_OP_COMBINED_HASH(make,model) hashval, 2 "SYS_STU8QPK2S$PEWHARK2CP3#1F#G" colval 3 from VEHICLE 4 where rownum < 10; HASHVAL COLVAL ---------- ---------- 1.2706E+19 1.2706E+19 1.8075E+19 1.8075E+19 7.9949E+18 7.9949E+18 1.1730E+19 1.1730E+19 6.7142E+18 6.7142E+18 1.1730E+19 1.1730E+19 1.0779E+19 1.0779E+19 5.4051E+18 5.4051E+18 7.3555E+18 7.3555E+18 97 97
  • 98. PARSING IN CURSOR #28 alter table "SH"."VEHICLE" add (SYS_STU8QPK2S$PEWHARK2CP3#1F#G as (SYS_OP_COMBINED_HASH(MAKE,MODEL)) virtual BY USER for statistics); END OF STMT 98 98
  • 102. SQL> select count(*) 2 from VEHICLE 3 where MAKE in ('FORD','HOLDEN') 4 and MODEL = 'COMMODORE'; COUNT(*) ---------- 214468 ----------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost ----------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 14 | 1921 | 1 | SORT AGGREGATE | | 1 | 14 | |* 2 | VIEW | index$_join$_001 | 77818 | 1063K| 1921 |* 3 | HASH JOIN | | | | |* 4 | INDEX RANGE SCAN | MODEL_IX | 77818 | 1063K| 502 | 5 | INLIST ITERATOR | | | | |* 6 | INDEX RANGE SCAN| MAKE_IX | 77818 | 1063K| 2086 ----------------------------------------------------------------------- 102 102
  • 103. can we solve this ? 103 103
  • 105. adaptive cursor sharing 11.1 105 105
  • 106. 11.2 106 106
  • 107. much much better 107
  • 108. 108
  • 109. recall 109 109
  • 113. SQL> select /*+ GATHER_PLAN_STATISTICS */ count(*) 2 from VEHICLE 3 where MAKE = 'HOLDEN' 4 and MODEL = 'COMMODORE'; COUNT(*) ---------- 214468 SQL> SELECT * 2 FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR( 3 NULL, NULL, 'ALLSTATS LAST')); "ok" ----------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | ----------------------------------------------------------------- | 1 | SORT AGGREGATE | | 1 | 1 | 1 | |* 2 | TABLE ACCESS FULL| VEHICLE | 1 | 220K| 214K| ----------------------------------------------------------------- 113 113
  • 114. 114 114
  • 115. but just maybe .... 115 115
  • 116. ... someone already is 116 116
  • 117. 100,000 rows SQL> create table EMP as 2 select rownum empno, 3 mod(rownum,10) jobid, 4 mod(rownum,10)*1000 salary, 5 mod(rownum,50)+1 deptno 6 from dual 7 connect by rownum < 100000; 100 rows SQL> create table DEPT as 2 select rownum deptno, 3 'dept'||rownum dname 4 from dual 5 connect by rownum <= 100; 117
  • 118. SQL> exec dbms_stats.gather_table_stats(user,'EMP'); SQL> exec dbms_stats.gather_table_stats(user,'DEPT'); SQL> create index EMP_IX on EMP ( deptno ); SQL> create index DEPT_IX on DEPT ( deptno ); 118
  • 119. SQL> select e.empno, d.dname hard to 2 from emp e, dept d 3 where d.deptno = e.deptno optimize 4 and e.jobid = 1 5 and e.salary > 5000; 4 and e.jobid = 1 no rows selected 5 and e.salary > 5000; ---------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ---------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | 1 | MERGE JOIN | | 4444 | 104K | | 2 | TABLE ACCESS BY INDEX ROWID| DEPT | 100 | 1000 | | 3 | INDEX FULL SCAN | DEPT_IX | 100 | | |* 4 | SORT JOIN | | 4444 | 62216 | |* 5 | TABLE ACCESS FULL | EMP | 4444 | 62216 | ---------------------------------------------------------------- 119
  • 121. no changes to anything 121
  • 122. SQL> select e.empno, d.dname 2 from emp e, dept d 3 where d.deptno = e.deptno 4 and e.jobid = 1 5 and e.salary > 5000; no rows selected --------------------------------------------------- | Id | Operation | Name | Rows | Bytes | --------------------------------------------------- | 0 | SELECT STATEMENT | | | | |* 1 | HASH JOIN | | 89 | 2136 | | 2 | TABLE ACCESS FULL| DEPT | 1 | 10 | |* 3 | TABLE ACCESS FULL| EMP | 4444 | 62216 | --------------------------------------------------- 122
  • 123. 11.2 123
  • 124. the optimizer knows what "hard" is 124
  • 126. its not continuous learning 126
  • 128. SQL tuning advisor fallback 128
  • 130. 130
  • 131. SQL> create table MY_TMP as 2 select .... Table created. SQL> select ... 2 from ... 3 where COL in ( select COL from MY_TMP ) 4 and ... 131
  • 132. cache the results of queries 132
  • 133. GTT, plsql table, ... hard... single session, expiry issues... 133
  • 134. memory SQL> SELECT name, value 2 FROM v$parameter 3 WHERE name LIKE 'result_cache%'; NAME VALUE ------------------------------ ----------- result_cache_mode MANUAL result_cache_max_size 1081344 result_cache_max_result 5 result_cache_remote_expiration 0 % 134
  • 135. SQL> set autotrace traceonly stat SQL> set timing on SQL> select owner, count(*) 2 from T 3 group by owner 4 / 29 rows selected. Elapsed: 00:00:03.98 Statistics ----------------------------------------------------- 0 recursive calls 1 db block gets 32192 consistent gets 32184 physical reads 96 redo size [snip] 135
  • 136. SQL> / 29 rows selected. Elapsed: 00:00:03.80 Statistics ----------------------------------------------------- 0 recursive calls 1 db block gets 32192 consistent gets 32184 physical reads 96 redo size [snip] 136
  • 137. SQL> set autotrace traceonly stat SQL> set timing on SQL> select /*+ RESULT_CACHE */ owner, count(*) 2 from T 3 group by owner 4 / 29 rows selected. Elapsed: 00:00:03.80 Statistics ----------------------------------------------------- 0 recursive calls 1 db block gets 32192 consistent gets 32184 physical reads 96 redo size [snip] 137
  • 138. SQL> set autotrace traceonly stat SQL> set timing on SQL> select /*+ RESULT_CACHE */ owner, count(*) 2 from T 3 group by owner 4 / 29 rows selected. Elapsed: 00:00:00.04 !!!!!!!!!!!! Statistics ----------------------------------------------------- 0 recursive calls 0 db block gets 0 consistent gets 0 physical reads 0 redo size [snip] 138
  • 140. session 1 SQL> select /*+ RESULT_CACHE */ owner, count(*) 2 from T 3 group by owner 4 / 29 rows selected. Elapsed: 00:00:03.80 session 2 SQL> select /*+ RESULT_CACHE */ owner, count(*) 2 from T 3 group by owner 4 / 29 rows selected. Elapsed: 00:00:00.04 140
  • 142. SQL> set timing on SQL> select /*+ RESULT_CACHE */ owner, count(*) 2 from T 3 group by owner 4 / 29 rows selected. Elapsed: 00:00:00.05 SQL> delete from T where rownum = 1; 1 row deleted. SQL> select /*+ RESULT_CACHE */ owner, count(*) 2 from T 3 group by owner 4 / active txn Elapsed: 00:00:03.91 142
  • 143. SQL> commit; Commit complete. SQL> select /*+ RESULT_CACHE */ owner, count(*) 2 from T 3 group by owner 4 / Elapsed: 00:00:03.91 reinstantiate cache SQL> select /*+ RESULT_CACHE */ owner, count(*) 2 from T 3 group by owner 4 / Elapsed: 00:00:00.04 voila! 143
  • 144. 11.2 144
  • 145. part of table definition 145
  • 146. alter table T result_cache (mode force); 146
  • 147. dependencies 147
  • 149. SQL> select 2 r.name, 3 listagg(o.name,' ') within group ( order by o.name ) as obj 4 from v$result_cache_objects r, 5 v$result_cache_dependency d, 6 sys.obj$ o 7 where r.type = 'Result' 8 and r.id =d.result_id 9 and d.object_no=o.obj# 10 group by r.name; NAME OBJ ------------------------------------------------ ---------------- select /*+ RESULT_CACHE */ owner, count(*) T from T group by owner select /*+ RESULT_CACHE */ owner, count(*) T1 T from T, T1 group by owner 149
  • 150. plsql too 150
  • 151. SQL> desc COUNTRY_SALES Name Null? Type ----------------- -------- ------------ CTRY NOT NULL VARCHAR2(10) CRNCY NOT NULL VARCHAR2(3) AMOUNT NUMBER PRODUCT VARCHAR2(20) TXN_DATE DATE QUANTITY NUMBER(3) "summarise the sales in $AUD" 151
  • 153. slower... obscure... SOA ...awfully complicated 153
  • 154. SQL> create or replace 2 function CURRENCY_CONVERT(code varchar2) return number is 3 l_service sys.utl_dbws.service; 4 l_call sys.utl_dbws.call; 5 l_result sys.anydata; 6 7 l_wsdl varchar2(100); 8 l_ns varchar2(100); [snip] 15 begin 16 l_ns := 'http://www.webservicex.net/currencyconvertor.asmx'; 17 l_wsdl := 'http://www.webservicex.net/currencyconvertor.asmx?wsdl'; [snip] 28 29 l_result := SYS.UTL_DBWS.INVOKE ( 30 call_handle => l_call, 31 input_params => l_input_params); [snip] 46 return sys.anydata.accessnumber(l_result); 47 end; 48 / Function created. 154
  • 155. SQL> select sum(CURRENCY_CONVERT(crncy)*amount) tot 2 from COUNTRY_SALES 3 / TOT ---------- 4799.62 Elapsed: 00:00:45.36 155
  • 156. 156
  • 157. SQL> create or replace 2 function CURRENCY_CONVERT(code varchar2) return number RESULT_CACHE is 3 l_service sys.utl_dbws.service; 4 l_call sys.utl_dbws.call; 5 l_result sys.anydata; 6 7 l_wsdl varchar2(100); 8 l_ns varchar2(100); [snip] 15 begin 16 l_ns := 'http://www.webservicex.net/currencyconvertor.asmx'; 17 l_wsdl := 'http://www.webservicex.net/currencyconvertor.asmx?wsdl'; [snip] 28 29 l_result := SYS.UTL_DBWS.invoke ( 30 call_handle => l_call, 31 input_params => l_input_params); [snip] 46 return sys.anydata.accessnumber(l_result); 47 end; 48 / Function created. 157
  • 158. SQL> select sum(CURRENCY_CONVERT(crncy)*amount) tot 2 from COUNTRY_SALES 3 where rownum < 100 4 / TOT ---------- 4799.62 inter-row Elapsed: 00:00:15.78 cache benefit SQL> / TOT ---------- 4799.62 all values Elapsed: 00:00:00.02 cached 158
  • 159. explain plan 159
  • 160. SQL> select /*+ RESULT_CACHE */ owner, max(object_id) 2 from T 3 group by owner 4 / -------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | -------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 19 | 171 | | 1 | RESULT CACHE | b82qdu5m139yr3fbna1x5r6g2d | | | | 2 | HASH GROUP BY | | 19 | 171 | | 3 | TABLE ACCESS FULL| T | 2201K| 18M | -------------------------------------------------------------------------- indeterminate 160
  • 161. SQL> select status 2 from v$result_cache_objects 3 where cache_id = 'b82qdu5m139yr3fbna1x5r6g2d'; STATUS --------- Published ? New - Published - Result is still under construction Result is available for use Bypass - Result will be bypassed from use Expired - Result has exceeded expiration time Invalid - Result is no longer available for use 161
  • 162. select /*+ RESULT_CACHE */ … two people, same query select /*+ RESULT_CACHE */ … 162
  • 163. when in doubt... ...try to break it 163
  • 164. 164
  • 165. 165
  • 166. 166
  • 167. SQL> create or replace 2 function SLOW(n number) return number 3 is 4 begin 5 dbms_lock.sleep(1); 6 return n; 7 end; 8 / Function created. 167
  • 168. SQL> select /*+ RESULT_CACHE */ owner, slow(object_id) 2 from T 3 where rownum <= 120; Elapsed: 00:02:01.13 -------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | -------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 119 | 1071 | | 1 | RESULT CACHE | 14tnr7dxmvkp3244d69tw72z4p | | | |* 2 | COUNT STOPKEY | | | | | 3 | TABLE ACCESS FULL| T | 119 | 1071 | -------------------------------------------------------------------------- 168
  • 169. SQL> select /*+ RESULT_CACHE */ owner, slow(object_id) 2 from T 3 where rownum < 120; [5 seconds later...] OWNERSQL> select status SLOW(OBJECT_ID) 2 from v$result_cache_objects ------------------------------ --------------- SYS 3 where cache_id = '14tnr7dxmvkp3244d69tw72z4p'; 20 SYS 46 SYS STATUS 2 session 28 SYS --------- 15 SYS New 29 SQL> select /*+ RESULT_CACHE */ owner, slow(object_id) [still from 2 executing...] T 3 where rownum < 120; [executing...] Elapsed: 00:03:03.54 !!!!!!!!! 169
  • 170. SQL> select sid, 2 decode(lockwait,null,status,'BLOCKED') status 3 from v$session 4 where username = 'CONNOR'; SID STATUS ---------- -------- 131 ACTIVE 143 BLOCKED uh oh.... 170
  • 171. PARSING IN CURSOR #5 len=82 dep=0 uid=88 oct=3 lid=88 select /*+ RESULT_CACHE */ owner, slow(data_object_id) from T where rownum < 120 END OF STMT PARSE #5:c=15625,e=28756,p=0,cr=0,cu=0,mis=1,r=0,tim=202781578 EXEC #5:c=0,e=60,p=0,cr=0,cu=0,mis=0,r=0,tim=202781659 WAIT #5: nam='enq: RC - Result Cache: Contention' ela= 10005714 WAIT #5: nam='enq: RC - Result Cache: Contention' ela= 10002485 WAIT #5: nam='enq: RC - Result Cache: Contention' ela= 10002804 WAIT #5: nam='enq: RC - Result Cache: Contention' ela= 10002549 WAIT #5: nam='enq: RC - Result Cache: Contention' ela= 10005258 WAIT #5: nam='enq: RC - Result Cache: Contention' ela= 10002461 WAIT #5: nam='direct path read' ela= 13770 file number=4 ... WAIT #5: nam='direct path read' ela= 25 file number=4 ... [etc] 171
  • 173. PARSING IN CURSOR #5 len=82 dep=0 uid=88 oct=3 lid=88 select /*+ RESULT_CACHE */ owner, slow(data_object_id) from T where rownum < 120 END OF STMT PARSE #5:c=15625,e=28756,p=0,cr=0,cu=0,mis=1,r=0,tim=202781578 EXEC #5:c=0,e=60,p=0,cr=0,cu=0,mis=0,r=0,tim=202781659 WAIT #5: nam='enq: RC - Result Cache: Contention' ela= 10005714 WAIT #5: nam='direct path read' ela= 13770 file number=4 ... WAIT #5: nam='direct path read' ela= 25 file number=4 ... ... 173
  • 175. 175
  • 176. not too short.... why bother with result cache? 176
  • 177. not too long.... might lock other people out 177
  • 180. SQL> desc T Name Null? Type ----------------------------- -------- ------------- OWNER NOT NULL VARCHAR2(30) OBJECT_NAME NOT NULL VARCHAR2(30) SQL> desc T_AUDIT Name Null? Type ----------------------------- -------- -------------- AUDIT_DATE DATE AUDIT_ACTION CHAR(1) OWNER NOT NULL VARCHAR2(30) OBJECT_NAME NOT NULL VARCHAR2(30) 180
  • 181. SQL> create or replace 2 trigger AUDIT_TRG 3 after insert or update or delete on T 4 for each row 5 declare 6 v_action varchar2(1) := case when updating then 'U' 7 when deleting then 'D' else 'I' end; 8 begin 9 if updating or inserting then 10 insert into T_AUDIT 11 values (sysdate 12 ,v_action 13 ,:new.owner 14 ,:new.object_name); 15 else 16 insert into T_AUDIT 17 values (sysdate 18 ,v_action 19 ,:old.owner 20 ,:old.object_name); 21 end if; 22 end; 23 / Trigger created. 181
  • 183. SQL> insert into T 2 select owner, object_name 3 from all_objects insert where 4 into T rownum <= 10000; select owner, object_name from all_objects 10000 rownum <= 10000 where rows created. call count cpu elapsed disk query current rows ------- ------ ------- ---------- -------- --------- ---------- ---------- Parse 1 0.01 0.00 0 0 0 0 Execute 1 3.10 3.05 88 123 10642 10000 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ ------- ---------- -------- --------- ---------- ---------- total 2 3.12 3.06 88 123 10642 10000 INSERT INTO T_AUDIT VALUES (SYSDATE ,:B3 ,:B1 ,:B2 ) call count cpu elapsed disk query current rows ------- ------ ------- ---------- -------- --------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 10000 0.79 0.97 2 109 10845 10000 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ ------- ---------- -------- --------- ---------- ---------- total 10001 0.79 0.97 2 109 10845 10000 183
  • 184. bulk binding "hard" 184
  • 185. create or replace package T_PKG is type each_row is record ( action varchar2(1), owner varchar2(30), object_name varchar2(30) ); type row_list is table of each_row index by pls_integer; g row_list; end; / 185
  • 186. create or replace trigger AUDIT_TRG1 before insert or update or delete on T begin t_pkg.g.delete; end; / 186
  • 187. create or replace trigger AUDIT_TRG2 after insert or update or delete on T for each row begin if updating or inserting then t_pkg.g(t_pkg.g.count+1).owner := :new.owner; t_pkg.g(t_pkg.g.count).object_name := :new.object_name; else t_pkg.g(t_pkg.g.count).owner := :old.owner; t_pkg.g(t_pkg.g.count).object_name := :old.object_name; end if; end; / 187
  • 188. create or replace trigger AUDIT_TRG3 after insert or update or delete on T declare v_action varchar2(1) := case when updating then 'U' when deleting then 'D' else 'I' end; begin forall i in 1 .. t_pkg.g.count insert into T_AUDIT values ( sysdate, v_action, t_pkg.g(i).owner, t_pkg.g(i).object_name); t_pkg.g.delete; end; / 188
  • 189. SQL> insert into T 2 select owner, object_name 3 from all_objects insert into T 4 where rownum <= 10000; select owner, object_name from all_objects 10000 rows created. where rownum <= 10000 call count cpu elapsed disk query current rows ------- ------ ------- --------- -------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 33 0 0 Execute 1 0.56 0.58 0 91 10653 10000 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ ------- --------- -------- ---------- ---------- ---------- total 2 0.56 0.59 0 124 10653 10000 INSERT INTO T_AUDIT VALUES ( SYSDATE, :B1 , :B2 , :B3 ) call count cpu elapsed disk query current rows ------- ------ ------- --------- -------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.04 0.03 0 90 478 10000 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ ------- --------- -------- ---------- ---------- ---------- total 2 0.04 0.03 0 90 478 10000 189
  • 190. additional package no one did it .... three triggers 190
  • 192. create or replace trigger AUDIT_TRG for insert or update or delete on T compound trigger before statement is begin ... end before statement; after each row is begin ... end after each row; after statement is begin ... end after statement; end; / 192
  • 193. SQL> create or replace 2 trigger AUDIT_TRG for insert or update or delete on T compound trigger 3 4 type each_row is record ( action varchar2(1), 5 owner varchar2(30), 6 object_name varchar2(30)); 7 type row_list is table of each_row index by pls_integer; 8 g row_list; 9 v_action varchar2(1) := 10 case when updating then 'U' when deleting then 'D' else 'I' end; 11 12 before statement is 13 begin 14 g.delete; 15 end before statement; 16 17 after each row is 18 begin 19 20 if updating or inserting then 21 g(g.count+1).owner := :new.owner; 22 g(g.count).object_name := :new.object_name; 23 else 24 g(g.count).owner := :old.owner; 25 g(g.count).object_name := :old.object_name; 26 end if; 27 end after each row; 28 29 after statement is 30 begin 31 forall i in 1 .. g.count 32 insert into T_AUDIT 33 values (sysdate,v_action,g(i).owner,g(i).object_name); 34 g.delete; 35 end after statement; 36 37 end; 38 / 193 Trigger created.
  • 194. one more thing on triggers... 194
  • 195. the 107 slides you didn't see 195
  • 196. SQL> create or replace 2 trigger AUDIT_TRG 3 after insert or update or delete on T 4 for each row 5 declare 6 v_action varchar2(1) := 7 case when updating then 'U' 8 when deleting then 'D' else 'I' end case; 9 begin 10 if updating or inserting then 11 insert into T_AUDIT 12 values(sysdate,v_action,:new.owner,:new.object_name); 13 else 14 insert into T_AUDIT 15 values(sysdate,v_action,:old.owner,:old.object_name); 16 end if; 17 end; 18 / Warning: Trigger created with compilation errors. SQL> sho err Errors for TRIGGER AUDIT_TRG: LINE/COL ERROR -------- ----------------------------------------------------------------- 4/46 PLS-00103: Encountered the symbol "CASE" when expecting one of the following: * & = - + ; < / > at in is mod remainder not rem <an exponent (**)> <> or != or ~= >= <= <> and or like like2 196
  • 197. SQL> create or replace 2 trigger AUDIT_TRG 3 after insert or update or delete on T 4 for each row 5 declare 6 v_action varchar2(1) := 7 case when updating then 'U' 8 when deleting then 'D' else 'I' end; 9 begin 10 if updateing or inserting then 11 insert into T_AUDIT 12 values(sysdate,v_action,:new.owner,:new.object_name); 13 else 14 insert into T_AUDIT 15 values(sysdate,v_action,:old.owner,:old.object_name); 16 end if; 17 end; 18 / Warning: Trigger created with compilation errors. SQL> sho err Errors for TRIGGER AUDIT_TRG: LINE/COL ERROR -------- ----------------------------------------------------------------- 6/3 PL/SQL: Statement ignored 6/6 PLS-00201: identifier 'UPDATEING' must be declared 197
  • 198. SQL> create or replace 2 trigger AUDIT_TRG 3 after insert or update or delete on T 4 for each row 5 declare 6 v_action varchar2(1) := 7 case when updating then 'U' 8 when deleting then 'D' else 'I' end; 9 begin 10 if updating or inserting then 11 insert into TAUDIT 12 values(sysdate,v_action,:new.owner,:new.object_name); 13 else 14 insert into T_AUDIT 15 values(sysdate,v_action,:old.owner,:old.object_name); 16 end if; 17 end; 18 / Warning: Trigger created with compilation errors. SQL> sho err Errors for TRIGGER AUDIT_TRG: LINE/COL ERROR -------- ------------------------------------------------------ 7/6 PL/SQL: SQL Statement ignored 7/18 PL/SQL: ORA-00942: table or view does not exist 198
  • 199. SQL> create or replace 2 trigger AUDIT_TRG 3 after insert or update or delete on T 4 for each row 5 declare 6 v_action varchar2(1) := 7 case when updating then 'U' 8 when deleting then 'D' else 'I' end; 9 begin 10 if updating or inserting then 11 insert into T_AUDIT 12 values(sysdate,v_action,:new.owner,new.object_name); 13 else 14 insert into T_AUDIT 15 values(sysdate,v_action,:old.owner,:old.object_name); 16 end if; 17 end; 18 / Warning: Trigger created with compilation errors. SQL> sho err Errors for TRIGGER AUDIT_TRG: LINE/COL ERROR -------- --------------------------------------------------------- 10/6 PL/SQL: SQL Statement ignored 11/45 PL/SQL: ORA-00984: column not allowed here 199
  • 200. etc etc etc 200
  • 201. Which of the following is the largest ? 201
  • 202. T 202
  • 203. SQL> insert into T values ('X','Y'); insert into T values ('X','Y') * ERROR at line 1: ORA-04098: trigger 'CONNOR.AUDIT_TRG' is invalid and failed re-validation 203
  • 205. SQL> create or replace 2 trigger AUDIT_TRG 3 after insert or update or delete on T 4 for each row 5 DISABLE 6 declare 7 v_action varchar2(1) := 8 case when updating then 'U' 9 when deleting then 'D' else 'I' end; 10 begin 11 if updating or inserting then 12 insert into T_AUDIT 13 values(sysdate,v_action,:new.owner,:new.object_name); 14 else 15 insert into T_AUDIT 16 values(sysdate,v_action,:old.owner,old.object_name); 17 end if; 18 end; 19 / Warning: Trigger created with compilation errors. 205
  • 206. SQL> select status from user_triggers 2 where trigger_name = 'AUDIT_TRG'; STATUS -------- DISABLED SQL> insert into T values ('X','Y'); 1 row created. 206
  • 209. SQL> create table T ( x number, y number ); Table created. SQL> create or replace 2 view MY_VIEW as 3 select x,y from T; View created. 209
  • 210. SQL> alter table T add Z number; Table altered. SQL> select status 2 from user_objects 3 where object_name = 'MY_VIEW'; STATUS ------- INVALID 210
  • 211. 11g 211
  • 213. SQL> alter table T add Z number; Table altered. SQL> select status 2 from user_objects 3 where object_name = 'MY_VIEW'; STATUS ------- VALID 213
  • 214. plsql too 214
  • 215. quick review 215
  • 218. 218
  • 220. proc A proc B proc C proc D pack A pack B pack C pack D body A body B body C body D 220
  • 221. 11g 221
  • 222. change the spec as well ! 222
  • 223. pack A pack B pack C pack D body A body B body C body D 223
  • 224. SQL> create or replace 2 package PKG is 3 procedure P1; 4 end; 5 / SQL> create or replace Package created. 2 procedure PRC is 3 begin SQL> create or replace 4 pkg.p1; 2 package body PKG is 3 5 end; procedure P1 is 4 x6 / number; 5 begin 6 Procedure created. x := 1; 7 end; 8 end; 9 / Package body created. 224
  • 225. SQL> create or replace 2 package PKG is 3 procedure P1; 4 procedure P2; 5 end; 6 / Package created. SQL> create or replace 2 package body PKG is 3 procedure P1 is 4 x number; 5 begin 6 x := 1; 7 end; 8 9 procedure p2 is 10 x number; 11 begin 12 x := myseq.nextval; 13 end; 14 end; 15 / Package body created. 225
  • 226. SQL> select status 10g and below 2 from user_objects 3 where object_name = 'PRC'; STATUS ------- INVALID SQL> select status 11g 2 from user_objects 3 where object_name = 'PRC'; STATUS ------- VALID 226
  • 227. package D 227
  • 228. the order is important 228
  • 229. SQL> create or replace 2 package PKG is 3 procedure p1; 4 end; 5 / Package created. SQL> create or replace 2 package body PKG is 3 procedure p1 is 4 x number; 5 begin 6 x := 1; 7 end; 8 9 end; 10 / Package body created. 229
  • 230. SQL> create or replace 2 package PKG is 3 procedure p2; 4 procedure p1; 5 end; 6 / Package created. SQL> create or replace 2 package body PKG is 3 procedure p2 is 4 x number; 5 begin 6 x := myseq.nextval; 7 end; 8 9 procedure p1 is 10 x number; 11 begin 12 x := 1; 13 end; 14 15 end; 16 / Package body created. 230
  • 231. moral of the story 231
  • 232. change package bodies (as before) 232
  • 233. add to bottom of specs 233
  • 234. this is NOT about package state 234
  • 235. SQL> create or replace 2 package PKG is 3 procedure p1; 4 end; 5 / Package created. SQL> create or replace 2 package body PKG is 3 4 my_global_var date; 5 6 procedure p1 is 7 x number; 8 begin 9 if my_global_var is null then 10 my_global_var := sysdate; 11 end if; 12 end; 13 end; 14 / Package body created. 235
  • 236. SQL> create or replace 2 procedure PRC is 3 begin SQL> create or replace 4 pkg.p1; 2 package body PKG is 5 end; 3 6 / 4 my_global_var date; 5 Procedure created. 6 procedure p1 is 7 x number; SQL> exec PRC; 8 begin 9 if my_global_var is null then SQL> exec PRC; 10 my_global_var := sysdate; 11 end if; BEGIN PRC; END; 12 end; 13 end; * 14 / ERROR at line 1: ORA-04068: existing state of packages has been discarded Package body created. ORA-04061: existing state of package body "PKG" has been invalidated ORA-04065: not executed, altered or dropped package body "PKG" ORA-06508: PL/SQL: could not find program unit being called: "PKG" ORA-06512: at "PRC", line 3 ORA-06512: at line 1 236
  • 237. minimise global variables keep stateful data separate store types separately 237
  • 238. you may have noticed... 238
  • 239. SQL> create or replace 2 package body PKG is 3 procedure p2 is 4 x number; 5 begin 6 x := myseq.nextval; 7 end; 8 9 procedure p1 is 10 x number; 11 begin 12 x := 1; 13 end; 14 15 end; 16 / Package body created. 239
  • 241. 241
  • 242. can we reduce the risk further ? 242
  • 244. SQL> create or replace 2 procedure THE_SINGLE_MOST_IMPORTANT_PROC_IN_MY_APP is begin .... 244
  • 245. 11.2 245
  • 246. 246
  • 248. package PKG is package PKG(V2) is select COL1, COL2 select COL1, NEW_COL from MY_VIEW from MY_VIEW(V2) both in active use ! 248
  • 249. SQL> desc DBA_EDITIONS Name Null? Type ----------------------------- -------- ------------- EDITION_NAME NOT NULL VARCHAR2(30) PARENT_EDITION_NAME VARCHAR2(30) USABLE VARCHAR2(3) 249
  • 250. SQL> select * 2 from DBA_EDITIONS; EDITION_NAME PARENT_EDITION USABLE ------------ -------------- ------ ORA$BASE YES 250
  • 251. PKG1 PKG2 PKG3 PKG4 PKG5 ora$base PKG1 PKG3 PKG5 version2 251
  • 252. no space = probably editionable 252
  • 253. indexes 253
  • 255. tables 255
  • 256. views 256
  • 257. create view V_MY_TABLE as select V1_COL1 as col1, V1_COL2 as col2, version1 V1_COL3 as col3, V1_ONLY_COL4 as col4, from MY_TABLE SQL> desc MY_TABLE Name Null? Type ----------------------------- -------- ----------------- V1_COL1 NUMBER V1_COL2 DATE V1_COL3 VARCHAR2(10) V1_ONLY_COL4 VARCHAR2(10) V2_NEWCOL5 DATE V2_NEWCOL6 NUMBER create view V_MY_TABLE as select V1_COL1 as col1, V1_COL2 as col2, V1_COL3 as col3, version2 V2_NEWCOL5 as col5, V2_NEWCOL6 as col6 from MY_TABLE 257
  • 258. editioning views (special) 258
  • 260. SQL> desc EMP Name Null? Type ----------------------------- -------- ------------- EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) JOB VARCHAR2(9) MGR NUMBER(4) HIREDATE DATE SAL NUMBER(7,2) COMM NUMBER(7,2) DEPTNO NUMBER(2) 260
  • 261. SQL> create or replace 2 package body EMP_MAINT is 3 procedure hire_emp(p_empno emp.empno%type, 4 p_ename emp.ename%type, 5 p_job emp.job%type, 6 p_sal emp.sal%type, 7 p_deptno emp.deptno%type) is 8 begin 9 insert into EMP 10 (empno,ename,job,sal,deptno) 11 values 12 (p_empno,p_ename,p_job,p_sal,p_deptno); 13 end; 14 end; 15 / Package body created. 261
  • 262. version 2 262
  • 263. SQL> desc EMP Name Null? Type ----------------------------- -------- ------------- EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) JOB VARCHAR2(9) MGR NUMBER(4) HIREDATE Contract/Permanent DATE SAL NUMBER(7,2) COMM NUMBER(7,2) DEPTNO NUMBER(2) ETYPE VARCHAR2(10) TERMINATION_DATE DATE End of Contract 263
  • 264. old style 264
  • 265. SQL> alter table EMP add ETYPE VARCHAR2(1); Table altered. SQL> alter table EMP add TERMINATION_DATE DATE; Table altered. SQL> update EMP set ETYPE = 'Permanent'; 14 rows updated. SQL> alter table EMP modify ETYPE not null; Table altered. SQL> alter table EMP add constraint 2 EMP_CHK01 check ( ETYPE in ('Contract', 'Permanent')); Table altered. 265
  • 267. SQL> exec EMP_MAINT.HIRE_EMP(1,'Sue','SALES',10,10) BEGIN EMP_MAINT.HIRE_EMP(1,'Sue','SALES',10,10); END; * ERROR at line 1: ORA-01400: cannot insert NULL into ("SCOTT"."EMP"."ETYPE") ORA-06512: at "SCOTT.EMP_MAINT", line 8 ORA-06512: at line 1 267
  • 268. outage 268
  • 269. SQL> create or replace 2 package body EMP_MAINT is 3 procedure hire_emp(p_empno emp.empno%type, 4 p_ename emp.ename%type, 5 p_job emp.job%type, 6 p_sal emp.sal%type, 7 p_deptno emp.deptno%type, 8 p_etype emp.etype%type, 9 p_term emp.termination_date%type) is 10 begin 11 insert into EMP 12 (empno,ename,job,sal,deptno,etype,termination_date) 13 values 14 (p_empno,p_ename,p_job,p_sal,p_deptno,p_etype,p_term); 15 end; 16 end; 17 / Package body created. 269
  • 271. step 1 271
  • 273. SQL> alter user SCOTT enable editions; User altered. 273
  • 274. this is a big deal 274
  • 275. Enabling editions is retroactive and irreversible. - 11g2 doc 275
  • 276. step 2 276
  • 278. SQL> alter table EMP rename to "_EMP"; Table altered. SQL> create or replace 2 editioning view EMP as 3 select * from "_EMP"; View created. SQL> exec dbms_utility.compile_schema(user) PL/SQL procedure successfully completed. 278
  • 279. obtuse _EMP 279
  • 280. SQL> select * from _EMP; select * from _EMP * ERROR at line 1: ORA-00911: invalid character 280
  • 281. may mean an outage as you upgrade to 11.2 281
  • 282. SQL> alter table "_EMP" add ETYPE VARCHAR2(1); Table altered. SQL> alter table "_EMP" add TERMINATION_DATE DATE; Table altered. SQL> alter table "_EMP" add constraint 2 EMP_CHK01 check ( ETYPE in ('Contract', 'Permanent')); Table altered. SQL> alter table "_EMP" modify ETYPE not null; Table altered. 282
  • 284. SQL> create edition "APP_V2" 2 / Edition created. 284
  • 285. SQL> conn SCOTT/TIGER Connected. SQL> alter session set edition = APP_V2; ERROR: ORA-38802: edition does not exist 285
  • 286. SQL> grant USE on edition APP_V2 to SCOTT; Grant succeeded. 286
  • 287. SQL> alter session set edition = APP_V2; SQL> create or replace 2 editioning view EMP as 3 select * from "_EMP" 4 / View created. 287
  • 288. SQL> alter session set edition = ORA$BASE; Session altered. SQL> desc EMP Name Null? Type ----------------------------- -------- ---------------- EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) JOB VARCHAR2(9) MGR NUMBER(4) HIREDATE DATE SAL NUMBER(7,2) COMM NUMBER(7,2) DEPTNO NUMBER(2) 288
  • 289. SQL> alter session set edition = APP_V2; Session altered. SQL> desc EMP Name Null? Type ----------------------------- -------- --------------- EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) JOB VARCHAR2(9) MGR NUMBER(4) HIREDATE DATE SAL NUMBER(7,2) COMM NUMBER(7,2) DEPTNO NUMBER(2) ETYPE VARCHAR2(10) TERMINATION_DATE DATE 289
  • 290. SQL> select sys_context('USERENV', 2 'CURRENT_EDITION_NAME') edt 3 from dual; EDT -------------- APP_V2 290
  • 291. SQL> create or replace 2 package body EMP_MAINT is 3 procedure hire_emp(p_empno emp.empno%type, 4 p_ename emp.ename%type, 5 p_job emp.job%type, 6 p_sal emp.sal%type, 7 p_deptno emp.deptno%type, 8 p_etype emp.etype%type, 9 p_term emp.termination_date%type) is 10 begin 11 insert into EMP 12 (empno,ename,job,sal,deptno,etype,termination_date) 13 values 14 (p_empno,p_ename,p_job,p_sal,p_deptno,p_etype,p_term); 15 end; 16 end; 17 / Package body created. 291
  • 292. SQL> alter session set edition = ORA$BASE; Session altered. SQL> begin 2 EMP_MAINT.HIRE_EMP( 3 p_empno =>1, 4 p_ename =>'Sue', 5 p_job =>'SALES', 6 p_sal =>10, 7 p_deptno =>20); 8 end; 9 / PL/SQL procedure successfully completed. 292
  • 293. SQL> alter session set edition = APP_V2; Session altered. SQL> begin 2 EMP_MAINT.HIRE_EMP( 3 p_empno =>2, 4 p_ename =>'Mike', 5 p_job =>'SALES', 6 p_sal =>10, 7 p_deptno =>20, 8 p_etype =>'Contract' 9 p_term =>'10-JAN-2012'); 10 end; 11 / PL/SQL procedure successfully completed. 293
  • 296. SQL> alter session set edition = APP_V2; Session altered. SQL> begin 2 EMP_MAINT.HIRE_EMP( 3 p_empno =>2, 4 p_ename =>'Mike', 5 p_job =>'SALES', 6 p_sal =>10, 7 p_deptno =>20, 8 p_etype =>null 9 p_term =>'10-JAN-2012'); 10 end; 11 / PL/SQL procedure successfully completed. 296
  • 297. constraints not (natively) editionable 297
  • 298. SQL> alter table "_EMP" add constraint 2 EMP_CHK02 check ( 3 SYS_CONTEXT('USERENV', 4 'CURRENT_EDITION_NAME') 5 = 'ORA$BASE' 6 OR ETYPE is not null 7 ); Table altered. 298
  • 299. APP_V2 "everyone has an ETYPE" cross edition consistency APP_V1 (aka ORA$BASE) "what is an ETYPE" 299
  • 301. SQL> alter session set edition = APP_V2; Session altered. SQL> CREATE OR REPLACE TRIGGER emp_v1_to_v2 2 BEFORE INSERT OR UPDATE ON "_EMP" 3 FOR EACH ROW 4 FORWARD CROSSEDITION 5 DISABLE 6 BEGIN 7 :new.etype := nvl(:new.etype,'Permanent'); 8 :new.termination_date := null; 9 END; 10 / Trigger created. 301
  • 302. SQL> CREATE OR REPLACE TRIGGER emp_v2_to_v1 2 BEFORE INSERT OR UPDATE ON "_EMP" 3 FOR EACH ROW 4 REVERSE CROSSEDITION 5 DISABLE 6 BEGIN 7 ... 8 ... 9 END; 10 / Trigger created. 302
  • 303. both in the new edition "the working edition is sacred" 303
  • 304. SQL> alter session set edition = APP_V2; Session altered. SQL> alter trigger EMP_V1_TO_V2 enable; Trigger altered. 304
  • 305. all new / modified data 305
  • 307. SQL> alter session set edition = ORA$BASE; Session altered. SQL> declare 2 ok boolean; 3 scn number; 4 begin 5 ok := 6 dbms_utility.wait_on_pending_dml('"_EMP"',10, scn); 7 8 if ok then 9 update EMP set sal=sal; 10 end if; 11 end; 12 / PL/SQL procedure successfully completed. 307
  • 308. SQL> select empno, etype from "_EMP"; EMPNO ETYPE ---------- ---------- 1 Contract 2 Contract 7369 Permanent 7499 Permanent 7521 Permanent 7566 Permanent 7654 Permanent 7698 Permanent 7782 Permanent 7788 Permanent 7839 Permanent 7844 Permanent 7876 Permanent 7900 Permanent 7902 Permanent 7934 Permanent 308
  • 309. or DBMS_SQL 309
  • 311. voila ! 311
  • 313. SQL> create or replace 2 trigger DEFAULT_EDITION 3 after logon on database 4 begin 5 execute immediate 6 'alter session set edition = APP_V2'; 7 end; 8 / 313
  • 314. SQL> create or replace 2 trigger DEFAULT_EDITION 3 after logon on database 4 begin 5 dbms_session.set_edition_deferred( 'APP_V2' ); 7 end; 8 / 314
  • 315. retire old edition optional 315
  • 316. how do I get started 316
  • 318. 318
  • 319. stop ... taking ... outages 319
  • 321. 321
  • 322. more complicated than you think.... 322
  • 324. probably the whole database 324
  • 326. SQL> connect / as sysdba Connected. sys@db112> alter user TO_BE_EDITIONED enable editions; alter user TO_BE_EDITIONED enable editions * ERROR at line 1: ORA-38819: user TO_BE_EDITIONED owns one or more objects whose type is editionable and that have noneditioned dependent objects 326
  • 327. SQL> alter user TO_BE_EDITIONED enable editions FORCE; User altered. 327
  • 328. SQL> select owner, object_name, status 2 from dba_objects 3 where owner in ( 4 'TO_BE_EDITIONED', 5 'NOT_EDITIONED'); OWNER OBJECT_NAME STATUS --------------- ------------------- ------- TO_BE_EDITIONED EMP VALID NOT_EDITIONED MY_EMPV INVALID 328
  • 329. possibly not so "online" 329
  • 330. sys@db112> alter user TO_BE_EDITIONED enable editions; alter user TO_BE_EDITIONED enable editions * ERROR at line 1: ORA-38819: user TO_BE_EDITIONED owns one or more objects whose type is editionable and that have noneditioned dependent objects 330
  • 331. PARSING IN CURSOR #3 len=487 dep=1 uid=0 oct=3 ... select d.owner#, u.name, d.name, d.namespace, d.stime from obj$ d, dependency$ dep, obj$ p, user$ u where d.obj# = dep.d_obj# and p.obj# = dep.p_obj# and d.remoteowner is null and p.owner# = :1 and d.owner# = u.user# and p.type# in (4,5,7,8,9,10,11,12,13,14,22,87) and ((u.type# != 2 and bitand(u.spare1, 16) = 0 and u.user#!= p.owner#) or (d.type# not in 4,5,7,8,9,10,11,12,13,14,22,87))) 331
  • 332. PARSING IN CURSOR #3 len=487 dep=1 uid=0 oct=3 ... select d.owner#, u.name, d.name, dba_dependencies d.namespace, d.stime from obj$ d, dependency$ dep, obj$ p, user$ u where d.obj# = dep.d_obj# and p.obj# = dep.p_obj# and d.remoteowner is null and p.owner# = :1 and d.owner# = u.user# and p.type# in (4,5,7,8,9,10,11,12,13,14,22,87) and ((u.type# != 2 and bitand(u.spare1, 16) = 0 and u.user#!= p.owner#) or (d.type# not in 4,5,7,8,9,10,11,12,13,14,22,87))) 332
  • 333. PARSING IN CURSOR #3 len=487 dep=1 uid=0 oct=3 ... select d.owner#, u.name, d.name, dba_dependencies d.namespace, d.stime from obj$ d, dependency$ dep, obj$ p, user$ u object_type where d.obj# = dep.d_obj# and p.obj# = dep.p_obj# and d.remoteowner is null and p.owner# = :1 and d.owner# = u.user# and p.type# in (4,5,7,8,9,10,11,12,13,14,22,87) and ((u.type# != 2 and bitand(u.spare1, 16) = 0 and u.user#!= p.owner#) or (d.type# not in 4,5,7,8,9,10,11,12,13,14,22,87))) 333
  • 334. PARSING IN CURSOR #3 len=487 dep=1 uid=0 oct=3 ... select d.owner#, u.name, d.name, d.namespace, d.stime from obj$ d, dependency$ dep, obj$ p, user$ u object_type where d.obj# = dep.d_obj# and and p.obj# = dep.p_obj# d.remoteowner is null editions_enabled and p.owner# = :1 and d.owner# = u.user# and p.type# in (4,5,7,8,9,10,11,12,13,14,22,87) and ((u.type# != 2 and bitand(u.spare1, 16) = 0 and u.user#!= p.owner#) or (d.type# not in 4,5,7,8,9,10,11,12,13,14,22,87))) 334
  • 335. select * from DBA_DEPENDENCIES where ( OWNER in ( SELECT username from dba_users where EDITIONS_ENABLED = 'N' ) OR TYPE NOT IN ( 'VIEW','SYNONYM','PROCEDURE','FUNCTION' ,'PACKAGE','NON-EXISTENT','PACKAGE BODY' ,'TRIGGER','TYPE','TYPE BODY' ,'LIBRARY','ASSEMBLY') ) and REFERENCED_OWNER = 'TO_BE_EDITIONED' and TYPE IN ( 'VIEW','SYNONYM','PROCEDURE','FUNCTION' ,'PACKAGE','NON-EXISTENT','PACKAGE BODY' ,'TRIGGER','TYPE','TYPE BODY' ,'LIBRARY','ASSEMBLY') and REFERENCED_OWNER != OWNER 335
  • 336. table = data store for all versions... 336
  • 338. ... is not just editions 338
  • 339. version control create index online ddl_timeout fallback editions constraints column naming invisible indexes 339
  • 340. existing processes / scripts 340
  • 341. drop 341
  • 342. rename 342
  • 343. edition v1 T1 T2 edition v2 T2 T1 343
  • 344. edition v1 col1 _v1 NUMBER edition v2 col1 _v2 DATE 344
  • 345. edition v1 T1 (PK=col1,col2) edition v2 T1 (PK=col1,col3) 345
  • 346. contexts database links queues VPD FGA 346
  • 347. 347
  • 348. 348
  • 349. wrap up 349
  • 350. lots of things not covered 350
  • 351. 11g / 11.2 very very nice 351
  • 352. don't get too carried away 352
  • 353. "Oracle 11g is the greatest invention in the history of man" - Anon, 2008 353
  • 355. Connor McDonald OracleDBA co.uk 355
  • 356. ORA-00041 “active time limit exceeded - session terminated” www.oracledba.co.uk 356
  • 357. <apology> The presentation author apologises for the gratuitous use of family album shots, but since his whole family came to Melbourne for InSync, he didn't have much choice. <apology> 357