Beruflich Dokumente
Kultur Dokumente
WE
ARE
SHOWING
CODING SAMPLES
SO IF YOU HAVE PASSED
THE AGE OF TWENTY THEN YOU SHOULD PROBABLY THINK
ABOUT SITTING RIGHT UP CLOSE TO THE FRONT OF THE ROOM BECAUSE OTHERWISE YOU MIGHT MISS OUT
A N D I F Y O U C A N R E A D T H I S, T H E N Y O U S H O U L D L E A V E B E C A U S E Y O U H A V E S U P E R P O W E R S A N D Y O U S H O U L D B E I N A N A V E N G E R S M O V I E N O T L E A R N I N G A B O U T I N F O R M A T I O N T E C H N O L O G Y. :-)
1
6/13/2017
@connor_mc_d connormcdonald.wordpress.com
2
6/13/2017
https://www.youtube.com/c/ConnorMcDonaldOracle
https://www.facebook.com/connor.mcdonald42
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 5
Connor McDonald
Developer Advocate
June 2017
3
6/13/2017
why am I here ?
4
6/13/2017
5
6/13/2017
6
6/13/2017
7
6/13/2017
"why am I here?"
12.2!
12.2! 12.2!
12.2!12.2!
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 16
8
6/13/2017
reality
9
6/13/2017
BANNER
----------------------------------------------------------
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
PL/SQL Release 8.1.7.4.0 - Production
CORE 8.1.7.0.0 Production
TNS for HPUX: Version 8.1.7.4.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
BANNER
----------------------------------------------------------
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
PL/SQL Release 8.1.7.4.0 - Production
CORE 8.1.7.0.0 Production
TNS for HPUX: Version 8.1.7.4.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
10
6/13/2017
BANNER
----------------------------------------------------------
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
PL/SQL Release 8.1.7.4.0 - Production
CORE 8.1.7.0.0 Production
TNS for HPUX: Version 8.1.7.4.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
11
6/13/2017
dont reinvent
12
6/13/2017
13
6/13/2017
install nothing
https://cloud.oracle.com/tryit
14
6/13/2017
install something
http://tinyurl.com/ora122vm
15
6/13/2017
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
16
6/13/2017
17
6/13/2017
18
6/13/2017
licensing
19
6/13/2017
asktom.oracle.com
20
6/13/2017
1
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 41
longer names
21
6/13/2017
128 bytes
"awesome"
22
6/13/2017
Table created.
true
23
6/13/2017
TABLE_NAME
------------------------------
T001B Permitted Posting Periods
T003 Document types
T004 Chart of accounts
T009 Fiscal year variants
T010O Posting periods
T010P Posting Period Names
T012 House banks
T014 Credit control area
T077S Account group (G/L accounts)
T880 Global company data
...
24
6/13/2017
and...
Table created.
25
6/13/2017
but...
COLUMN_NAME
------------------------------
SomeRidiculousPieceOfNonsenseBySomeDudeWhoWantsToAlignWithHisDotNetCodi
ngStyle NUM_DISTINCT AVG_COL_LEN NUM_NULLS
------------ ----------- ----------
26
6/13/2017
Trigger created.
27
6/13/2017
Table created.
Table altered.
28
6/13/2017
2
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 57
29
6/13/2017
30
6/13/2017
12.2
31
6/13/2017
SQL> declare
2 c_var_length constant pls_integer := 30;
3 l_str varchar2(c_var_length);
4 begin
5 null;
6 end;
7 /
32
6/13/2017
SQL
function
SQL> declare
2 c_var_length constant pls_integer := to_number('30');
3 l_str varchar2(c_var_length);
4 begin
5 null;
6 end;
7 /
l_str varchar2(c_var_length);
*
ERROR at line 3:
ORA-06550: line 3, column 25:
PLS-00491: numeric literal required
33
6/13/2017
SQL> declare
2 c_var_length constant pls_integer := 30;
3 l_str varchar2(c_var_length);
34
6/13/2017
start today
35
6/13/2017
user_tables.table_name%type
36
6/13/2017
37
6/13/2017
3
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 76
38
6/13/2017
Name Type
--------------------------------------------------------------------------------- ----------
SALES_PK NUMBER(38)
DATE_AT_WHICH_CUSTOMER_CAME_INTO_THE_STOP DATE
DATE_AT_WHICH_CUSTOMER_CAME_LEFT_THE_STOP DATE
DURATION_CUSTOMER_SPENT_BROWSING_SALES_CATALOG_BEFORE_ASKING_FOR_ASSISTANCE_MINS NUMBER(38)
ITEM_THAT_CUSTOMER_PURCHASED VARCHAR2(50)
AMOUNT_CUSTOMER_TENDERED_TO_CASHIER_IN_50DOLLAR_NOTES NUMBER(38)
AMOUNT_CUSTOMER_TENDERED_TO_CASHIER_IN_20DOLLAR_NOTES NUMBER(38)
AMOUNT_CUSTOMER_TENDERED_TO_CASHIER_IN_10DOLLAR_NOTES NUMBER(38)
AMOUNT_CUSTOMER_TENDERED_TO_CASHIER_IN_5DOLLAR_NOTES NUMBER(38)
AMOUNT_CUSTOMER_TENDERED_TO_CASHIER_IN_COINS_IN_TOTAL_CENTS NUMBER(38)
LENGTH_IN_MILLIMETERS_OF_THE_RECEIPT_WE_PRINTED_FOR_THE_CUSTOMER NUMBER(38)
AVERAGE_LENGTH_OF_SHOELACE_OF_STORE_ASSISTANT_THAT_HELPED_THE_CUSTOMER NUMBER(38)
...
...
...
39
6/13/2017
*
ERROR at line 1:
ORA-01489: result of string concatenation is too long
40
6/13/2017
tough to solve
SQL> select
2 column_name,
3 ( select listagg(column_name,',') within group ( order by column_id )
4 from all_tab_columns
5 where table_name = 'EMP'
6 and owner = 'SCOTT'
7 and column_id <= a.column_id ) cols
8 from all_tab_columns a
9 where table_name = 'EMP'
10 and owner = 'SCOTT'
11 order by column_id;
COLUMN_NAME COLS
------------------------------ ----------------------------------------------------
EMPNO EMPNO
ENAME EMPNO,ENAME
JOB EMPNO,ENAME,JOB
MGR EMPNO,ENAME,JOB,MGR
HIREDATE EMPNO,ENAME,JOB,MGR,HIREDATE
SAL EMPNO,ENAME,JOB,MGR,HIREDATE,SAL
COMM EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM
DEPTNO EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO
8 rows selected.
41
6/13/2017
first principles
pipeline function
12.2
42
6/13/2017
TABLE_NAME COLS
------------- ------------------------------------------------------------
STORE_SALES SALES_PK,DATE_AT_WHICH_CUSTOMER_CAME_INTO_THE_STOP,DATE_AT_W
HICH_CUSTOMER_CAME_LEFT_THE_STOP,DURATION_CUSTOMER_SPENT_BRO
WSING_SALES_CATALOG_BEFORE_ASKING_FOR_ASSISTANCE_IN_MINS,ITE
,LENGTH_IN_MILLIMETERS_OF_THE_RECEIPT_WE_PRINTED_FOR_THE_CUS
[snip]
TIME_SPENT_WHILST_REFOLDING_ITE...(2378)
43
6/13/2017
TABLE_NAME COLS
------------- ------------------------------------------------------------
STORE_SALES SALES_PK,DATE_AT_WHICH_CUSTOMER_CAME_INTO_THE_STOP,DATE_AT_W
HICH_CUSTOMER_CAME_LEFT_THE_STOP,DURATION_CUSTOMER_SPENT_BRO
WSING_SALES_CATALOG_BEFORE_ASKING_FOR_ASSISTANCE_IN_MINS,ITE
,LENGTH_IN_MILLIMETERS_OF_THE_RECEIPT_WE_PRINTED_FOR_THE_CUS
[snip]
TIME_SPENT_WHILST_REFOLDING_ITE[more](2378)
44
6/13/2017
TABLE_NAME COLS
------------- ------------------------------------------------------------
STORE_SALES SALES_PK,DATE_AT_WHICH_CUSTOMER_CAME_INTO_THE_STOP,DATE_AT_W
HICH_CUSTOMER_CAME_LEFT_THE_STOP,DURATION_CUSTOMER_SPENT_BRO
WSING_SALES_CATALOG_BEFORE_ASKING_FOR_ASSISTANCE_IN_MINS,ITE
,LENGTH_IN_MILLIMETERS_OF_THE_RECEIPT_WE_PRINTED_FOR_THE_CUS
[snip]
TIME_SPENT_WHILST_REFOLDING_ITE[more]
TABLE_NAME COLS
------------- ------------------------------------------------------------
STORE_SALES SALES_PK,DATE_AT_WHICH_CUSTOMER_CAME_INTO_THE_STOP,DATE_AT_W
HICH_CUSTOMER_CAME_LEFT_THE_STOP,DURATION_CUSTOMER_SPENT_BRO
WSING_SALES_CATALOG_BEFORE_ASKING_FOR_ASSISTANCE_IN_MINS,ITE
,LENGTH_IN_MILLIMETERS_OF_THE_RECEIPT_WE_PRINTED_FOR_THE_CUS
[snip]
TIME_SPENT_WHILST_REFOLDING_ITE
45
6/13/2017
4
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 91
QTFWBC
46
6/13/2017
47
6/13/2017
48
6/13/2017
49
6/13/2017
Elapsed: 06:12:34.00
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 100
50
6/13/2017
Elapsed: 06:12:34.00
ERROR at line 1:
ORA-01847: day of month must be between 1 and last day of month
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 101
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 102
51
6/13/2017
COUNT(*)
----------
0
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 103
12.2
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 104
52
6/13/2017
validate_conversion
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 105
CREATED_DATE
--------------------
01-FEB-2016
12-MAR-2012
54-AUG-2013
09-SEP-2014
23-OCT-2012
...
...
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 106
53
6/13/2017
TO_DATE(C
---------
01-FEB-16
12-MAR-12
09-SEP-14
23-OCT-12
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 107
CAST extended
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 108
54
6/13/2017
SALARY CONV_SAL
---------- ----------
120000 120000
172125 172125
128000 128000
125,000 -1
99500 99500
...
...
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 109
SALARY CONV_SAL
---------- ----------
120000 120000
172125 172125
TO_DATE
128000 128000 TO_NUMBER
125,000 -1
99500 99500 TO_TIMESTAMP
etc
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 110
55
6/13/2017
5
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 111
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 112
56
6/13/2017
SQL> select *
2 from customers
3 where cust_name = 'ADAMS';
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 114
57
6/13/2017
SQL> select *
2 from customers
3 where upper(cust_name) = 'ADAMS';
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 116
58
6/13/2017
COLUMN_NAME
------------------------------
CUST_NAME
-------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
-------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 152 |
|* 1 | TABLE ACCESS FULL| CUSTOMERS | 1 | 152 |
-------------------------------------------------------
Index created.
Index created.
59
6/13/2017
DML slower
more contention
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 119
"not my problem"
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 120
60
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 121
*
ERROR at line 1:
ORA-10631: SHRINK clause should not be specified for this object
61
6/13/2017
12.2
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 123
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 124
62
6/13/2017
? Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 125
Table created.
"case insenstive"
Copyright 2016, Oracle and/or its affiliates. All rights reserved. |
63
6/13/2017
Index created.
-----------------------------------------------------------------
| Id | Operation | Name | Rows |
-----------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 |
| 1 | TABLE ACCESS BY INDEX ROWID BATCHED| CUSTOMERS | 1 |
|* 2 | INDEX RANGE SCAN | CUST_IX | 1 |
-----------------------------------------------------------------
"big deal"
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 128
64
6/13/2017
binary_ci
SQL> select * from customers
2 where cust_name = 'ADAMS';
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 130
65
6/13/2017
binary_ai
SQL> select * from customers
2 where cust_name = 'ADAMS';
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 131
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 132
66
6/13/2017
key point
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 134
67
6/13/2017
*
ERROR at line 1:
ORA-43929: Collation cannot be specified if
parameter MAX_STRING_SIZE=STANDARD
6
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 136
68
6/13/2017
deprecated code
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 137
"huh?"
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 138
69
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 139
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 140
70
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 141
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 142
71
6/13/2017
72
6/13/2017
"wot eva"
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 145
new pragma
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 146
73
6/13/2017
74
6/13/2017
LINE/COL ERROR
-------- -----------------------------------------------------------
1/1 PLW-05018: unit PROCESS_CUSTOMERS omitted optional AUTHID
clause; default value DEFINER used
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 150
75
6/13/2017
"wot eva"
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 151
76
6/13/2017
LINE/COL ERROR
-------- -----------------------------------------------------------
1/1 PLW-05018: unit PROCESS_CUSTOMERS omitted optional AUTHID
clause; default value DEFINER used
7
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 154
77
6/13/2017
external tables
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 155
ext_emp
78
6/13/2017
Table created.
ext_emp
79
6/13/2017
easy fix
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 160
80
6/13/2017
Table created.
it's ddl
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 162
81
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 163
ITIL :-(
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 164
82
6/13/2017
service
call
help
desk DONEproblem
!
record
12.2
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 166
83
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 167
...
13 rows selected.
84
6/13/2017
file names
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 169
...
20 location ('emp20161001.dat'))
Table created.
85
6/13/2017
...
8 rows selected.
86
6/13/2017
8
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 173
ACCOUNTING,KING,PRESIDENT,5000
ACCOUNTING,MILLER,CLERK,1300
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 174
87
6/13/2017
<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>
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 175
{ "NAME" :"ACCOUNTING"
, "EMPLOYEES" : [
{"ENAME" : "KING",
"JOB" : "PRESIDENT",
"SAL" : 5000
},
{"ENAME" : "MILLER",
"JOB" : "CLERK",
"SAL" : 1300
}]
}
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 176
88
6/13/2017
12.1.0.2
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 177
alter table T
add constraint t_chk
check
(
my_doc is JSON
)
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 178
89
6/13/2017
extraction
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 179
ENAME
----------
KING
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 180
90
6/13/2017
dot notation
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 181
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 182
91
6/13/2017
12.2
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 183
generation
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 184
92
6/13/2017
{
"department": "Accounting",
"employees": [
{
"name": "Shelley,Higgins",
"job": "Accounting Manager"
},
{
"name": "William,Gietz",
"job": "Public Accountant"
}
]
}
{"newJSONfunctions": [
"json_array",
"json_object",
"json_arrayagg",
"json_objectagg"
] }
93
6/13/2017
SQL> select
2 json_array(department_id, department_name) depts
3 from hr.departments
4 where department_id > 200;
DEPTS
--------------------------------------------------------
[210,"IT Support"]
[220,"NOC"]
[230,"IT Helpdesk"]
[240,"Government Sales"]
[250,"Retail Sales"]
[260,"Recruiting"]
[270,"Payroll"]
7 rows selected.
SQL> select
2 json_object(
3 'DeptID' is department_id,
4 'Name' is department_name) depts
5 from hr.departments
6 where department_id > 200;
DEPTS
------------------------------------------------
{"DeptID":210,"Name":"IT Support"}
{"DeptID":220,"Name":"NOC"}
{"DeptID":230,"Name":"IT Helpdesk"}
{"DeptID":240,"Name":"Government Sales"}
{"DeptID":250,"Name":"Retail Sales"}
{"DeptID":260,"Name":"Recruiting"}
{"DeptID":270,"Name":"Payroll"}
7 rows selected.
Copyright 2016, Oracle and/or its affiliates. All rights reserved. |
94
6/13/2017
Materialized Views
Search index
... and more JSON goodies
GeoJSON
In-Memory support
JSON Data Guide
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 190
95
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 191
JSON_DATAGUIDE(O.ORDER_DETAILS)
----------------------------------------------------------------------
[ {"o:path": "$.date", "type": "string", "o:length": 32 },
{"o:path": "$.order", "type": "array", "o:length": 256 },
{"o:path": "$.location", "type": "object", "o:length": 32},
{"o:path": "$.location.city", "type": "string", "o:length": 8},
...
...
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 192
96
6/13/2017
9
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 193
analytic views
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 194
97
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 195
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 196
98
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 197
...
...
19 profit number(10,2),
...
...
32 );
Table created.
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 198
99
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 199
sounds easy
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 200
100
6/13/2017
TOTAL
------------
24274312.17
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 201
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 202
101
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 203
BI tools / metadata
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 204
102
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 205
TOTAL
------------
24274312.17
huh?
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 206
103
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 207
data profit
SQL
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 208
104
6/13/2017
data profit
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 209
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 210
105
6/13/2017
profit 2.0
data profit
profit 3.0
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 211
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 212
106
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 213
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 214
107
6/13/2017
1+1=3
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 215
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 216
108
6/13/2017
"SQL is easy"
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 217
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 218
109
6/13/2017
select ...
WITH
from details
my_fact_table
as ( f,
dim_region dr,
dim_customer dc,
dim_gender dg,
dim_locality dl,
dim_cal_year dyc,
)
dim_fiscal_year
,pct_dist as ( dyf
where select
...
from
...
my_fact_table f,
dim_region dr,
dim_customer dc,
dim_gender dg
where ...
)
,pct_region as ( first_value(blah ignore nulls )
select ...
from my_fact_table f,
within_group (
dim_region dr, partition by blah
dim_customer dc,
dim_gender dg order by x nulls first )
where ...
)
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 219
why ?
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 220
110
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 221
complex BI layers
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 222
111
6/13/2017
12.2
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 223
analytic views
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 224
112
6/13/2017
aggregations
cross-row calculations
classifications
in the database
hierarchies distributions
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 225
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 226
113
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 227
select
time_hierarchy.member_name as time,
product_hierarchy.member_name as product,
geo_hierarchy.member_name as geo,
sales,
sales_year_ago,
sales_chg_year_ago,
sales_pctchg_year_ago
from
sales_av hierarchies(time_hierarchy, product_hierarchy, geo_hierarchy)
where
time_hierarchy.level_name = 'YEAR'
and product_hierarchy.level_name = 'CATEGORY'
and geo_hierarchy.level_name = 'REGION;
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 228
114
6/13/2017
select
time_hierarchy.member_name as time,
product_hierarchy.member_name as product,
geo_hierarchy.member_name as geo,
sales,
sales_year_ago,
sales_chg_year_ago,
sales_pctchg_year_ago
from
sales_av hierarchies(time_hierarchy, product_hierarchy, geo_hierarchy)
where
time_hierarchy.level_name = 'MONTH'
and product_hierarchy.level_name = 'CATEGORY'
and geo_hierarchy.level_name = 'REGION;
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 229
select
time_hierarchy.member_name as time,
product_hierarchy.member_name as product,
geo_hierarchy.member_name as geo,
sales,
sales_year_ago,
sales_chg_year_ago,
sales_pctchg_year_ago
from
sales_av hierarchies(time_hierarchy, product_hierarchy, geo_hierarchy)
where
time_hierarchy.level_name = 'YEAR'
and product_hierarchy.level_name = 'ITEM'
and geo_hierarchy.level_name = 'REGION;
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 230
115
6/13/2017
select
time_hierarchy.member_name as time,
product_hierarchy.member_name as product,
geo_hierarchy.member_name as geo,
sales,
sales_year_ago,
sales_chg_year_ago,
sales_pctchg_year_ago
from
sales_av hierarchies(time_hierarchy, product_hierarchy, geo_hierarchy)
where
time_hierarchy.level_name = 'YEAR'
and product_hierarchy.level_name = 'ITEM'
and geo_hierarchy.level_name = 'REGION;
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 231
huge topic
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 232
116
6/13/2017
livesql.oracle.com
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 233
10
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 234
117
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 235
"huh?"
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 236
118
6/13/2017
background
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 237
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 238
119
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 239
$7,100,000
$8,200,000
$7,700,000
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 240
120
6/13/2017
sometimes ...
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 241
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 242
121
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 243
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 244
122
6/13/2017
CDIST
-------
12
Elapsed: 01:32:17.00
12.1.0.2
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 246
123
6/13/2017
CDIST
-------
12
Elapsed: 00:12:43.00
but ...
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 248
124
6/13/2017
COUNT(*)
----------
1723
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 249
12.2
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 250
125
6/13/2017
Session altered.
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 251
approx_count_distinct_detail
approx_median
more functions
to_approx_...
approx_percentile
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 252
126
6/13/2017
more confidence
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 253
DEPARTMENT MED_SAL
---------- -------------
10 4400
20 6000
30 2765
40 6500
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 254
127
6/13/2017
SQL> select
2 department,
3 approx_median(salary deterministic, 'ERROR_RATE') err
4 from employees
5 group by department
6 order by department;
DEPARTMENT ERR
---------- -------------
10 .002718282
20 .021746255
30 .021746255
40 .002718282
50 .019027973
60 .019027973
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 255
SQL> select
2 department,
3 approx_median(salary, 'CONFIDENCE') conf
4 from employees
5 group by department
6 order by department;
DEPARTMENT CONF
---------- -------------
10 .997281718
20 .999660215
30 .999660215
40 .997281718
50 .999611674
60 .999611674
70 .997281718
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 256
128
6/13/2017
11
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 257
partitioning
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 258
129
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 259
Table created.
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 260
130
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 261
11g
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 262
131
6/13/2017
interval partitioning
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 263
Table created.
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 264
132
6/13/2017
lists
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 265
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 266
133
6/13/2017
Table created.
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 267
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 268
134
6/13/2017
ERROR at line 1:
ORA-14400: inserted partition key does not map to any partition
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 269
12.2
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 270
135
6/13/2017
automatic lists
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 271
Table created.
must still be >=1
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 272
136
6/13/2017
1 row created.
PARTITION_NAME
-------------------------------------------------
FEMALE
MALE
SYS_P661
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 273
existing tables
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 274
137
6/13/2017
Table altered.
Table altered.
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 275
12
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 276
138
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 277
LOBs
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 278
139
6/13/2017
"hold on a minute!"
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 279
1997
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 280
140
6/13/2017
securefile LOBs
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 281
"hold on a minute!"
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 282
141
6/13/2017
2007
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 283
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 284
142
6/13/2017
compression
de-duplication
securefile LOBs are cooler
encryption
write cache
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 285
until ...
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 286
143
6/13/2017
n(databases) > 1
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 287
Table created.
1 row created.
SQL> select *
2 from t;
ID C
---------- --------------------------------------------
1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 288
144
6/13/2017
SQL> select *
2 from t@db11;
ERROR:
ORA-22992: cannot use LOB locators selected from remote tables
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 289
12.2
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 290
145
6/13/2017
SQL> select *
2 from t@db122;
ID C
---------- --------------------------------------------
1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 291
http://docs.oracle.com/database/122/ADLOB/distributed-LOBs.htm
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 292
146
6/13/2017
wrap up
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 293
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 294
147
6/13/2017
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 295
plenty to excite
Copyright 2016, Oracle and/or its affiliates. All rights reserved. | 296
148
6/13/2017
ORA-03113
Connor McDonald
@connor_mc_d
297 Copyright 2016, Oracle and/or its affiliates. All rights reserved. |
149