<Secret Code>
TOM KYTE TO THE RESCUE
THE DATABASE
IN MODERN ARCHITECTURES
A. Correct Answer
B. Sometimes correct
C. Correct if there are never duplicate
salaries
D. Not Correct
IN-LINE VIEWS
TOP-N QUERIES IN 12C
select *
from emp
order
by sal desc
OFFSET 3 FETCH NEXT 4 ROWS ONLY;
TOP-N% QUERYING
or:
select *
from ( select *
from emp
order
by sal asc
FETCH FIRST 3 ROWS ONLY
)
order by sal desc;
IN-LINE PL/SQL FUNCTIONS AND
PROCEDURES
Procedures are also allowed in-line
In-Line Functions and Procedures can invoke
each other
WITH
procedure increment( operand in out number
, incsize in number)
is
begin
operand:= operand + incsize;
end;
FUNCTION inc(value number) RETURN number IS
l_value number(10):= value;
BEGIN
increment(l_value, 100);
RETURN l_value;
end;
SELECT inc(sal)
from emp
SPECIAL BUSINESS RULE: DEFAULT
VALUE
The default values is the value that should be
inserted for a column when the client has
ignored the column
not provided a value nor indicated NULL
The default value is applied prior to the
execution of the Before Row trigger
So :new.<column_value> has the value that will
be inserted
The Before Row trigger has no built in way to
telling whether the value was provided by the
client or supplied as default by the database
Default value is typically used for auditing
purposes
Note: default values for columns exposed in UI
should be set in the client
COLUMN DEFAULT
Application Context
EBR TO KILL PLANNED DOWNTIME
(BECAUSE OF APPLICATION UPGRADE)
Applicatio
Application X nX
VERSION 1 VERSION
2
ase elease 2
Base Rele R Release 3
TIME TRAVELLING
FLASHBACK
Introduced in 9i
Based on UNDO
Initially only for recovery
As of 11g Total Recall option with
Flashback Data Archive
Controlled history keeping
Look back into history
Query trends (version history)
Difference reporting
Audit trails (Replace journaling tables)
Require trick for transaction history: WHO?
Also: when is the start of history?
OOW 2012 SESSION COMES TO THE
RESCUE
CON8511 - Temporal Database Capabilities
with the Latest Generation of Database
Technology
TOTAL RECALL - FLASHBACK DATA
ARCHIVE IMPROVEMENTS
Complete schema evolution support: all table
definition, partitioning, and space
management DDLs are supported on FDA-
enabled tables.
The metadata information for tracking
transactions including the user context is
now tracked.
This could mean that journaling tables are now
officially deprecated
And the current contents of journaling tables can
even be migrated to Flashback Data Archive
Introduction of SQL 2011 Valid Time Temporal
Modeling
TOTAL RECALL
Services
Standard
Application
Database s
Database Legacy
Application
s
MULTI TIER ARCHITECTURE
Mobile WS
Services DB QRCN
HTTP
JMX, JMX
Monitor,
Trace, Audit Stored Encapsulation
Database Procedures Decoupling
Authentication & Caching
Fine Grained SQL Business Logic
Authorization
APPLICATION ARCHITECTURE:
DRIVE APPLICATION FROM META DATA
Agility
Design Time at Run Time
Define part of the application behavior and
appearance through meta-data (outside the
base source code)
The default settings are defined by developers
and deployed along with the application
Read and interpreted at run time
Manipulated and re-read
Application
and re-interpreted at run time
Note: very similar to the way
the database operates:
Data Dictionary is the
meta-data driving the meta
behavior of the database
SEPARATE
BASE DATA AND CUSTOMIZED DATA
If a value is changed during site-level
implementation
Or run time customization
It should be kept apart from the base meta-
data
To prevent overwriting customized data when
the new release arrives
To allow for (temporarily) reverting to base data
A simple solution: the Complex View with two
underlying tables approach
Note: Select ORIGINAL_NAME
For Update Of IO trg
is not allowed Customized
Values
New release BaseValues
REPLACE THE ORIGINAL SINGLE TABLE
WITH A TWO-TABLE BASE/CUSTOM SPLIT
rename <original> to <base>
create table <customizations>
as
select * from base where rownum = 0
create or replace view <original>
as
select * from <customizations>
union all
select * from <base> b
left outer join
<customizations> c
on (b.id = c.id)
where c.rowid is null
REPLACE THE ORIGINAL SINGLE TABLE WITH A
TWO-TABLE BASE/CUSTOM SPLIT (2)
New release of
Oracle Database ROOT
PDB
APPLICATION ARCHITECTURE: NO
SQL
NO SQL
Complex SQL is
hidden away inside
the database
Cache to not have Web Browser
to query all the time
from the database
and to not take
the overhead of a
commit for not so
JEE Application Server
important data NO SQL
Process first in
memory, on
middle tier
(BigData and CEP) -
and only persist
what is useful
RDBMS
SQL
QUERY RESULT CHANGE
NOTIFICATION
Continuous Query Notification:
Send an event when the result set for a query
changes
Background process calls PL/SQL Handler or Java
Java
Listener or OCI client when the Listener
commit has occurred
Event contains rowid
of changed rows
Used for:
Refreshing specific
data caches (middle
tier, global context)
(custom) Replication
PL/SQL
CONTINUOUS PROCESSING OF DATA
STREAMS USING CQL
Aggregation, Spot deviation, Match on
complex patterns
WHO IS AFRAID OF RED, YELLOW
AND BLUE
Table Events
Column Seq number(5)
Column Payload varchar2(200)
SOLUTION USING LEAD
SELECT *
FROM EMP
MATCH_RECOGNIZE
(
ORDER BY hiredate
MEASURES SAME_JOB.hiredate AS hireday
, MATCH_NUMBER() AS match_num
ALL ROWS PER MATCH
PATTERN (SAME_JOB{3})
DEFINE
SAME_JOB AS SAME_JOB.job = FIRST(SAME_JOB.job)
) MR
THE SHOPPING ALGORITHM
THE SHOPPING ALGORITHM
Participants
1 record
< > select *
from employers
where id = < 324>
100s records
select *
from employers 1 query
Benefits Package
select *
from employers
where id in <some set> select *
from participants
where employer_id in <some set>
select b.*
from benefits b join participants p
on (p.id = b.participant_id)
where p.employer_id in <some set>
APPLICATION ARCHITECTURE
SERVICE ENABLING
WebLogic Server Database
Re
OO
Native DB
WebService
lat
HTTP EPG
Java/JEE
XM on
PL/SQL
package
a
SOA Suite JDBC
AQ
L
View
Oracle Other Table
Service Bus (Email, FTP/File, XML
DB
XMPP/Chat)
Chat/IM XMPP
Server File/FTP Server
Email Server
XML/JSON
Relational/Oracle Type
11g Native DB
WebService
HTTP
10g
http
ADF BC
EPG
JSON/ CSV
Java App SDO /SDO WS XML PL/SQL
XML & XSD
WS
JAX-WS
package
Ref Cursor
JPublisher
DB Types & Coll
SOA WS JDBC XML
8i Types
Suite AQ AQ
Adapters
Chat/IM XMPP
Server
File/FTP Server
Email Server
BUSINESS RULES
SOA, ESB,
WebServices
Batch Bulk
Processes Standard
Applications
Database
OZ_CUSTOMER
?
ORDER
Id
Name
Country DUTCH_CUSTOMER
Customer_Id
. Id
Name
USING VIRTUAL COLUMNS
IN FOREIGN KEY RELATIONS
A foreign key can be created on a Virtual
Column
That means for example we can have a single
column with some id
And two virtual columns with CASE expressions
that produce NULL or the ID value
With Foreign Keys on the Virtual Columns
OZ_CUSTOMER
ORDER
Id
Country Name
DUTCH_CUSTOMER
Customer_Id
Dutch_id (VC) Id
Australian_id (VC) Name
USING VIRTUAL COLUMNS
IN FOREIGN KEY RELATIONS
Inline Views
Defaulting
Application Context
Flashback and the time dimension
NoSQL means smart SQL
Cache refresh driven by change notification
Streaming analysis before persisting
Decoupling galore
Bulk retrieval
Service enabling
Business Rules
EBR
12c promises even more