oracle database 12c - apexsolutions.cz · oracle database 12c novinky v pl/sql letem světem patrik...
Post on 22-Mar-2020
37 Views
Preview:
TRANSCRIPT
Oracle Database 12c Novinky v PL/SQL letem světem
Patrik Plachý Senior Consultant CEE Technology Cluster November 02, 2016
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Oracle Database 12c Continuous Innovation
Cloud Internet Client-Server
1990s 2000s 2010s
Oracle 5, 6, 7, 8 Oracle 8i, 9i, 10g Oracle 11g, 12c
Scalability Row Level Locking, B-tree
Indexes, Read Consistency,
Parallel Server, Shared Cursors,
Shared Server
Real Application Clusters,
Automatic Storage Management, IOTs
Advanced Compression, Bitmap Indexes
Exadata, Smart Flash, In-Memory DB,
Software-in-Silicon,
Native Database Sharding
Availability Transactions, Ref Integrity, Online
Backup, Point-in-Time Recovery
Data Guard (Active), Recovery Manager,
Flashback, Clusterware, Online DDL, TAF
Zero Data Loss Recovery Appliance,
Edition Based Redefinition, App. Cont.
Analytics Partitions, Parallel SQL, Optimizer Analytic Function, Data Mining, OLAP, MVs SQL Pattern Match, R, Big Data Appl
Security Privileges, Roles, Auditing,
Network Encryption, Views
Data Encrypt, Masking, Virtual Private DB,
Label Security, DB Vault, Audit Vault, PKI
Real Application Security, DB Firewall,
Privilege Analysis, Redaction, Key Vault
Developers SQL, Views, PL/SQL, Triggers,
LOBs, Object Types, Spatial, Text
Java in DB, Native XML, Table Functions,
.Net, PHP, App Express, SQL Developer
Native JSON, REST Services, Node.js,
RDF Social Graph, Network Graph
Management Enterprise Manager, v$, wait event Diagnostics, Tuning, Testing, Lifecycle Packs MultiTenant, DB & Exa Cloud, DB Appl
Integration DB Links, 2PC, Replication, AQ GoldenGate, XA Transaction,External Table Big Data SQL, Big Data Analytics
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Developers
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Case insensitive database support
• Collation can be declared on a schema, table or column level
• Accent-insensitive is also supported
Long Identifiers
• Object Names for tables, columns etc. can now be 128 bytes in length
• Allows for more expressive naming of objects
Globalization Support
• AL32UTF8 is the default database character set
• Unicode 7.0 support
Core Database Improvements
CREATE TABLE Sales_Data_For_Online_Transactions (Transaction_Identifier NUMBER(6), Date_Of_Sales_Transaction DATE, Gross_Value_of_Transaction NUMBER(3,2), . . . …
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
More 12.2 SQL innovations
• Enhanced LISTAGG
• Band joins
• Real-time materialized views
• PL/SQL Improvements
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Oracle Database 12c as a Document Store 12.2 JSON DataGuide – Automatic Schema Inference
SQL> desc MOVIE_TICKETS
NAME TYPE
--------------------- -----------
BOOKING_ID RAW(16)
BOOKING_TIME TIMESTAMP(6)
BOOKING_DETAILS VARCHAR2(4000)
Table containing JSON documents
JSON DataGuide Table enhanced with virtual columns
SQL> desc MOVIE_TICKETS
NAME TYPE
--------------------- -----------
BOOKING_ID RAW(16)
BOOKING_TIME TIMESTAMP(6)
BOOKING_DETAILS VARCHAR2(4000)
BOOKING_DETAILS$Movie VARCHAR2(16)
BOOKING_DETAILS$Theater VARCHAR2(16)
BOOKING_DETAILS$Adults NUMBER
BOOKING_DETAILS$Time VARCHAR2(32) {
"Theater":"AMC 15",
"Movie":"Jurrasic World 3D",
"Time“:2015-11-26T18:45:00",
"Tickets":{
"Adults":2
}
}
DBMS_JSON.AddVC( “MOVIE_TICKETS”, “BOOKING_DETAILS”);
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Oracle SODA Simple Oracle Document Access
• JSON Document APIs for REST and Java • Leverages native 12.2 database JSON features •Allows developers to combine the ease of use of
document development and relational • SQL analytics can be used on JSON documents
• Full PL/SQL API
JSON
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
New Oracle .NET Support
• Oracle Public Cloud
– .NET Compute
– Visual Studio deployment tools for Oracle Public Cloud
• Application Continuity for unplanned database outages
• Sharding
• Database Resident Connection Pooling
• Offline Schema Compare in Visual Studio
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
LiveSQL.oracle.com – Free
• SQL scratch pad in the Oracle Cloud
• Free service launched Oct 2015 @ OOW
•Google searchable SQL syntax
• Customers can save and share SQL examples
• Planned integration w/ Oracle documentation
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
PL/SQL
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Performance improvement for PL/SQL functions called from SQL
• Example: pretty-print an integer
select PK, Print(n1) "n1", Print(n2) "n2", Print(n3) "n3" from t
1 1 K 1 G 566 G
2 1 K 157 M 416 G
3 2 K 1 G 971 G
4 578 byte 1 G 1 T
5 2 K 1 G 220 G
6 1 K 2 G 1 T
7 48 byte 1 G 2 T
8 992 byte 42 M 3 T
9 794 byte 2 G 1 T
10 2 K 302 M 672 G
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
The “algorithm”
• Pretty-print an integer as a multiple of an appropriate power of 1024: plain, K, M, B, or T
function Print(n in integer) return varchar2 authid Definer is
K constant number not null := 1024;
M constant number not null := K*K;
G constant number not null := M*K;
T constant number not null := G*K;
begin
return
case
when n <= K-1 then To_Char(n, '999999')||'byte'
when n/K <= K-1 then To_Char(n/K, '999999')||'K'
when n/M <= K-1 then To_Char(n/M, '999999')||'M'
when n/G <= K-1 then To_Char(n/G, '999999')||'G'
else To_Char(n/T, '999999')||'T'
end;
end Print;
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Try it in pure SQL! select PK,
case
when n1 <= 1023 then To_Char(n1, '999999')||' byte'
when n1/1024 <= 1023 then To_Char(n1/1024, '999999')||' K'
when n1/1048576 <= 1023 then To_Char(n1/1048576, '999999')||' M'
when n1/1073741824 <= 1023 then To_Char(n1/1073741824, '999999')||' G'
else To_Char(n1/1099511627776, '999999')||' T'
end
"n1",
case
when n2 <= 1023 then To_Char(n2, '999999')||' byte'
when n2/1024 <= 1023 then To_Char(n2/1024, '999999')||' K'
when n2/1048576 <= 1023 then To_Char(n2/1048576, '999999')||' M'
when n2/1073741824 <= 1023 then To_Char(n2/1073741824, '999999')||' G'
else To_Char(n2/1099511627776, '999999')||' T'
end
"n2",
case
when n3 <= 1023 then To_Char(n3, '999999')||' byte'
when n3/1024 <= 1023 then To_Char(n3/1024, '999999')||' K'
when n3/1048576 <= 1023 then To_Char(n3/1048576, '999999')||' M'
when n3/1073741824 <= 1023 then To_Char(n3/1073741824, '999999')||' G'
else To_Char(n3/1099511627776, '999999')||' T'
end
"n3"
from t
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Get the performance of SQL with the clarity and reusability of PL/SQL
function Print(n in integer) return varchar2 authid Definer is
pragma UDF;
K constant number not null := 1024;
M constant number not null := K*K;
G constant number not null := M*K;
T constant number not null := G*K;
begin
return
case
when n <= K-1 then To_Char(n, '999999')||'byte'
when n/K <= K-1 then To_Char(n/K, '999999')||'K'
when n/M <= K-1 then To_Char(n/M, '999999')||'M'
when n/G <= K-1 then To_Char(n/G, '999999')||'G'
else To_Char(n/T, '999999')||'T'
end;
end Print;
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Declare the PL/SQL function in the subquery’s with clause with
function Print(n in integer) return varchar2 is
K constant number not null := 1024;
M constant number not null := K*K;
G constant number not null := M*K;
T constant number not null := G*K;
begin
return
case
when n <= K-1 then To_Char(n, '999999')||' byte'
when n/K <= K-1 then To_Char(n/K, '999999')||' K'
when n/M <= K-1 then To_Char(n/M, '999999')||' M'
when n/G <= K-1 then To_Char(n/G, '999999')||' G'
else To_Char(n/T, '999999')||' T'
end;
end Print;
select PK,Print(n1) "n1",Print(n2) "n2",Print(n3) "n3" from t
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Performance comparison
• Pure SQL 5.0x is fastest
• Schema-level function with pragma UDF 3.9x is close
• Function in the with clause 3.8x is similar
• Pre-12.1 ordinary schema-level function 1.0 – the baseline is very much the slowest
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Binding values of PL/SQL-only datatypes into SQL statements
• Before 12.1, you could bind only values of SQL datatypes
• In 12.1, you can bind PL/SQL index-by-pls_integer tables (of records) and booleans – from client-side programs – OCI or both flavors of JDBC – and
from PL/SQL –to anonymous blocks, statements using functions, or statements
using the table operator
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Binding a PL/SQL index-by table to SQL
• Before 12.1, you could invoke a function with a collection actual, or select from a collection, but – The type had to be defined at schema-level – Therefore it had to be a nested table or a varray – A non-scalar payload had to be an ADT
• New in 12.1 – The type can be defined in a package spec – can be index by
pls_integer table – The payload can be a record – but the fields must still be SQL
datatypes
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Example: binding an IBPI to a PL/SQL function in SQL
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Example: binding to the operand of the table operator
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Example: binding an IBPI to an anonymous block
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Example: binding a boolean to an anonymous block
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
accessible by clause
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Improved call stack introspection
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Pre 12.1 Print_Call_Stack()
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
12.1 Print_Call_Stack()
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
PL/SQL play with Oracle Database 12c
https://blogs.oracle.com/dbcz/entry/play_with_oracle_database_12c
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Practically Perfect PL/SQL with Steven Feuerstein
https://www.youtube.com/channel/UCpJpLMRm452kVcie3RpINPw/feed?view_as=public
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 32
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 33
top related