oracle database 12c - apexsolutions.cz · oracle database 12c novinky v pl/sql letem světem patrik...

34

Upload: others

Post on 22-Mar-2020

33 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Oracle Database 12c - apexsolutions.cz · Oracle Database 12c Novinky v PL/SQL letem světem Patrik Plachý Senior Consultant CEE Technology Cluster November 02, 2016
Page 2: Oracle Database 12c - apexsolutions.cz · Oracle Database 12c Novinky v PL/SQL letem světem Patrik Plachý Senior Consultant CEE Technology Cluster November 02, 2016
Page 3: Oracle Database 12c - apexsolutions.cz · Oracle Database 12c Novinky v PL/SQL letem světem Patrik Plachý Senior Consultant CEE Technology Cluster November 02, 2016

Oracle Database 12c Novinky v PL/SQL letem světem

Patrik Plachý Senior Consultant CEE Technology Cluster November 02, 2016

Page 4: Oracle Database 12c - apexsolutions.cz · 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.

Page 5: Oracle Database 12c - apexsolutions.cz · 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. |

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

Page 6: Oracle Database 12c - apexsolutions.cz · 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. |

Developers

Page 7: Oracle Database 12c - apexsolutions.cz · 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. |

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), . . . …

Page 8: Oracle Database 12c - apexsolutions.cz · 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. |

More 12.2 SQL innovations

• Enhanced LISTAGG

• Band joins

• Real-time materialized views

• PL/SQL Improvements

Page 9: Oracle Database 12c - apexsolutions.cz · 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. |

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”);

Page 10: Oracle Database 12c - apexsolutions.cz · 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. |

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

Page 11: Oracle Database 12c - apexsolutions.cz · 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. |

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

Page 12: Oracle Database 12c - apexsolutions.cz · 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. |

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

Page 13: Oracle Database 12c - apexsolutions.cz · 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. |

PL/SQL

Page 14: Oracle Database 12c - apexsolutions.cz · 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. |

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

Page 15: Oracle Database 12c - apexsolutions.cz · 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. |

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;

Page 16: Oracle Database 12c - apexsolutions.cz · 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. |

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

Page 17: Oracle Database 12c - apexsolutions.cz · 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. |

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;

Page 18: Oracle Database 12c - apexsolutions.cz · 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. |

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

Page 19: Oracle Database 12c - apexsolutions.cz · 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. |

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

Page 20: Oracle Database 12c - apexsolutions.cz · 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. |

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

Page 21: Oracle Database 12c - apexsolutions.cz · 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. |

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

Page 22: Oracle Database 12c - apexsolutions.cz · 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. |

Example: binding an IBPI to a PL/SQL function in SQL

Page 23: Oracle Database 12c - apexsolutions.cz · 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. |

Example: binding to the operand of the table operator

Page 24: Oracle Database 12c - apexsolutions.cz · 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. |

Example: binding an IBPI to an anonymous block

Page 25: Oracle Database 12c - apexsolutions.cz · 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. |

Example: binding a boolean to an anonymous block

Page 26: Oracle Database 12c - apexsolutions.cz · 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. |

accessible by clause

Page 27: Oracle Database 12c - apexsolutions.cz · 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. |

Improved call stack introspection

Page 28: Oracle Database 12c - apexsolutions.cz · 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. |

Pre 12.1 Print_Call_Stack()

Page 29: Oracle Database 12c - apexsolutions.cz · 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. |

12.1 Print_Call_Stack()

Page 30: Oracle Database 12c - apexsolutions.cz · 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. |

PL/SQL play with Oracle Database 12c

https://blogs.oracle.com/dbcz/entry/play_with_oracle_database_12c

Page 31: Oracle Database 12c - apexsolutions.cz · 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. |

Practically Perfect PL/SQL with Steven Feuerstein

https://www.youtube.com/channel/UCpJpLMRm452kVcie3RpINPw/feed?view_as=public

Page 32: Oracle Database 12c - apexsolutions.cz · Oracle Database 12c Novinky v PL/SQL letem světem Patrik Plachý Senior Consultant CEE Technology Cluster November 02, 2016

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 32

Page 33: Oracle Database 12c - apexsolutions.cz · 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. | 33

Page 34: Oracle Database 12c - apexsolutions.cz · Oracle Database 12c Novinky v PL/SQL letem světem Patrik Plachý Senior Consultant CEE Technology Cluster November 02, 2016