Db12c Application Development Odd 2103475 en In
-
Upload
srinivas-chary -
Category
Documents
-
view
215 -
download
0
Transcript of Db12c Application Development Odd 2103475 en In
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 2
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.
Oracle Database 12c Application Development
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 4
Security & Compliance
Big Data
Consolidation
Data Optimization
Application Development
High Availability
In-Memory
Performance & Scalability
Data Warehousing
Plug into the Cloud
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 5
Development in Oracle Database 12c
A rich and powerful development environment
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 6
Agenda
Temporal Databases
SQL
PL/SQL and Edition Based Redefinition
SQL Developer
SQL Translator
Application Express
Java
Application Continuity
XML
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 7
Temporal Validity
Flash Back Data Archive
Flashback Query
Oracle Database 12c and Temporal Data Managing the time dimension
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 8
Temporal Applications
Developing applications that understand history is
complicated
Querying and reporting history data is hard, as
schemas evolve
The result is history is only tracked for a few key
tables
– Often raw fact data is tracked but context is not
– e.g. Sales history is tracked, but not quota rules, or
territories
Modeling time is hard
Employees
Departments
History Kept
No History
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 9
Oracle Database 12c Temporal Support
Transaction Time Temporal
(Flashback Data Archive)
Tracks transactional changes to a
table over its lifetime
Typically used for compliance and
auditing
Enables the users to see the data
as it was at a point in time in the
past
Valid Time Temporal
Enables user to model & query data
for “real world validity”
Typically used for insurance policies,
financial markets, trade data & future
changes
Users can model concepts such as
the “Life time of an insurance policy”
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 10
Flashback Data Archive New features in Oracle Database 12c
Complete Schema Evolution
All table and space management DDL is
supported on Flashback Archive enabled tables
Now compatible with Oracle E-Business Suite
Import of history into flashback
archive enables tables
User Context Tracking
Makes it simpler to determine who made the
change
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 11
Valid Time Temporal
VALID TIME rows are stored in the base table itself
By default, queries see all rows in the table
Querying Data Validity
Changes are written to
timestamp columns on base
table
Valid Time Data read from base table
(filtered using SQL)
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 12
Valid Time Temporal Example
CREATE TABLE customers(
custid NUMBER,
custname VARCHAR2(30),
custaddr1 VARCHAR2(50),
custaddr2 VARCHAR2(50),
custcity VARCHAR2(50),
custstate VARCHAR2(2),
custzip VARCHAR2(20),
start_time TIMESTAMP,
end_time TIMESTAMP,
PERIOD FOR cust_valid_time (start_time, end_time));
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 13
INSERT INTO CUSTOMERS VALUES(1,'Acme Inc.','123 Any
Street','Suite 17','Anytown','AS','99999', TO_TIMESTAMP('01-
JAN-12’) ,NULL);
custid custname custaddr1 custaddr2
custcity custstate custzip start_time end_time
1 Acme Inc 123 Any
Street
Suite 17 Anytown CA 99999 01-JAN-
12
Valid Time Temporal Example
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 14
custid custname custaddr1 custaddr2
custcity custstate custzip start_time end_time
1 Acme Inc 123 Any
Street
Suite 17 Anytown CA 99999 01-JAN-
12
31-May-13
UPDATE customers
SET end_time=TO_TIMESTAMP('31-MAY-13’)
WHERE custid=1;
Valid Time Temporal Example
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 15
INSERT INTO CUSTOMERS VALUES(1,'Acme Inc.',’456 Another
Street', NULL,'Anytown','AS','99998', TO_TIMESTAMP('01-JUN-13’)
,NULL);
custid custname custaddr1 custaddr2
custcity custstate custzi
p
start_time end_time
1 Acme Inc 123 Any
Street
Suite 17 Anytown CA 99999 01-JAN-12 31-May-13
1 Acme Inc 456
Another
Street
Anytown CA 99998 01-JUN-13
Valid Time Temporal Example
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 16
SELECT custaddr1, custaddr2, custcity, custstate, custzip
FROM customers WHERE custid=1;
custid custname custaddr1 custaddr2
custcity custstate custzip start_time end_time
1 Acme Inc 123 Any
Street
Suite 17 Anytown CA 99999 01-JAN-12 31-May-13
1 Acme Inc 456
Another
Street
Anytown CA 99998 01-JUN-13
Valid Time Temporal Example
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 17
EXEC DBMS_FLASHBACK_ARCHIVE.ENABLE_AT_VALID_TIME('CURRENT');
SELECT custid, start_time, end_time
FROM customers WHERE custid=1;
custid custname custaddr1 custaddr2
custcity custstate custzip start_time end_time
1 Acme Inc 123 Any
Street
Suite 17 Anytown CA 99999 01-JAN-12 31-May-13
1 Acme Inc 456
Another
Street
Anytown CA 99998 01-JUN-13
Valid Time Temporal Example
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 18
SELECT custid, start_time, end_time
FROM customers
AS OF PERIOD FOR cust_valid_time TO_TIMESTAMP('03-JUN-13');
custid custname custaddr1 custaddr2
custcity custstate custzip start_time end_time
1 Acme Inc 123 Any
Street
Suite 17 Anytown CA 99999 01-JAN-12 31-May-13
1 Acme Inc 456
Another
Street
Anytown CA 99998 01-JUN-13
Valid Time Temporal Example
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 19
Temporal with Oracle Database 12c Minimizing custom Code
Transaction Time Temporal
(flashback data archive)
maintains history
Valid Time Temporal
maintains business validity
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 20
Pattern Matching
PL/SQL in “With” Clause
Identity Based Columns
Fetch First
Invisible Columns
Improved Left Outer Join Syntax
32k Varchar
A more powerful expressive language
Oracle Database 12c : The Evolution of SQL
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 21
Pattern Matching Simplified Analysis of Big Data
Select * from
Employees MATCH_RECOGNIZE (
…
PATTERN(X+ Z{2})
…
)
Scalable discovery of business event
sequences
– Clickstream logs: sessionization, search
behaviour
– Financial transactions: fraud detection, double
bottom (“W”) stock analysis
– Telco: dropped calls
– Medical sensors: automated medical
observations and detections Patterns are defined
using regular
expressions
Ascendin
g O
rder
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 22
Find double bottom (W) patterns and report:
• Beginning and ending date of the pattern
• Average Price Increase in the second ascent
• Modify the search to find only patterns that lasted less than a week
SQL Pattern Matching Example: Find Double Bottom (W)
PATTERN (X+ Y+ W+ Z+)
DEFINE X AS (price < PREV(price))
days
Stock price
X
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 23
Find double bottom (W) patterns and report:
• Beginning and ending date of the pattern
• Average Price Increase in the second ascent
• Modify the search to find only patterns that lasted less than a week
SQL Pattern Matching Example: Find Double Bottom (W)
PATTERN (X+ Y+ W+ Z+)
DEFINE X AS (price < PREV(price))
Y AS (price > PREV(price))
days
Stock price
X Y
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 24
Find double bottom (W) patterns and report:
• Beginning and ending date of the pattern
• Average Price Increase in the second ascent
• Modify the search to find only patterns that lasted less than a week
SQL Pattern Matching Example: Find Double Bottom (W)
days
Stock price
SELECT first_x, last_z
FROM ticker MATCH_RECOGNIZE (
PARTITION BY name ORDER BY time
MEASURES FIRST(x.time) AS first_x
LAST(z.time) AS last_z
ONE ROW PER MATCH
PATTERN (X+ Y+ W+ Z+)
DEFINE X AS (price < PREV(price))
Y AS (price > PREV(price))
W AS (price < PREV(price))
Z AS (price > PREV(price))
X Y W Z
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 25
SQL Pattern Matching
1 9 13 19 days
Stock price
SELECT first_x, last_z
FROM ticker MATCH_RECOGNIZE (
PARTITION BY name ORDER BY time
MEASURES FIRST(x.time) AS first_x,
LAST(z.time) AS last_z
ONE ROW PER MATCH
PATTERN (X+ Y+ W+ Z+)
DEFINE X AS (price < PREV(price)),
Y AS (price > PREV(price)),
W AS (price < PREV(price)),
Z AS (price > PREV(price)))
First_x Last_z
1 9
13 19 Example: Find Double Bottom (W)
Find double bottom (W) patterns and report:
• Beginning and ending date of the pattern
• Average Price Increase in the second ascent
• Modify the search to find only patterns that lasted less than a week
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 26
if (lineNext == null) {
next = "";
} else {
next = lineNext.getQuantity();
}
if (!q.isEmpty() && (prev.isEmpty() || (eq(q, prev) && gt(q, next)))) {
state = "S";
return state;
}
if (gt(q, prev) && gt(q, next)) {
state = "T";
return state;
}
if (lt(q, prev) && lt(q, next)) {
state = "B";
return state;
}
if (!q.isEmpty() && (next.isEmpty() || (gt(q, prev) && eq(q, next)))) {
state = "E";
return state;
}
if (q.isEmpty() || eq(q, prev)) {
state = "F";
return state;
}
return state;
}
private boolean eq(String a, String b) {
if (a.isEmpty() || b.isEmpty()) {
return false;
}
return a.equals(b);
}
private boolean gt(String a, String b) {
if (a.isEmpty() || b.isEmpty()) {
return false;
}
return Double.parseDouble(a) > Double.parseDouble(b);
}
private boolean lt(String a, String b) {
if (a.isEmpty() || b.isEmpty()) {
return false;
}
return Double.parseDouble(a) < Double.parseDouble(b);
}
public String getState() {
return this.state;
}
}
BagFactory bagFactory = BagFactory.getInstance();
@Override
public Tuple exec(Tuple input) throws IOException {
long c = 0;
String line = "";
String pbkey = "";
V0Line nextLine;
V0Line thisLine;
V0Line processLine;
V0Line evalLine = null;
V0Line prevLine;
boolean noMoreValues = false;
String matchList = "";
ArrayList<V0Line> lineFifo = new ArrayList<V0Line>();
boolean finished = false;
DataBag output = bagFactory.newDefaultBag();
if (input == null) {
return null;
}
if (input.size() == 0) {
return null;
}
Pattern Matching Finding Double Bottom (W)
SELECT first_x, last_z
FROM ticker MATCH_RECOGNIZE (
PARTITION BY name ORDER BY time
MEASURES FIRST(x.time) AS first_x,
LAST(z.time) AS last_z
ONE ROW PER MATCH
PATTERN (X+ Y+ W+ Z+)
DEFINE X AS (price < PREV(price)),
Y AS (price > PREV(price)),
W AS (price < PREV(price)),
Z AS (price > PREV(price) AND
z.time - FIRST(x.time) <= 7 ))
250+ Lines of Java and PIG 12 Lines of SQL
20x less code, 5x faster
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 27
New SQL Functionality
PL/SQL in SQL via the “with” clause
– Useful for read only databases
– Potentially faster for some operations
IDENTITY based columns
– Auto incrementing columns
– Supports ANSI standard
Increased size for VARCHAR2
– Increase from 4000 to 32K
New Row limiting clause
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 28
PL/SQL in SQL Example
WITH
FUNCTION get_domain(url VARCHAR2) RETURN VARCHAR2 IS
pos BINARY_INTEGER;
len BINARY_INTEGER;
BEGIN
pos := INSTR(url, 'www.');
len := INSTR(SUBSTR(url, pos + 4), '.') - 1;
RETURN SUBSTR(url, pos + 4, len);
END;
SELECT
DISTINCT get_domain(catalog_url)
FROM
orders;
PL/SQL Function embedded in “with” clause
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 29
IDENTITY Example
CREATE TABLE t1
(id NUMBER GENERATED AS IDENTITY,
first_name varchar2(30)
);
CREATE TABLE t2
(id NUMBER GENERATED BY DEFAULT AS IDENTITY
(START WITH 100 INCREMENT BY 10),
first_name varchar2(30)
);
Create a table where the id column is always populated by Oracle
Create a table where the id column is populated by Oracle when not provided
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 30
32K VARCHAR2/NVARCHAR2 Example
ALTER SYSTEM set MAX_STRING_SIZE = EXTENDED scope = SPFILE
CREATE TABLE Applicants
(id NUMBER GENERATED AS IDENTITY,
first_name varchar2(30),
last_name varchar2(30),
application date,
CV varchar2(32767)
);
Enable 32k support in the Oracle Database 12c
Create table with 32k varchar2
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 31
Row Limit Example
SELECT employee_id, last_name
FROM employees
ORDER BY employee_id
FETCH FIRST 5 ROWS ONLY;
SELECT employee_id, last_name, salary
FROM employees
ORDER BY salary
FETCH FIRST 5 PERCENT ROWS WITH TIES;
Select only the first 5 rows
Select the first 5% of rows and those whose salary “ties” with the lowest of the 5%
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 32
Invokers Rights Functions Caching
Objects, Not Types, Are Editioned
More Types To Cross SQL/PLSQL
Implicit Statement Results
Database Triggers on PDBs
A Portable high performance transaction language
PL/SQL and Edition Based Redefintion
BEGIN
…
END;
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 33
Now there’s no reason to avoid database PL/SQL
Fifty-year-old wisdom says:
– “expose the database to client-side code as a PL/SQL API and
securely hide the implementation details — the names and structures of
the tables, and the SQL statements that manipulate them — from the
client.
Yet a very large number of customers refuse to do this
Excuses:
– Patching database PL/SQL causes unacceptable downtime
– Can’t pass index-by table of records to/from the client
– Can’t provision a private sandbox database for each developer
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 34
These changes demolish the objections
EBR adoption barrier vanishes
– Editioned state now per object, not per schema
– Materialized views, indexes, and virtual columns can now use PL/SQL
functions (new metadata specifies the edition for name resolution)
PL/SQL
– Row sets can now be passed between the client and the database index-
by-PL/SQL-tables of records
The multitenant architecture
– PDBs can be rapidly and thinly created, and then dropped, using SQL
– Easy to write an app to let a developer self-provision his sandbox database
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 35
Support for Oracle Database 12c
SQL Translation Framework
Data Redaction Support
APEX Administration
Cloud Database Support
Manage Pluggable Databases
Simplifying development and management in the Oracle Database
Oracle SQL Developer
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 36
Oracle Database 12c: Pluggable Databases SQL Developer Release 3.2
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 37
Oracle Database 12c: Pluggable Databases
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 38
Oracle Data Redaction Example: Partial
Before
After
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 39
JQuery Support
Mobile Application Support
HTML 5 Charts
Packaged Apps
Oracle Database 12c Support
Oracle Application Express 4.2
Centralized database development for transaction centric applications
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 40
APEX Gant Chant
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 41
Survey Builder Packaged Application
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 42
.NET and Oracle Database 12c
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 43
.NET and Oracle Database 12c
Transaction Guard and Global Data Services
Managed ODP.NET
Visual Studio Application Lifecycle Management – PDBs
View, clone, plug, unplug PDBs from Visual Studio
Share PDBs with other developers
– Schema Compare View differences between schemas
Generate diff scripts to source control
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 44
JDBC 4.1 support
Choice of Java6 or Java7
Support for Oracle 12c Features
Support for DRCP
Application Continuity
Java in Oracle Database 12c
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 45
Oracle Database 12c for Java
Java Standards Support
– JDBC & UCP Support for JavaSE 7 and JDBC 4.1
– Java in the database goes JavaSE 6 & 7; pick at db creation time.
– Java in the database got JNDI, Java Logging
Support for New Database Type and New SQL Types
– JDBC Support for Pluggable databases through Service Names
– 32K VARCHAR, NVARCHAR, and RAW
– Invisible or Hidden Columns, Implicit Result Set
– Auto-Increment Columns (IDENTITY columns)
– PL/SQL Package Types as Parameter
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 46
Oracle Database 12c for Java
Performance & Scalability
– Large Scale Java deployment with DRCP
– Very Large Network Buffers (SDU)
– Support for Monitoring of Database Operations
High Availability
– Reliable Outcome of In-Flight Work (at Most Once Commit) with Transaction Guard
– Masking Database Outage and Resubmission of In-Flight Work with Application
Continuity
– Load-Balancing and Failover across Geographies (Worldwide) with Global Data
Service
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 47
When is Application Continuity for Java transparent
If the Application
– Uses J2EE or JPA that uses the standard JDBC API
– Uses UCP or WebLogic Server and return connections to
pool
– Does not have external actions that cannot be replayed.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 48
XQuery Update
Support for XQuery-FullText
XQuery Performance Improvements
XML in Oracle Database 12c
<?XML?>
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 49 49
Advanced XML Capabilities
Flexible XML Indexing
Optimized storage for schema-based and schema-less XML
Native XQuery Engine
Document and Data Centric Access
Document or Message
JDBC
HTTP
FTP
WebDav
XMLType
XML Schema
XQuery
SQL/XML
XSLT
DOM
Folders
ACLS
Versioning
.NET
XML Application
XDK
SOAP
OCI
Files
Metadata
Events
Metadata
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 50
Oracle XML DB in Oracle Database 12c
Support for XQuery-Update
– Standards based update operations on XML Content
Support for XQuery-Fulltext
– Standard based, XML aware full-text searching. Support for document,
fragment and leaf-level searching
Indexing enhancements to support XQuery-Fulltext implementation
Significant performance enhancements for XQuery processing
Optimizations for offloading parsing and serialization
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 51
In Database Archiving
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 52
In-Database Archiving
Applications typically work with recent data
– But often need to retain data for 5 to 10 years
Can potentially improve upgrade times as only data that is active is
modified
In-DB Archiving provides the ability to archive infrequently used data
within the database
– Archived Data is invisible by default
Archived data remains online for historical analysis
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 53
In-Database Archiving
Enable In-Database Archiving on the Sales Table
ALTER TABLE SALES ROW ARCHIVAL;
UPDATE SALES set ORA_ARCHIVE_STATE = 1;
Archive the rows with a non zero value (null, -1, 1 etc.)
ALTER SESSION SET ROW ARCHIVAL VISIBILITY = ALL;
Modify your session to see all rows including archived versions
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 54
Oracle Application Development Summary
Oracle provides a rich development experience with support for a wide
range of languages and approaches
Oracle Database 12c continues to improve on the developer’s
experience by providing improved tools and APIs
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 55
The preceding 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 © 2013, Oracle and/or its affiliates. All rights reserved. 56
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 57