Professional Documents
Culture Documents
1
12/18/2015
2
12/18/2015
3
12/18/2015
4
12/18/2015
5
12/18/2015
Connor McDonald
Developer Advocate for SQL
2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted
6
12/18/2015
"why bother?"
"maybe"
7
12/18/2015
"why bother?"
(part 2)
don’t reinvent
8
12/18/2015
9
12/18/2015
multi- tenant
10
12/18/2015
multi- tenant
11
12/18/2015
"why bother?"
(part 3)
12
12/18/2015
Code
1985
Value
DB
Mainframe Client Web SOA
Server
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 23
Code
DB 1997
Value
13
12/18/2015
Cod
e
2013
Value
DB
14
12/18/2015
15
12/18/2015
?
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 27
be patient
16
12/18/2015
but beware
17
12/18/2015
or let us do it
18
12/18/2015
http://www.oracle.com/technetwork/community/developer-vm/index.html
19
12/18/2015
Feature:
total recall
20
12/18/2015
"hold on !"
21
12/18/2015
11g feature !
super sunday
22
12/18/2015
super sunday
23
12/18/2015
24
12/18/2015
SQL> desc T
25
12/18/2015
26
12/18/2015
27
12/18/2015
package
bulk binding
3 triggers
28
12/18/2015
11g+
compound trigger
29
12/18/2015
...
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 /
Trigger created.
30
12/18/2015
61
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
62
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
31
12/18/2015
Tablespace created.
63
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
64
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
32
12/18/2015
Table altered.
65
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
--------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
--------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | 518 |
| 1 | TABLE ACCESS FULL| EMP | 14 | 518 |
--------------------------------------------------
66
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
33
12/18/2015
--------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
--------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | 518 |
| 1 | TABLE ACCESS FULL| EMP | 14 | 518 |
--------------------------------------------------
67
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
3 days later...
68
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
34
12/18/2015
-----------------------------------------------------------------
| Id | Operation | Name | Rows |
-----------------------------------------------------------------
| 0 | SELECT STATEMENT | | 446 |
| 1 | VIEW | | 446 |
| 2 | UNION-ALL | | |
|* 3 | FILTER | | |
| 4 | PARTITION RANGE ITERATOR| | 445 |
|* 5 | TABLE ACCESS FULL | SYS_FBA_HIST_69539 | 445 |
|* 6 | FILTER | | |
|* 7 | HASH JOIN OUTER | | 1 |
|* 8 | TABLE ACCESS FULL | EMP | 1 |
|* 9 | TABLE ACCESS FULL | SYS_FBA_TCRV_69539 | 14 |
------------------------------------------------------------------
69
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
TABLE_NAME
---------------------------
SYS_FBA_HIST_71036
SYS_FBA_TCRV_71036
SYS_FBA_DDL_COLMAP_71036
EMP
70
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
35
12/18/2015
71
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
72
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
36
12/18/2015
SQL> commit;
73
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
74
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
37
12/18/2015
so why didn't we ?
75
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
reason 1
76
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
38
12/18/2015
77
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Table altered.
Table altered.
[etc]
[etc]
78
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
39
12/18/2015
reason 2
79
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
40
12/18/2015
separately licensed
81
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
82
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
41
12/18/2015
1) context extension
83
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
SQL> begin
2 dbms_flashback_archive.set_context_level(
3 level=> 'ALL');
4 end;
84
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
42
12/18/2015
1 row updated.
SQL> commit;
85
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
XID
----------------
09000B00C7080000
86
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
43
12/18/2015
88
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
44
12/18/2015
CURRENT_EDITION_NAME VARCHAR2(256)
CURRENT_SCHEMA VARCHAR2(256)
CURRENT_USER VARCHAR2(256)
DATABASE_ROLE VARCHAR2(256)
DB_NAME VARCHAR2(256)
GLOBAL_UID VARCHAR2(256)
HOST VARCHAR2(256)
IDENTIFICATION_TYPE VARCHAR2(256)
INSTANCE_NAME VARCHAR2(256)
IP_ADDRESS VARCHAR2(256)
MODULE VARCHAR2(256)
OS_USER VARCHAR2(256)
SERVER_HOST VARCHAR2(256)
SERVICE_NAME VARCHAR2(256)
SESSION_EDITION_NAME VARCHAR2(256)
SESSION_USER VARCHAR2(256)
SESSION_USERID VARCHAR2(256)
SESSIONID VARCHAR2(256)
TERMINAL VARCHAR2(256)
SPARE VARCHAR2(256)
90
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
45
12/18/2015
XID : 09000B00C7080000
AUTHENTICATED_IDENTITY : scott
CLIENT_IDENTIFIER :
CLIENT_INFO :
CURRENT_EDITION_NAME : ORA$BASE
CURRENT_SCHEMA : SYS
CURRENT_USER : SYS
DATABASE_ROLE : PRIMARY
DB_NAME : np12
HOST : WORKGROUP\XPS
IDENTIFICATION_TYPE : LOCAL
INSTANCE_NAME : np12
MODULE : SQL*Plus
OS_USER : xps\hamcdc
SERVER_HOST : xps
...
91
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
92
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
46
12/18/2015
93
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
SYSTEM tablespace
94
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
47
12/18/2015
95
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
48
12/18/2015
not a typo
49
12/18/2015
compression
partitioning
100
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
50
12/18/2015
secure
read only
102
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
51
12/18/2015
efficient
fdba
103
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
52
12/18/2015
"Gee...thanks"
106
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
53
12/18/2015
107
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
108
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
54
12/18/2015
DBMS_FLASHBACK_ARCHIVE.IMPORT_HISTORY
109
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
be careful...
110
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
55
12/18/2015
Table altered.
Flashback Archive:
Error ORA-1950 in SQL create table "SCOTT".SYS_FBA_DDL_COLMAP_91938
(STARTSCN NUMBER, ENDSCN NUMBER...
Flashback Archive:
Error ORA-942 in SQL insert into "SCOTT".SYS_FBA_DDL_COLMAP_91938
(ENDSCN, COLUMN_NAME, TYPE, ...
Flashback Archive:
Error ORA-942 in SQL "select count(*) from "SCOTT".SYS_FBA_DDL_COLMAP_91938"
111
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Feature:
better truncate
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 105
56
12/18/2015
Table created.
Table created.
1 row created.
1 row created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 106
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 107
57
12/18/2015
Table created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 108
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 109
58
12/18/2015
ERROR at line 1:
ORA-02298: cannot enable CHILD_FK - parent keys not found
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 109
12c
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 110
59
12/18/2015
Table truncated.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 111
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 112
60
12/18/2015
ERROR at line 1:
ORA-00933: SQL command not properly ended
ERROR at line 1:
ORA-02275: such a referential constraint already
exists in the table
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 113
full cascade
be careful
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 114
61
12/18/2015
referential partitions
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 115
Feature
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 116
62
12/18/2015
Sequence created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 117
NEXTVAL
----------
1
NEXTVAL
----------
1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 118
63
12/18/2015
"big deal"
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 119
"bad" reason
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 120
64
12/18/2015
X X
---------- ----------
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
... ...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 121
better reason
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 122
65
12/18/2015
contention
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 123
Sequence created.
66
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 125
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 126
67
12/18/2015
update SEQ$
set increment$=:2,minvalue=:3,maxvalue=:4,
cycle#=:5,order$=:6,
cache=:7,highwater=:8,audit$=:9,
flags=:10,partcount=:11
where
obj#=:1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 127
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 128
68
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 129
DBA
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 130
69
12/18/2015
temporary undo
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 131
temporary undo
+
session sequences
+
active dataguard
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 132
70
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 133
Feature:
defaults
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 134
71
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 135
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 136
72
12/18/2015
usage of triggers
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 137
Sequence created.
Table created.
Trigger created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 138
73
12/18/2015
Sequence created.
Table created.
Trigger created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 138
1 row created.
PK C1
---------- ----------
1 20
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 139
74
12/18/2015
we got smarter
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 140
PK C1
---------- ----------
1 20
20 20
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 141
75
12/18/2015
triggers
76
12/18/2015
77
12/18/2015
June 1992
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 147
78
12/18/2015
PK C1
---------- ----------
2 0
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 148
PK C1
---------- ----------
2 0
3 1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 149
79
12/18/2015
80
12/18/2015
identity
Table dropped.
Table created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 153
81
12/18/2015
SEQUENCE_NAME : ISEQ$$_414914
MIN_VALUE : 1
MAX_VALUE : 9999999999999999999999
INCREMENT_BY : 1
CYCLE_FLAG : N
ORDER_FLAG : N
CACHE_SIZE : 20
LAST_NUMBER : 1
PARTITION_COUNT :
SESSION_FLAG : N
KEEP_VALUE : N
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 154
Table created.
can choose
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 155
82
12/18/2015
before 12c
83
12/18/2015
Table created.
1 row created.
1 row created.
1 row created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 158
PK STATUS
---------- ------
1 N
2 N
3
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 159
84
12/18/2015
workarounds unpleasant
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 160
Procedure created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 161
85
12/18/2015
1 row created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 163
86
12/18/2015
Feature
query expansion
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 164
Statistics
------------------------------------------
651 recursive calls
0 db block gets
2243 consistent gets
24 physical reads
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 165
87
12/18/2015
SQL> begin
2 dbms_utility.expand_sql_text
3 ( 'select * from MY_VIEW'||
4 'where created > sysdate',:c);
5 end;
6 /
SQL> print c
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 166
View created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 167
88
12/18/2015
"A4"."HEADER_BLOCK",
"A4"."SEGMENT_TYPE_ID",
"A4"."BUFFER_POOL_ID",
"A4"."SEGMENT_FLAGS",
"A4"."SEGMENT_OBJD",
"A4"."BLOCKS"),
"A4"."BLOCKS")) "BLOCKS",DECODE(BITAND("A4"."SEGMENT_FLAGS",131072),131072,
"A4"."EXTENTS",DECODE(BITAND("A4"."SEGMENT_FLAGS",1),1,
"SYS"."DBMS_SPACE_ADMIN"."SEGMENT_NUMBER_EXTENTS"("A4"."TABLESPACE_ID",
"A4"."RELATIVE_FNO",
"A4"."HEADER_BLOCK",
"A4"."SEGMENT_TYPE_ID",
"A4"."BUFFER_POOL_ID",
"A4"."SEGMENT_FLAGS",
"A4"."SEGMENT_OBJD",
"A4"."EXTENTS"),
"A4"."EXTENTS")) "EXTENTS",
"A4"."INITIAL_EXTENT" "INITIAL_EXTENT",
"A4"."NEXT_EXTENT" "NEXT_EXTENT",
"A4"."MIN_EXTENTS" "MIN_EXTENTS",
"A4"."MAX_EXTENTS" "MAX_EXTENTS",
"A4"."MAX_SIZE" "MAX_SIZE",
"A4"."RETENTION" "RETENTION",
"A4"."MINRETENTION" "MINRETENTION",
"A4"."PCT_INCREASE" "PCT_INCREASE",
"A4"."FREELISTS" "FREELISTS",
"A4"."FREELIST_GROUPS" "FREELIST_GROUPS",
"A4"."RELATIVE_FNO" "RELATIVE_FNO",Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 169
DECODE("A4"."BUFFER_POOL_ID",1,'KEEP',2,'RECYCLE','DEFAULT') "BUFFER_POOL",
89
12/18/2015
"A198"."SUBNAME" "PARTITION_NAME",
"A196"."OBJECT_TYPE" "SEGMENT_TYPE",
"A195"."TYPE#" "SEGMENT_TYPE_ID",DECODE(BIT
AND("A195"."SPARE1",2097408),2097152,'SECUREFILE',256,'ASSM','MSSM')
"SEGMENT_SUBTYPE",
"A197"."TS#" "TABLESPACE_ID",
"A197"."NAME" "TABLESPACE_NAME",
"A197"."BLOCKSIZE" "BLOCKSIZE",
"A194"."FILE#" "HEADER_FILE",
"A195"."BLOCK#" "HEADER_BLOCK",
"A195"."BLOCKS"*"A197"."BLOCKSIZE" "BYTES",
"A195"."BLOCKS" "BLOCKS",
"A195"."EXTENTS" "EXTENTS",
"A195"."INIEXTS"*"A197"."BLOCKSIZE" "INITIAL_EXTENT",
"A195"."EXTSIZE"*"A197"."BLOCKSIZE" "NEXT_EXTENT",
"A195"."MINEXTS" "MIN_EXTENTS",
"A195"."MAXEXTS"
"MAX_EXTENTS",DECODE(BITAND("A195"."SPARE1",4194304),4194304,
"A195"."BITMAPRANGES",NULL) "MAX_SIZE",TO_CHAR(DECODE(
BITAND("A195"."SPARE1",2097152),2097152,
DECODE("A195"."LISTS",0,'NONE',1,'AUTO',2,'MIN',3,'MAX',4,'DEFAULT','INVALID'
),NULL))
"RETENTION",DECODE(BITAND("A195"."SPARE1",2097152),2097152,
"A195"."GROUPS",NULL)
"MINRETENTION",DECODE(BITAND("A197"."FLAGS",3),1,TO_NUMBER(NULL),
"A195"."EXTPCT") "PCT_INCREASE",DECODE(BITAND("A197"."FLAGS",32),32,
TO_NUMBER(NULL),DECODE("A195"."LISTS",0,1,
"A195"."LISTS"))
"FREELISTS",DECODE(BITAND("A197"."FLAGS",32),32,TO_NUMBER(NULL),DECODE("A195"
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 170
."GROUPS",0,1,
"A195"."GROUPS")) "FREELIST_GROUPS",
DECODE(BITAND("A209"."PROPERTY",8192),8192,'NESTED TABLE','TABLE')
"OBJECT_TYPE",
2 "OBJECT_TYPE_ID",5 "SEGMENT_TYPE_ID",
"A209"."OBJ#" "OBJECT_ID",
"A209"."FILE#" "HEADER_FILE",
"A209"."BLOCK#" "HEADER_BLOCK",
"A209"."TS#" "TS_NUMBER" FROM "SYS"."TAB$" "A209" WHERE
BITAND("A209"."PROPERTY",1024)=0) UNI
ON ALL (SELECT 'TABLE PARTITION' "OBJECT_TYPE",19 "OBJECT_TYPE_ID",5
"SEGMENT_TYPE_ID",
"A208"."OBJ#" "OBJECT_ID",
"A208"."FILE#" "HEADER_FILE",
"A208"."BLOCK#" "HEADER_BLOCK",
"A208"."TS#" "TS_NUMBER" FROM "SYS"."TABPART$" "A208") UNION ALL
(SELECT 'CLUSTER' "OBJECT_TYPE",3 "OBJECT_TYPE_ID",5 "SEGMENT_TYPE_ID",
"A207"."OBJ#" "OBJECT_ID",
"A207"."FILE#" "HEADER_FILE",
"A207"."BLOCK#" "HEADER_BLOCK",
"A207"."TS#" "TS_NUMBER" FROM "SYS"."CLU$" "A207") UNION ALL
(SELECT DECODE("A206"."TYPE#",8,'LOBINDEX','INDEX') "OBJECT_TYPE",1
"OBJECT_TYPE_ID",6 "SEGMENT_TYPE_ID",
"A206"."OBJ#" "OBJECT_ID",
"A206"."FILE#" "HEADER_FILE",
"A206"."BLOCK#" "HEADER_BLOCK",
"A206"."TS#" "TS_NUMBER" FROM "SYS"."IND$" "A206" WHERE "A206"."TYPE#"=1 OR
"A206"."TYPE#"=2 OR
"A206"."TYPE#"=3 OR
"A206"."TYPE#"=4 OR
"A206"."TYPE#"=6 OR Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 171
"A206"."TYPE#"=7 OR
90
12/18/2015
91
12/18/2015
"A191"."TS#"="A189"."TS#" AND
"A191"."FILE#"="A189"."RELFILE#") UNION ALL
(SELECT NVL("A188"."NAME",'SYS') "OWNER",
TO_CHAR("A185"."FILE#")||'.'||TO_CHAR("A186"."BLOCK#")
"SEGMENT_NAME",NULL "PARTITION_NAME",
DECODE("A186"."TYPE#",2,'DEFERRED ROLLBACK',3,
'TEMPORARY',4,'CACHE',9,'SPACE HEADER','UNDEFINED')
"SEGMENT_TYPE",
"A186"."TYPE#" "SEGMENT_TYPE_ID",NULL
"SEGMENT_SUBTYPE",
"A187"."TS#" "TABLESPACE_ID",
"A187"."NAME" "TABLESPACE_NAME",
"A187"."BLOCKSIZE" "BLOCKSIZE",
"A185"."FILE#" "HEADER_FILE",
"A186"."BLOCK#" "HEADER_BLOCK",
"A186"."BLOCKS"*"A187"."BLOCKSIZE" "BYTES",
"A186"."BLOCKS" "BLOCKS",
"A186"."EXTENTS" "EXTENTS",
"A186"."INIEXTS"*"A187"."BLOCKSIZE" "INITIAL_EXTENT",
"A186"."EXTSIZE"*"A187"."BLOCKSIZE" "NEXT_EXTENT",
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 174
"A186"."MINEXTS" "MIN_EXTENTS",
"A186"."TYPE#"<>6 AND
"A186"."TYPE#"<>8 AND
"A186"."TYPE#"<>10 AND
"A186"."TYPE#"<>11 AND
"A186"."TS#"="A185"."TS#"
AND
"A186"."FILE#"="A185"."RELFILE#") UNION ALL
(SELECT NVL("A184"."NAME",'SYS') "OWNER",'HEATMAP' "SEGMENT_NAME",
NULL "PARTITION_NAME",'SYSTEM STATISTICS' "SEGMENT_TYPE",
"A182"."TYPE#" "SEGMENT_TYPE_ID",NULL "SEGMENT_SUBTYPE",
"A183"."TS#" "TABLESPACE_ID",
"A183"."NAME" "TABLESPACE_NAME",
"A183"."BLO
CKSIZE" "BLOCKSIZE",
"A181"."FILE#" "HEADER_FILE",
"A182"."BLOCK#" "HEADER_BLOCK",
"A182"."BLOCKS"*"A183"."BLOCKSIZE" "BYTES",
"A182"."BLOCKS" "BLOCKS",
"A182"."EXTENTS" "EXTENTS",
"A182"."INIEXTS"*"A183"."BLOCKSIZE" "INITIAL_EXTENT",
"A182"."EXTSIZE"*"A183"."BLOCKSIZE" "NEXT_EXTENT",
"A182"."MINEXTS" "MIN_EXTENTS",
"A182"."MAXEXTS"
"MAX_EXTENTS",DECODE(BITAND("A182"."SPARE1",4194304),4194304,
"A182"."BITMAPRANGES",NULL) "MAX_SIZE",NULL "RETENTION",NULL
"MINRETENTION",DECODE(BITAND("A183"."FLAGS",3),1,TO_NUMBER(NULL),
"A182"."EXTPCT")
"PCT_INCREASE",DECODE(BITAND("A183"."FLAGS",32),32,TO_NUMBER(NULL),DEC
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 175
ODE("A182"."LISTS",0,1,
92
12/18/2015
"SYS"."TS$" "A183",
"SYS"."SEG$" "A182",
"SYS"."FILE$" "A181" WHERE "A182"."TS#"="A183"."TS#" AND
"A182"."USER#"="A184"."USER#"(+) AND
"A182"."TYPE#"=11 AND
"A182"."TS#"="A181"."TS#" AND
"A182"."FILE#"="A181"."RELFILE#")) "A4") "A3", (SELECT "A5"."NAME" "OWNER",
"A6"."NAME" "OBJECT_NAME",
"A6"."SUBNAME" "SUBOBJECT_NAME",
"A6"."OBJ#" "OBJECT_ID",
"A6"."DATAOBJ#" "DATA_OBJECT_ID",DECODE("A6"."TYPE#",0,'NEXT OBJECT',1,'INDEX',
2,'TABLE',3,'CLUSTER',4,'VIEW',5,'SYNONYM
',6,'SEQUENCE',7,'PROCEDURE',8,'FUNCTION',9,'PACKAGE',11,'PACKAGE BODY',12,
'TRIGGER',13,'TYPE',14,'TYPE BODY',19,'TABLE PARTITION',20,'INDEX PARTITION',
21,'LOB',22,'LIBRARY',23,'DIRECTORY',24,'QUEUE',28,'JAVA SOURCE',29,'JAVA CLASS',30,
'JAVA RESOURCE',32,'INDEXTYPE',33,'OPERATOR',34,
'TABLE SUBPARTITION',35,'INDEX SUBPARTITION',40,'LOB PARTITION',41,'LOB SUBPARTITION',42
,NVL( (SELECT 'REWRITE EQUIVALENCE' "'REWRITEEQUIVALENCE'" FROM SYS."SUM$" "A52" WHERE
"A52"."OBJ#"="A6"."OBJ#" AND
BITAND("A52"."XPFLAGS",8388608)=8388608),'MATERIALIZED VIEW'),43,'DIMENSION',
44,'CONTEXT',46,'RULE SET',47,'RESOURCE PLAN',48,'CONSUMER GROUP',55,'XML SCHEMA',56,'JAVA
DATA',57,'EDITION',59,'RULE',
60,'CAPTURE',61,'APPLY',62,'EVALUATION CONTEXT',66,'JOB',67,'PROGRAM',68,'JOB CLASS',69,
'WINDOW',72,'SCHEDULER GROUP',74,'SCHEDULE',79,'CHAIN',81,'FILE GROUP',82,'MINING
MODEL',87,'ASSEMBLY',90,'CREDENTIAL',92,'CUBE
DIMENSION',93,'CUBE',94,'MEASURE FOLDER',95,'CUBE BUILD PROCESS',100,'FILE WATCHER',
101,'DESTINATION',114,'SQL TRANSLATION PROFILE',115,'UNIFIED AUDIT POLICY','UNDEFINED')
"OBJECT_TYPE",
"A6"."CTIME" "CREATED", Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 176
16 ...
more
pages
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 177
93
12/18/2015
Feature
PL/SQL debugging
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 179
94
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 180
SQL> exec P;
BEGIN P; END;
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "SCOTT.P", line 13
ORA-06512: at line 1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 181
95
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 182
96
12/18/2015
SQL> exec P;
BEGIN P; END;
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "SCOTT.P", line 22
97
12/18/2015
?
9 into y
10 from all_objects
11 where object_name = 'NUFFIN';
12
13 x := x / y;
14
15 select rownum
16 into x
17 from dual;
18
19 exception
20 when others then
21 log_error;
22 raise;
23 end;
24 /
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 186
...
18
19 exception
20 when others then
21 dbms_output.put_line(
22 dbms_utility.format_call_stack);
23 raise;
24 end;
25 /
98
12/18/2015
SQL> exec P;
BEGIN P; END;
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "SCOTT.P", line 23
ORA-06512: at line 1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 188
26 dbms_output.put_line(l_debug);
99
12/18/2015
SQL> exec P;
----- PL/SQL Call Stack -----
object line object
handle number name
0x14b1e3900 16 procedure SCOTT.P
0x12521b8d8 1 anonymous block
BEGIN P; END;
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "SCOTT.P", line 27
ORA-06512: at line 1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 190
----- PL/SQL Call Stack -----\n object line object\n handle number name ...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 191
100
12/18/2015
24 exception
25 when others then
26 l_debug := substr(l_debug,instr(l_debug,chr(10),1,3));
27 l_debug := regexp_replace(l_debug,chr(10)||'.*$');
28 dbms_output.put_line(l_debug);
29 raise;
30 end;
31 /
SQL> exec P;
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "SCOTT.P", line 29
ORA-06512: at line 1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 193
101
12/18/2015
DBMS_UTILITY.FORMAT_ERROR_BACKTRACE
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 195
102
12/18/2015
SQL> exec P;
ORA-06512: at "SCOTT.P", line 17
BEGIN P; END;
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "SCOTT.P", line 27
ORA-06512: at line 1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 197
103
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 199
104
12/18/2015
UTL_CALL_STACK
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 201
105
12/18/2015
SQL> exec P;
16-P
1-__anonymous_block
BEGIN P; END;
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "SCOTT.P", line 27
ORA-06512: at line 1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 203
106
12/18/2015
Package created.
107
12/18/2015
23-PKG.P
32-PKG.P1
33-PKG.P2
34-PKG.P3
1-__anonymous_block
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "SCOTT.PKG", line 29
ORA-06512: at "SCOTT.PKG", line 32
ORA-06512: at "SCOTT.PKG", line 33
ORA-06512: at "SCOTT.PKG", line 34
ORA-06512: at line 1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 207
108
12/18/2015
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "SCOTT.PKG", line 29
ORA-06512: at "SCOTT.PKG", line 32
ORA-06512: at "SCOTT.PKG", line 33
ORA-06512: at "SCOTT.PKG", line 34
ORA-06512: at line 1
Feature
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 209
109
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 211
110
12/18/2015
no correlation
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 213
111
12/18/2015
SURNAME
------------------------------
jones
brown
SMITH
sigh...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 215
112
12/18/2015
INITCAP(SURNAME)
------------------------------
Jones
Brown
Smith
until ...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 217
113
12/18/2015
INITCAP(SURNAME)
------------------------------
Jones
Brown
Smith
Mcdonald
Johnson'S
home grown
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 219
114
12/18/2015
cool ...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 221
115
12/18/2015
MY_INITCAP(SURNAME)
--------------------------
Jones
Brown
Smith
McDonald
Johnson's
until ...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 223
116
12/18/2015
DBA
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 224
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 225
117
12/18/2015
...
Elapsed: 00:00:00.48
Elapsed: 00:00:09.37
118
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 227
SQL> select
2 case
3 when regexp_like(surname,'(Mac[A-Z]|Mc[A-Z])') then surname
4 when surname like '''%' then surname
5 when initcap(surname) like '_''S%' then surname
6 else replace(initcap(surname),'''S','''s')
7 end ugh
8 from names;
UGH
-------------------------------
Jones
Brown
Smith
McDonald
Johnson's
119
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 230
120
12/18/2015
SQL> WITH
2 function my_initcap(p_string varchar2) return varchar2 is
3 l_string varchar2(1000) := p_string;
4 begin
5 if regexp_like(l_string,'(Mac[A-Z]|Mc[A-Z])') then
6 null;
7 elsif l_string like '''%' then
...
17
18 return l_string;
19 end;
20 select my_initcap(surname)
21 from names;
MY_INITCAP(SURNAME)
-----------------------------------------
Jones
Brown
Smith
McDonald
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 232
multiple routines
121
12/18/2015
SQL> WITH
2 function is_scottish(p_string varchar2) return boolean is
3 begin
4 return regexp_like(p_string,'(Mac[A-Z]|Mc[A-Z])');
5 end;
6 function my_initcap(p_string varchar2) return varchar2 is
7 l_string varchar2(1000) := p_string;
8 begin
9 if is_scottish(l_string) then
10 null;
11 elsif l_string like '''%' then
12 null;
13 else
14 l_string := initcap(l_string);
15 if l_string like '_''S%' then
..
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 234
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 235
122
12/18/2015
SQL> WITH
2 function my_initcap(p_string varchar2) return varchar2 is
3 l_string varchar2(1000) := p_string;
SQL> begin
2 if regexp_like(l_string,'(Mac[A-Z]|Mc[A-Z])') then
3 null;
4 elsif l_string like '''%' then
5 null;
6 else
7 l_string := initcap(l_string);
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 237
123
12/18/2015
workaround
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 238
124
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 240
Procedure created.
125
12/18/2015
WITH_PLSQL
unrelated to previous
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 242
126
12/18/2015
WITH
*
ERROR at line 2:
ORA-32034: unsupported use of WITH clause
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 244
5 rows inserted.
127
12/18/2015
determinism
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 246
SQL> with
2 function f return timestamp as
3 begin
4 return systimestamp;
5 end;
6 select f
7 from dual
8 connect by level <= 10;
9 /
F
----------------------------------------
05-JAN-14 08.09.43.969000000 PM
05-JAN-14 08.09.43.970000000 PM
05-JAN-14 08.09.43.970000000 PM
05-JAN-14 08.09.43.971000000 PM
...
128
12/18/2015
DETERMINISTIC keyword
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 248
SQL> with
2 function f return timestamp DETERMINISTIC as
3 begin
4 return systimestamp;
5 end;
6 select f
7 from dual
8 connect by level <= 10;
9 /
F
----------------------------------------
05-JAN-14 08.09.52.145000000 PM
05-JAN-14 08.09.52.146000000 PM
05-JAN-14 08.09.52.146000000 PM
05-JAN-14 08.09.52.147000000 PM
...
129
12/18/2015
no no no!
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 250
SQL> with
2 function f return timestamp as
3 begin
4 return systimestamp;
5 end;
6 select ( select f from dual )
7 from dual
8 connect by level <= 10;
9 /
F
----------------------------------------
05-JAN-14 08.11.50.145000000 PM
05-JAN-14 08.11.50.145000000 PM
05-JAN-14 08.11.50.145000000 PM
05-JAN-14 08.11.50.145000000 PM
...
130
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 252
Function created.
131
12/18/2015
Elapsed: 00:00:02.04
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 254
SQL> with
2 function f1 return number is
3 begin
4 return 1;
5 end;
6 select sum(f1)
7 from
8 ( select level from dual
9 connect by level <= 1000 ),
10 ( select level from dual
11 connect by level <= 1000 )
12 /
Elapsed: 00:00:00.52
132
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 256
Elapsed: 00:00:00.36
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
133
12/18/2015
Feature
JSON
ACCOUNTING,KING,PRESIDENT,5000
ACCOUNTING,MILLER,CLERK,1300
134
12/18/2015
ACCOUNTING,KING,PRESIDENT,5000
ACCOUNTING,MILLER,CLERK,1300
<department name="ACCOUNTING">
<employees>
<employee>
<ename>KING</ename>
<job>PRESIDENT</job>
<sal>5000</sal>
</employee>
<employee>
<ename>MILLER</ename>
<job>CLERK</job>
<sal>1300</sal>
</employee>
</employees>
</department>
135
12/18/2015
<department name="ACCOUNTING">
<employees>
<employee>
<ename>KING</ename>
<job>PRESIDENT</job>
<sal>5000</sal>
</employee>
<employee>
<ename>MILLER</ename>
<job>CLERK</job>
<sal>1300</sal>
</employee>
</employees>
</department>
{ "NAME" :"ACCOUNTING"
, "EMPLOYEES" : [
{"ENAME" : "KING",
"JOB" : "PRESIDENT",
"SAL" : 5000
},
{"ENAME" : "MILLER",
"JOB" : "CLERK",
"SAL" : 1300
}]
}
136
12/18/2015
{ Name : Value }
{
Name : Value,
Name : Value,
Name : Value
}
137
12/18/2015
{
{
Name : Value,
Name : Value,
Name : Value
}
,
{
Name : Value,
Name : Value,
Name : Value
}
}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
create table T
( id number(10),
my_doc varchar2(4000)
)
138
12/18/2015
alter table T
add constraint t_chk
check
(
my_doc is JSON
)
1 row inserted.
139
12/18/2015
extraction
140
12/18/2015
TAG
------
json
1 row created.
141
12/18/2015
ENAME
----------
KING
RESULT
---------
[{"ENAME":"KING","JOB":"PRESIDENT","SAL":5000},{"ENAME":
"MILLER","JOB":"CLERK","SAL":1300}]
142
12/18/2015
dot notation
143
12/18/2015
transformation
144
12/18/2015
searching
COUNT(*)
----------
1
COUNT(*)
----------
1
145
12/18/2015
search (performance)
146
12/18/2015
4 )
5 );
147
12/18/2015
2) text indexes
148
12/18/2015
Feature
invisible columns
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 285
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 286
149
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 287
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 288
150
12/18/2015
Table created.
Index created.
Table altered.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 289
COLUMN_NAME DATA_DEFAULT
------------------------------ ----------------
X
SYS_NC00003$ "X"+0
SYS_C00002_14020720:50:28$
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 290
151
12/18/2015
now exposed to us
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 291
SQL> desc T
SQL> desc T
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 292
152
12/18/2015
and an idiosyncracy...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 293
SQL> desc T
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 294
153
12/18/2015
requires discipline
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 295
Procedure created.
SQL> exec P
Table altered.
Table altered.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 296
154
12/18/2015
SQL> exec P
C2 C3 C1
---------- ---------- ----------
10 100 1
1 10 100
SQL> desc T
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 297
155
12/18/2015
SQL> desc T
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 299
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 300
156
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 301
Table created.
Procedure created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 302
157
12/18/2015
new application
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 303
Table altered.
Procedure created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 304
158
12/18/2015
28
28
15
15
29
29
25
25
54
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 305
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 306
159
12/18/2015
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00905: object SCOTT.APP1 is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 308
160
12/18/2015
Table altered.
28
28
15
[snip]
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 309
tools
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 310
161
12/18/2015
Table created.
SQL> desc T
Name Null? Type
------------------------- -------- ------------------
C1 NUMBER(38)
SQL> desc T
Name Null? Type
------------------------- -------- -----------
C1 NUMBER(38)
C2 (INVISIBLE) NUMBER(38)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 311
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 312
162
12/18/2015
Table altered.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 313
Table altered.
SQL> desc T
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 313
163
12/18/2015
use LHS
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 314
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 315
164
12/18/2015
Wrap up
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 412
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 413
165
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 414
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 415
166
12/18/2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 416
Connor McDonald
417 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
167
12/18/2015
ORA-03113
417 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
https://commons.wikimedia.org/wiki/File:Horse_Race_Finish_Line_(11888565543).jpg
https://pixabay.com/en/iphone-iphone-6-apple-flat-762044/
https://pixabay.com/en/curve-return-pass-road-384406/
https://pixabay.com/en/high-five-figure-man-blue-150911/
https://pixabay.com/en/joker-jester-card-playing-card-164030/
https://commons.wikimedia.org/wiki/File:2008-08-19_Flat_tire.jpg
168