Vous êtes sur la page 1sur 38

Copyright © 2013 Tech Mahindra. All rights reserved.

1
Oracle 18c Enhancements
 Versions and Enhancements
 SQL New features

Copyright © 2013 Tech Mahindra. All rights reserved. 2


Versions - Highlights

Copyright © 2013 Tech Mahindra. All rights reserved. 3


Versions - highlights

Copyright © 2013 Tech Mahindra. All rights reserved. 4


Introduction
 Oracle Database 18c, is the latest generation of the world’s most popular
database, and may be deployed on-premises and/or in Oracle Cloud running
on general purpose hardware or engineered systems specifically designed for
database workloads such as Oracle Exadata and Oracle Database Appliance

 It provides businesses of all sizes with access to the world’s fastest, most
scalable and reliable database technology for secure and cost-effective
deployment of transactional and analytical workloads in the Cloud, on-
premises and Hybrid Cloud configurations.

Copyright © 2013 Tech Mahindra. All rights reserved. 5


New Features
 Oracle Database 18c adds new functionality and enhancements to features
previously introduced in Oracle Database 12c, including:

– Multitenant Architecture for massive cost savings and agility.


– In-Memory Column Store for massive performance gains for real-time
analytics.
– Native Database Sharding for high availability of massive web applications.

– Many more critical capabilities for enhanced database performance,


availability, security, analytics and application development.

– Oracle Database 18c also features prominently as a core component of


Oracle’s Autonomous Database Cloud.

Copyright © 2013 Tech Mahindra. All rights reserved. 6


Journey to Autonomous Database Cloud
 Over successive database releases, Oracle has introduced innovative
automated features that have helped administrators deliver a superior level of
service to their end users.
 These innovations include:
– Cost-based Optimization. Automatic SQL query optimization, automatic
statistics gathering, automatic query rewrite automatic SQL Plan
management and automatic SQL tuning.

– Performance Tuning and Diagnostics. Automatic memory and resource


management, automatic index and materialized view advisors, Automatic
Database Diagnostic Monitor, Automatic Database Workload capture &
replay and Automatic Workload Repository.

– Data Optimization. Automatic undo management, automatic segment


space management, Automatic Storage Management, Automatic Data
Optimization and automatic columnar cache.

Copyright © 2013 Tech Mahindra. All rights reserved. 7


Journey to Autonomous Database Cloud
 An autonomous database is a cloud database that uses machine learning to
eliminate the human labor associated with database tuning, security, backups,
updates, and other routine management tasks traditionally performed
by databaseadministrators (DBAs).

 Cloud-Scale Operations. Automatic standby management (broker),


Diagnostic Framework, Multitenant Architecture, automatic database clone
refresh and machine learning in Cluster Health Advisor
 In October 2017, Oracle announced the Autonomous Database Cloud, a
range of database services tailored for specific Data Warehousing, OLTP, and
NoSQL workloads.

 By utilizing existing database functionality with machine-learning techniques,


the Autonomous Database Cloud can provide a level of performance and
reliability that manually managed databases struggle to deliver

Copyright © 2013 Tech Mahindra. All rights reserved. 8


Journey to Autonomous Database Cloud
 The Autonomous Database Cloud is specifically designed to provide
customers with a higher level of service at lower cost by automating routine
administrative tasks and eliminating human error through:

– Self-Driving. Users simply define workloads and policies, and database


automation makes them happen.

– Self-Securing. Protection from both external attacks and internal users.


– Self-Repairing. Automated protection from all downtime.
 The Autonomous Database Cloud is built on top of the world’s most widely
proven and sophisticated database: Oracle Database, it runs on the world’s
best database platform: Oracle Exadata, and will be available as pay-as-you-
go services on Oracle Cloud and Exadata Cloud at Customer (for public cloud
and private cloud deployment respectively).

Copyright © 2013 Tech Mahindra. All rights reserved. 9


Key Components of Oracle Autonomous
Database

 The Autonomous Data Warehouse Cloud for Data Warehouse, Data Mart,
Data Science, has been available in Oracle Cloud since March 2018.

Copyright © 2013 Tech Mahindra. All rights reserved. 10


Oracle Database Release 18c New Features
 Application Development

 Availability
 Big Data and Data Warehousing
 Database Overall

 Diagnosability

 Performance
 RAC and Grid

 Security

Copyright © 2013 Tech Mahindra. All rights reserved. 11


Application Development
 APEX

 General
 Graph
 JSON

 PL/SQL

 Spatial
 Text

Copyright © 2013 Tech Mahindra. All rights reserved. 12


APEX
 Application Express 5.1: New and Updated Packaged Applications

 Application Express 5.1: Interactive Grid


 Application Express 5.1: Font APEX Icon Library
 Application Express 5.1: Page Designer Enhancements

 Application Express 5.1: Calendar Enhancements

 Application Express 5.1: Oracle JET Charts

Copyright © 2013 Tech Mahindra. All rights reserved. 13


Private Temporary Tables
 Private temporary tables are temporary database objects that are
automatically dropped at the end of a transaction or a session. A private
temporary table is stored in memory and is visible only to the session that
created it.

 A private temporary table confines the scope of a temporary table to a session


or a transaction, thus providing more flexibility in application coding, leading to
easier code maintenance and a better ready-to-use functionality.

Copyright © 2013 Tech Mahindra. All rights reserved. 14


Copyright © 2013 Tech Mahindra. All rights reserved. 15
SQL Enhancements for JSON(Java Script
Object Notation)
 Multiple SQL enhancements are provided for storing and querying JSON data
in the database.

 You can specify that a given SQL expression returns JSON data, using TREAT
(... AS JSON).

 SQL/JSON query and generation functions can return results as LOB data.
 SQL/JSON generation functions can accept input in a variety of SQL data
types, and they can optionally be required to return well-formed JSON data.

Copyright © 2013 Tech Mahindra. All rights reserved. 16


PL/SQL
 PL/SQL Hierarchical Profiler (DBMS_HPROF) Enhancements
 Starting with Oracle Database 18c, a new DBMS_HPROF procedure creates
necessary tables and structures to collect and analyze raw profiler output as
an alternative to the raw profiler data file.

Copyright © 2013 Tech Mahindra. All rights reserved. 17


Scalable Sequence
 A Sequence can be made Scalable by specifying the clause SCALE in the
create sequence or Alter Sequence statement. This is very much useful when
we want to generate unordered primary or unique keys for data ingestion
workloads having high level of concurrency.

 Scalable sequence significantly reduce the sequence and index block


contention(conflict) and provide better data load scalability compared to the
solution of configuring a very large sequence cache using CACHE clause of
CREATE SEQUENCE or ALTER SEQUENCE statement.

 Scalable sequence improves the performance of concurrent data load


operations especially when the sequence values are used for populating
primary key columns of tables in single Oracle database instances as well as
Oracle RAC databases.

Copyright © 2013 Tech Mahindra. All rights reserved. 18


Example
 Create sequence sqno1 SCALE;

 Select sqno1.nextval from dual;


 NEXTVAL
 1019640000000000000000000001

 Scalable sequence number = 6 digit scalable offset number || normal


sequence number

 101964 : 6 digit scalable offset number


 Remaining digits : normal sequence number

 In 6 digit sequence number: 3 digit instance offset number ||3 digit session
offset number ( 101 964)

Copyright © 2013 Tech Mahindra. All rights reserved. 19


Example
 Select sys_context(‘USERENV’, ‘INSTANCE’), sys_context(‘USERENV’, ‘SID’)
from dual;

 Instance SID

 1 1964

 3 digit instance offset number : instance id % 100 = 100


 : 1 % 100 + 100 = 101

 3 digit session offset number : sessionid % 1000 = 1964%1000


 = 964
– :

Copyright © 2013 Tech Mahindra. All rights reserved. 20


SYNTAX of scalable sequence
 CREATE | ALTER sequence sequence_name
 --------
 SCALE [EXTEND | NOEXTEND] | NOSCALE;
 Create sequence test1 scale maxvalue 10000000;
 Select test1.nextval from dual;

 10234001

set serveroutput on;


declare n number;
begin
select te3.nextval into n from dual;
dbms_output.put_line(n);
end;
/

Copyright © 2013 Tech Mahindra. All rights reserved. 21


JSON(Java Script Object Notation) Format
 Oracle 18c Support JSON format


JSON: JavaScript Object Notation.

JSON is a syntax for storing and exchanging data.

JSON is text, written with JavaScript object notation.

JSON is a lightweight data-interchange format

JSON is "self-describing" and easy to understand

JSON is language independent *
 * JSON uses JavaScript syntax, but the JSON format is text only.
Text can be read and used as a data format by any programming language.

Copyright © 2013 Tech Mahindra. All rights reserved. 22


Why use JSON?
 Since the JSON format is text only, it can easily be sent to and from a server,
and used as a data format by any programming language.

 JavaScript has a built in function to convert a string, written in JSON format,


into native JavaScript objects:

 JSON Syntax

 The JSON syntax is a subset of the JavaScript syntax.

 JSON Syntax Rules


– JSON syntax is derived from JavaScript object notation syntax:
– Data is represented in name/value pair
– Curly braces hold object names and value pairs
– Square brackets hold arrays and values are separated by , (commas)

Copyright © 2013 Tech Mahindra. All rights reserved. 23


JSON Data - A Name and a Value
 JSON data is written as name/value pairs.

 A name/value pair consists of a field name (in double quotes), followed by a


colon, followed by a value:

 Example
 "name“ : "John“
 JSON names require double quotes. JavaScript names don't.

Copyright © 2013 Tech Mahindra. All rights reserved. 24


Exchanging Data
 When exchanging data between a browser and a server, the data can only be text.

 JSON is text, and we can convert any JavaScript object into JSON, and send
JSON to the server.

 We can also convert any JSON received from the server into JavaScript objects.
 This way we can work with the data as JavaScript objects, with no complicated
parsing and translations.

 Sending Data
 If you have data stored in a JavaScript object, you can convert the object into
JSON, and send it to a server:

Copyright © 2013 Tech Mahindra. All rights reserved. 25


Example
 var myJSON = '{"name":"John", "age":31, "city":"New York"}';
var myObj = JSON.parse(myJSON);
document.getElementById("demo").innerHTML = myObj.name;

Copyright © 2013 Tech Mahindra. All rights reserved. 26


Copyright © 2013 Tech Mahindra. All rights reserved. 27
JSON Array
 A JSONArray is an ordered sequence of values.

 Its external text form is a string wrapped in square brackets with commas
separating the values.

 The internal form is an object having get and opt methods for accessing the
values by index, and element methods for adding or replacing values.

 The SQL/JSON function JSON_ARRAY takes as its input one or more SQL
expressions, converts each expression to a JSON value, and returns a JSON
array that contains those JSON values.

Copyright © 2013 Tech Mahindra. All rights reserved. 28


Explanation

Copyright © 2013 Tech Mahindra. All rights reserved. 29


 STRICT
 Specify the STRICT clause to verify that the output of the JSON generation
function is correct JSON. If the check fails, a syntax error is raised.

 WITH UNIQUE KEYS


 Specify WITH UNIQUE KEYS to guarantee that generated JSON objects have
unique keys.

Copyright © 2013 Tech Mahindra. All rights reserved. 30


Example
The following example constructs a JSON array from a JSON object, a JSON
array, a numeric literal, a text literal, and null:

SELECT JSON_ARRAY (
JSON_OBJECT('percentage' VALUE .50),
JSON_ARRAY(1,2,3),
100,
'California',
null
NULL ON NULL
) "JSON Array Example"
FROM DUAL;

JSON Array Example


--------------------------------------------------------------------------------
[{"percentage":0.5},[1,2,3],100,"California",null]

Copyright © 2013 Tech Mahindra. All rights reserved. 31


JSON_OBJECT
 The SQL/JSON function JSON_OBJECT takes as its input one or more
property key-value pairs. It returns a JSON object that contains an object
member for each of those key-value pairs.

 Example 1: Output string appears within quotes, because FORMAT


JSON is not used

 SELECT JSON_OBJECT ('name' value 'Foo') FROM DUAL


 Output: JSON_OBJECT('NAME'VALUE'FOO'FORMATJSON)
 -------------------------------------------------
 {"name":"Foo"}

 Example

 SELECT JSON_OBJECT ('name' value 'Foo', 'Age' value 85) FROM DUAL

Copyright © 2013 Tech Mahindra. All rights reserved. 32


Example 2: No quotes around output string
when FORMAT JSON is used.
 SELECT JSON_OBJECT ('name' value 'Foo' FORMAT JSON ) FROM DUAL

Output:

JSON_OBJECT('NAME'VALUE'FOO'FORMATJSON)
-------------------------------------------------

{"name":Foo}

Copyright © 2013 Tech Mahindra. All rights reserved. 33


Example
SELECT JSON_OBJECT (
'deptno' VALUE d.department_id,
'deptname' VALUE d.department_name
) "Department Objects"
FROM hr.departments d
ORDER BY d.department_id;

SELECT JSON_OBJECT (
'deptno' VALUE d.department_id,
'deptname' VALUE d.department_name
) "Department Objects"
FROM hr.departments d where deptno is 10 STRICT
ORDER BY d.department_id;

Copyright © 2013 Tech Mahindra. All rights reserved. 34


JSON_TABLE
 This example shows how to create and populate table j_purchaseorder
CREATE TABLE j_purchaseorder
(id RAW (16) NOT NULL,
date_loaded TIMESTAMP(6) WITH TIME ZONE,
po_document CLOB CONSTRAINT ensure_json CHECK (po_document IS
JSON));

Copyright © 2013 Tech Mahindra. All rights reserved. 35


Adding data
 INSERT INTO j_purchaseorder
 VALUES (
 SYS_GUID(),
 SYSTIMESTAMP,
 '{"PONumber" : 1600,
 "Reference" : "ABULL-20140421",
 "Requestor" : "Alexis Bull",
 "User" : "ABULL",
 "CostCenter" : "A50",
 "ShippingInstructions" : {"name" : "Alexis Bull",
 "Address": {"street" : "200 Sporting Green",
 "city" : "South San Francisco",
 "state" : "CA",
 "zipCode" : 99236,
 "country" : "United States of America"},
 "Phone" : [{"type" : "Office", "number" : "909-555-7307"},
 {"type" : "Mobile", "number" : "415-555-1234"}]},
 "Special Instructions" : null,
 "AllowPartialShipment" : true,
 "LineItems" : [{"ItemNumber" : 1,
 "Part" : {"Description" : "One Magic Christmas",
 "UnitPrice" : 19.95,
 "UPCCode" : 13131092899},
 "Quantity" : 9.0},
 {"ItemNumber" : 2,
 "Part" : {"Description" : "Lethal Weapon",
 "UnitPrice" : 19.95,
 "UPCCode" : 85391628927},
 "Quantity" : 5.0}]}');

Copyright © 2013 Tech Mahindra. All rights reserved. 36


JSNO_QUERY
SELECT jt.phones
FROM j_purchaseorder,
JSON_TABLE(po_document, '$.ShippingInstructions'
COLUMNS
(phones VARCHAR2(100) FORMAT JSON PATH '$.Phone')) AS jt;

PHONES
-------------------------------------------------------------------------------------

[{"type":"Office","number":"909-555-7307"},{"type":"Mobile","number":"415-555-
1234"}]

Copyright © 2013 Tech Mahindra. All rights reserved. 37


Example
SELECT jt.*
FROM j_purchaseorder,
JSON_TABLE(po_document, '$.ShippingInstructions.Phone[*]'
COLUMNS (row_number FOR ORDINALITY,
phone_type VARCHAR2(10) PATH '$.type',
phone_num VARCHAR2(20) PATH '$.number'))
AS jt;

Copyright © 2013 Tech Mahindra. All rights reserved. 38

Vous aimerez peut-être aussi