SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Downloaden Sie, um offline zu lesen
2014 © Trivadis 
BASEL BERN BRUGG LAUSANNE ZUERICH DUESSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MUNICH STUTTGART VIENNA 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
DOAG 2014, Nürnberg (DE) Christian Antognini 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
1
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
3 
@ChrisAntognini 
Senior principal consultant, trainer and partner at Trivadis in Zurich (CH) 
christian.antognini@trivadis.com 
http://antognini.ch 
Focus: get the most out of Oracle Database 
Logical and physical database design 
Query optimizer 
Application performance management 
Author of Troubleshooting Oracle Performance (Apress, 2008/2014) 
OakTable Network, Oracle ACE Director
2014 © Trivadis 
1.Native Support for Top-N Queries 
2.PL/SQL in SQL Statements 
3.Temporal Validity 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
4 
AGENDA
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
Native Support for Top-N Queries 
5
2014 © Trivadis 
The SELECT statement has been enriched by the ROW_LIMITING_CLAUSE 
Based on SQL:2011 
Absolute top-N as well as percent top-N queries are possible 
Absolute OFFSET may be declared 
TIES handling is supported 
Data should be ordered to get a decent top-N result 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
6 
ROW_LIMITING_CLAUSE
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
7 
Top-N Rows 
SELECT first_name, last_name, salary FROM hr.employees ORDER BY salary DESC FETCH FIRST 5 ROWS ONLY 
FIRST_NAME LAST_NAME SALARY -------------------- ------------------------- ---------- Steven King 24000 Neena Kochhar 17000 Lex De Haan 17000 John Russell 14000 Karen Partners 13500 
ROW | ROWS can be used interchangeably
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
8 
Absolute Offset 
SELECT first_name, last_name, salary FROM hr.employees ORDER BY salary DESC OFFSET 5 ROWS FETCH NEXT 5 ROWS ONLY 
FIRST_NAME LAST_NAME SALARY -------------------- ------------------------- ---------- Michael Hartstein 13000 Nancy Greenberg 12000 Shelley Higgins 12000 Alberto Errazuriz 12000 Lisa Ozer 11500 
FIRST | NEXT can be used interchangeably
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
9 
Top Percent Rows 
SELECT first_name, last_name, salary FROM hr.employees ORDER BY salary DESC FETCH FIRST 5 PERCENT ROWS ONLY 
FIRST_NAME LAST_NAME SALARY -------------------- ------------------------- ---------- Steven King 24000 Neena Kochhar 17000 Lex De Haan 17000 John Russell 14000 Karen Partners 13500 Michael Hartstein 13000 
The number of rows returned is always a “ceiled” value in percent
2014 © Trivadis 
Also SQL:2011 doesn’t have it 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
10 
No Percent Offset 
SELECT first_name, last_name, salary FROM hr.employees ORDER BY salary DESC OFFSET 5 PERCENT ROWS FETCH NEXT 5 PERCENT ROWS ONLY 
ORA-00905: missing keyword
2014 © Trivadis 
Use WITH TIES to specify how to handle equalities at the edge of the row set 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
11 
Ties Handling 
SELECT first_name, last_name, salary FROM hr.employees ORDER BY salary DESC FETCH FIRST 1 PERCENT ROWS ONLY 
FIRST_NAME LAST_NAME SALARY -------------------- ------------------------- ---------- Steven King 24000 Neena Kochhar 17000
2014 © Trivadis 
Use WITH TIES to specify how to handle equalities at the edge of the row set 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
12 
Ties Handling 
SELECT first_name, last_name, salary FROM hr.employees ORDER BY salary DESC FETCH FIRST 1 PERCENT ROWS WITH TIES 
FIRST_NAME LAST_NAME SALARY -------------------- ------------------------- ---------- Steven King 24000 Neena Kochhar 17000 Lex De Haan 17000
2014 © Trivadis 
Also SQL:2011 doesn’t have it 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
13 
No Offset with Ties Handling 
SELECT first_name, last_name, salary FROM employees ORDER BY salary DESC OFFSET 2 ROWS WITH TIES FETCH NEXT 1 PERCENT ROWS WITH TIES 
ORA-00933: SQL command not properly ended
2014 © Trivadis 
Every implementation of a top-N query has to order the result set 
Taking advantage of an index is also possible 
Either the WINDOW SORT or WINDOW SORT PUSHED RANK are used 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
14 
Performance 
---------------------------------------------- 
| Id | Operation | Name | 
---------------------------------------------- 
| 0 | SELECT STATEMENT | | 
| 1 | VIEW | | 
| 2 | WINDOW SORT PUSHED RANK| | 
| 3 | TABLE ACCESS FULL | EMPLOYEES | 
----------------------------------------------
2014 © Trivadis 
Top-N queries are easier using ROW_LIMITING_CLAUSE 
No need to use inline views with RANK() / DENSE_RANK() / ROW_NUMBER() to determine the rank of a row 
No need to use nested inline views using ORDER BY, ROWNUM 
Not being able to specify a percent OFFSET and an OFFSET with TIES might be a problem for paginating issues 
But who does a paginating where the size of the returned dataset is unknown due to a per cent based specifications or an unknown number of ties? 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
15 
Assessment
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
PL/SQL in SQL Statements 
16
2014 © Trivadis 
It is possible to define PL/SQL functions and procedures within a SQL statement 
They are only accessible inside this SQL statement 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
17 
New WITH Clause Feature 
WITH FUNCTION round2five (in_amount NUMBER) RETURN NUMBER IS BEGIN RETURN ROUND(in_amount*20)/20; END; SELECT last_name, first_name, salary , round2five(salary * 1.3131573) as new_sal_rounded FROM hr.employees WHERE ROWNUM <= 15
2014 © Trivadis 
More than one function/procedure may be defined 
Functions/procedures may access functions/procedures defined earlier within the same WITH clause 
Functions/procedures have to be defined prior to subquery factoring clause(s) 
Functions/procedures may be accessed by the subquery factoring clause(s) 
Functions/procedures specified in a WITH clause have priority over schema based functions/procedures sharing the same name 
But not over SYS functions like USER/SYSDATE 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
18 
Options and Rules (1)
2014 © Trivadis 
If the function/procedure declaration is not in a top level SELECT statement or is not part of a SELECT statement at all then the WITH_PLSQL hint has to be used 
Can be used in views 
AUTONOMOUS_TRANSACTION possible 
RESULT_CACHE is not supported in WITH clause functions 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
19 
Options and Rules (2)
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
20 
Example – Function with Exception Handler 
WITH FUNCTION is_numeric (in_value IN VARCHAR2) RETURN NUMBER IS l_number number; BEGIN l_number := to_number(in_value); return 1; EXCEPTION WHEN value_error then return -1; END; ...
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
21 
Example – Usage Within a View 
CREATE OR REPLACE VIEW employee_view AS WITH FUNCTION get_manager_formatted (in_manager_id IN NUMBER) RETURN VARCHAR2 DETERMINISTIC IS ... 
SELECT * FROM employee_view WHERE rownum <= 15;
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
22 
Example – AUTONOMOUS_TRANSACTION 
CREATE OR REPLACE VIEW employee_view AS WITH FUNCTION track_salary_access (in_rowid IN ROWID ,in_salary IN NUMBER) RETURN NUMBER IS PRAGMA AUTONOMOUS_TRANSACTION; BEGIN INSERT INTO employee_log (row_id) VALUES (in_rowid); COMMIT; RETURN in_salary; END; SELECT employee_id, first_name, last_name , track_salary_access(rowid, salary) salary FROM hr.employees;
2014 © Trivadis 
Do not expect major differences 
The code doesn’t run in the SQL engine! 
WITH clause program units might be faster than schema-based program units 
Only parameter passing was optimized 
Equivalent performance can be achieved with schema-based program units by using the UDF pragma 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
23 
Performance
2014 © Trivadis 
Cool stuff 
Whenever you use a function/procedure at more than one place, you should create a schema object to keep it maintainable 
SQL Developer 4.0.x does support this feature 
SQL*Plus prior to 12c does not support this feature 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
24 
Limitations / Assessment
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
Temporal Validity 
25
2014 © Trivadis 
Total Recall (System Time) 
Temporal Validity (Business Time) 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
26 
Temporal Validity versus Total Recall (FBDA)
2014 © Trivadis 
Total Recall (System Time) 
Previous and current states 
Backdated changes are not possible1) 
Future changes are not possible1) 
Only system time supported 
Temporal Validity (Business Time) 
Previous, current and future states 
Backdated changes are possible 
Future changes are possible 
Multiple valid time periods supported 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
27 
Temporal Validity versus Total Recall (FBDA) 
1) at least not as part of standard DML
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
28 
Temporal Validity – Period, Semantics and Granularity 
1981-02-20 
2014-01-01 
2015-04-01 
1981-02-20 00:00:00 
2014-01-01 00:00:00 
2015-04-01 00:00:00 
1981-02-20 
00:00:00.000000 
2014-01-01 
00:00:00.000000 
2015-04-01 
00:00:00.000000 
Start 
End 
CHICAGO 
Start 
End 
SAN FRANCISCO
2014 © Trivadis 
valid_time_column is the name of temporal period 
virtual and hidden 
default prefix for start_time_column and end_time_column 
start_time_column and end_time_column (NULL = ) 
hidden by default 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
29 
CREATE TABLE Enhancements
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
30 
ALTER TABLE Enhancements 
ALTER TABLE dept ADD (vt_start DATE, vt_end DATE, PERIOD FOR vt (vt_start, vt_end))
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
31 
Visible Period Start and End Columns 
SQL> SELECT * FROM dept; 
DEPTNO DNAME LOC VT_START VT_END 
---------- -------------- ------------- ---------- ---------- 
10 ACCOUNTING NEW YORK 
20 RESEARCH DALLAS 
30 SALES CHICAGO 
40 OPERATIONS BOSTON
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
32 
Hidden, Virtual Column 
SQL> SELECT column_name, data_type, data_length 
, hidden_column, virtual_column 
FROM user_tab_cols 
WHERE table_name = 'DEPT' AND column_name LIKE 'VT%'; 
COLUMN_NAME DATA_TYPE DATA_LENGTH HIDDEN_COLUMN VIRTUAL_COLUMN 
----------- --------- ----------- ------------- -------------- 
VT NUMBER 22 YES YES VT_START DATE 7 NO NO VT_END DATE 7 NO NO
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
33 
Constraint 
SQL> SELECT table_name, constraint_type, search_condition 
FROM user_constraints 
WHERE table_name = 'DEPT'; 
TABLE_NAME CONSTRAINT_TYPE SEARCH_CONDITION 
---------- --------------- -------------------------------- 
DEPT C (VT_START < VT_END) and (VT > 0)
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
34 
AS OF PERIOD Query 
SQL> SELECT * 
2 FROM dept AS OF PERIOD FOR vt DATE '2015-01-01' 
3 ORDER BY deptno; 
DEPTNO DNAME LOC VT_START VT_END 
---------- -------------- ------------- ---------- ---------- 
10 ACCOUNTING NEW YORK 
20 RESEARCH DALLAS 
30 SALES SAN FRANCISCO 2014-01-01 
40 OPERATIONS BOSTON
2014 © Trivadis 
ENABLE_AT_VALID_TIME 
LEVEL 
-ALL: no filter 
-CURRENT: filter records to display currently valid data 
-ASOF: filter records to display valid data as of <query_time> 
QUERY_TIME 
DISABLE_ASOF_VALID_TIME 
Clears an ASOF filter 
Same as "ENABLE_AT_VALID_TIME('ALL')" 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
35 
New Procedures in DBMS_FLASHBACK_ARCHIVE
2014 © Trivadis 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
36 
No DML Support – Do It Your Self… 
SQL> UPDATE dept SET vt_end = DATE '2014-01-01' WHERE deptno = 30; 
SQL> INSERT INTO dept (deptno, dname, loc, vt_start) 
2 VALUES (30, 'SALES', 'SAN FRANCISCO', DATE '2014-01-01'); 
SQL> SELECT * 
FROM dept 
WHERE deptno = 30 
ORDER BY vt_start NULLS FIRST; 
DEPTNO DNAME LOC VT_START VT_END 
---------- -------------- ------------- ---------- ---------- 
30 SALES CHICAGO 2014-01-01 
30 SALES SAN FRANCISCO 2014-01-01
2014 © Trivadis 
Temporal validity is supported with Multitenant as of 12.1.0.2 
In 12.1.0.1 
-DDL and DML works 
-Temporal flashback query filters are applied in a non-CDB instance only 
No support for temporal joins or temporal GROUP BY 
FLASHBACK_QUERY_CLAUSE 
Temporal flashback query filters are not applied on views 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
37 
Limitations / Assessment
2014 © Trivadis 
Core Messages 
Native Support for Top-N Queries 
There is no good reason for not using it 
PL/SQL in SQL Statements 
If correctly used, very good feature 
Temporal Validity 
It’s too soon! 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
38
2014 © Trivadis 
Questions and answers ... 
BASEL BERN BRUGG LAUSANNE ZUERICH DUESSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MUNICH STUTTGART VIENNA 
Christian Antognini Principal Senior Consultant 
christian.antognini@trivadis.com 
18 November 2014 
Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 
40

Weitere ähnliche Inhalte

Andere mochten auch

× MEL Métropole Européenne de Lille Yannick Jacob, chef du service évolution ...
×	MEL Métropole Européenne de Lille Yannick Jacob, chef du service évolution ...×	MEL Métropole Européenne de Lille Yannick Jacob, chef du service évolution ...
× MEL Métropole Européenne de Lille Yannick Jacob, chef du service évolution ...Véronique SEEL (Michaut)
 
Une cheminee ethanol dans votre domicile
Une cheminee ethanol dans votre domicile
Une cheminee ethanol dans votre domicile
Une cheminee ethanol dans votre domicile foyerbio-encastrable9
 
Why Patient-Reported Outcomes Are the Future of Healthcare
Why Patient-Reported Outcomes Are the Future of HealthcareWhy Patient-Reported Outcomes Are the Future of Healthcare
Why Patient-Reported Outcomes Are the Future of HealthcareHealth Catalyst
 
Kerrighed cluster deployment
Kerrighed cluster deploymentKerrighed cluster deployment
Kerrighed cluster deploymentJean Parpaillon
 
Organic and engineering Chemistry
Organic and engineering ChemistryOrganic and engineering Chemistry
Organic and engineering ChemistryThakur Sandilya
 
Apec workshop 2 presentation 5 e apec workshop mexico capture technologies ...
Apec workshop 2 presentation 5 e apec workshop mexico   capture technologies ...Apec workshop 2 presentation 5 e apec workshop mexico   capture technologies ...
Apec workshop 2 presentation 5 e apec workshop mexico capture technologies ...Global CCS Institute
 
Hydrogenation reaction
Hydrogenation reactionHydrogenation reaction
Hydrogenation reactionSonali Pimple
 
Veille écologique 02 2011
Veille écologique 02 2011Veille écologique 02 2011
Veille écologique 02 2011WanabeSA
 
How to Use Text Analytics in Healthcare to Improve Outcomes: Why You Need Mor...
How to Use Text Analytics in Healthcare to Improve Outcomes: Why You Need Mor...How to Use Text Analytics in Healthcare to Improve Outcomes: Why You Need Mor...
How to Use Text Analytics in Healthcare to Improve Outcomes: Why You Need Mor...Health Catalyst
 
Deploying Predictive Analytics in Healthcare
Deploying Predictive Analytics in HealthcareDeploying Predictive Analytics in Healthcare
Deploying Predictive Analytics in HealthcareHealth Catalyst
 
The 3 Must-Have Qualities of a Care Management System
The 3 Must-Have Qualities of a Care Management SystemThe 3 Must-Have Qualities of a Care Management System
The 3 Must-Have Qualities of a Care Management SystemHealth Catalyst
 
Bs151 - INSTRUÇÃO NORMATIVA Nº 106-DG/PF
Bs151 - INSTRUÇÃO NORMATIVA Nº 106-DG/PFBs151 - INSTRUÇÃO NORMATIVA Nº 106-DG/PF
Bs151 - INSTRUÇÃO NORMATIVA Nº 106-DG/PFMinistério da Justiça
 
Les défis de l'économie circulaire et le rôle du business modèle
Les défis de l'économie circulaire et le rôle du business modèleLes défis de l'économie circulaire et le rôle du business modèle
Les défis de l'économie circulaire et le rôle du business modèleMourad ZEROUKHI
 

Andere mochten auch (16)

× MEL Métropole Européenne de Lille Yannick Jacob, chef du service évolution ...
×	MEL Métropole Européenne de Lille Yannick Jacob, chef du service évolution ...×	MEL Métropole Européenne de Lille Yannick Jacob, chef du service évolution ...
× MEL Métropole Européenne de Lille Yannick Jacob, chef du service évolution ...
 
Une cheminee ethanol dans votre domicile
Une cheminee ethanol dans votre domicile
Une cheminee ethanol dans votre domicile
Une cheminee ethanol dans votre domicile
 
Why Patient-Reported Outcomes Are the Future of Healthcare
Why Patient-Reported Outcomes Are the Future of HealthcareWhy Patient-Reported Outcomes Are the Future of Healthcare
Why Patient-Reported Outcomes Are the Future of Healthcare
 
Kerrighed cluster deployment
Kerrighed cluster deploymentKerrighed cluster deployment
Kerrighed cluster deployment
 
Organic and engineering Chemistry
Organic and engineering ChemistryOrganic and engineering Chemistry
Organic and engineering Chemistry
 
Apec workshop 2 presentation 5 e apec workshop mexico capture technologies ...
Apec workshop 2 presentation 5 e apec workshop mexico   capture technologies ...Apec workshop 2 presentation 5 e apec workshop mexico   capture technologies ...
Apec workshop 2 presentation 5 e apec workshop mexico capture technologies ...
 
Hydrogenation reaction
Hydrogenation reactionHydrogenation reaction
Hydrogenation reaction
 
Veille écologique 02 2011
Veille écologique 02 2011Veille écologique 02 2011
Veille écologique 02 2011
 
How to Use Text Analytics in Healthcare to Improve Outcomes: Why You Need Mor...
How to Use Text Analytics in Healthcare to Improve Outcomes: Why You Need Mor...How to Use Text Analytics in Healthcare to Improve Outcomes: Why You Need Mor...
How to Use Text Analytics in Healthcare to Improve Outcomes: Why You Need Mor...
 
Catt Tutorial
Catt TutorialCatt Tutorial
Catt Tutorial
 
Instituto universitario de tecnología
Instituto universitario de tecnologíaInstituto universitario de tecnología
Instituto universitario de tecnología
 
Deploying Predictive Analytics in Healthcare
Deploying Predictive Analytics in HealthcareDeploying Predictive Analytics in Healthcare
Deploying Predictive Analytics in Healthcare
 
The 3 Must-Have Qualities of a Care Management System
The 3 Must-Have Qualities of a Care Management SystemThe 3 Must-Have Qualities of a Care Management System
The 3 Must-Have Qualities of a Care Management System
 
Bs151 - INSTRUÇÃO NORMATIVA Nº 106-DG/PF
Bs151 - INSTRUÇÃO NORMATIVA Nº 106-DG/PFBs151 - INSTRUÇÃO NORMATIVA Nº 106-DG/PF
Bs151 - INSTRUÇÃO NORMATIVA Nº 106-DG/PF
 
La tierra un planeta habitado
La tierra un planeta habitadoLa tierra un planeta habitado
La tierra un planeta habitado
 
Les défis de l'économie circulaire et le rôle du business modèle
Les défis de l'économie circulaire et le rôle du business modèleLes défis de l'économie circulaire et le rôle du business modèle
Les défis de l'économie circulaire et le rôle du business modèle
 

Ähnlich wie Row Limiting, PL/SQL Functions and Temporal Validity in Oracle 12c

SQL Pattern Matching – should I start using it?
SQL Pattern Matching – should I start using it?SQL Pattern Matching – should I start using it?
SQL Pattern Matching – should I start using it?Andrej Pashchenko
 
Crack the complexity of oracle applications r12 workload v2
Crack the complexity of oracle applications r12 workload v2Crack the complexity of oracle applications r12 workload v2
Crack the complexity of oracle applications r12 workload v2Ajith Narayanan
 
KoprowskiT_SQLRelay2014#2_Southampton_MaintenancePlansForBeginners
KoprowskiT_SQLRelay2014#2_Southampton_MaintenancePlansForBeginnersKoprowskiT_SQLRelay2014#2_Southampton_MaintenancePlansForBeginners
KoprowskiT_SQLRelay2014#2_Southampton_MaintenancePlansForBeginnersTobias Koprowski
 
GraphQL And Relay Modern
GraphQL And Relay ModernGraphQL And Relay Modern
GraphQL And Relay ModernBrad Pillow
 
GraphQL And Relay Modern
GraphQL And Relay ModernGraphQL And Relay Modern
GraphQL And Relay ModernBrad Pillow
 
RMOUG2016 - Resource Management (the critical piece of the consolidation puzzle)
RMOUG2016 - Resource Management (the critical piece of the consolidation puzzle)RMOUG2016 - Resource Management (the critical piece of the consolidation puzzle)
RMOUG2016 - Resource Management (the critical piece of the consolidation puzzle)Kristofferson A
 
Boost your Oracle RAC manageability with Policy-Managed Databases
Boost your Oracle RAC manageability with Policy-Managed DatabasesBoost your Oracle RAC manageability with Policy-Managed Databases
Boost your Oracle RAC manageability with Policy-Managed DatabasesLudovico Caldara
 
Oracle Drivers configuration for High Availability, is it a developer's job?
Oracle Drivers configuration for High Availability, is it a developer's job?Oracle Drivers configuration for High Availability, is it a developer's job?
Oracle Drivers configuration for High Availability, is it a developer's job?Ludovico Caldara
 
SQL Optimization With Trace Data And Dbms Xplan V6
SQL Optimization With Trace Data And Dbms Xplan V6SQL Optimization With Trace Data And Dbms Xplan V6
SQL Optimization With Trace Data And Dbms Xplan V6Mahesh Vallampati
 
Advanced ASE Performance Tuning Tips
Advanced ASE Performance Tuning Tips Advanced ASE Performance Tuning Tips
Advanced ASE Performance Tuning Tips SAP Technology
 
Apache Lens at Hadoop meetup
Apache Lens at Hadoop meetupApache Lens at Hadoop meetup
Apache Lens at Hadoop meetupamarsri
 
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...Ludovico Caldara
 

Ähnlich wie Row Limiting, PL/SQL Functions and Temporal Validity in Oracle 12c (20)

Adaptive Query Optimization
Adaptive Query OptimizationAdaptive Query Optimization
Adaptive Query Optimization
 
SQL Pattern Matching – should I start using it?
SQL Pattern Matching – should I start using it?SQL Pattern Matching – should I start using it?
SQL Pattern Matching – should I start using it?
 
Checklist_AC.pdf
Checklist_AC.pdfChecklist_AC.pdf
Checklist_AC.pdf
 
Crack the complexity of oracle applications r12 workload v2
Crack the complexity of oracle applications r12 workload v2Crack the complexity of oracle applications r12 workload v2
Crack the complexity of oracle applications r12 workload v2
 
KoprowskiT_SQLRelay2014#2_Southampton_MaintenancePlansForBeginners
KoprowskiT_SQLRelay2014#2_Southampton_MaintenancePlansForBeginnersKoprowskiT_SQLRelay2014#2_Southampton_MaintenancePlansForBeginners
KoprowskiT_SQLRelay2014#2_Southampton_MaintenancePlansForBeginners
 
les07.pdf
les07.pdfles07.pdf
les07.pdf
 
SQL vs. NoSQL
SQL vs. NoSQLSQL vs. NoSQL
SQL vs. NoSQL
 
GraphQL And Relay Modern
GraphQL And Relay ModernGraphQL And Relay Modern
GraphQL And Relay Modern
 
GraphQL and Relay Modern
GraphQL and Relay ModernGraphQL and Relay Modern
GraphQL and Relay Modern
 
GraphQL And Relay Modern
GraphQL And Relay ModernGraphQL And Relay Modern
GraphQL And Relay Modern
 
Performance vision Version 3.0 - What's New
Performance vision Version 3.0 - What's NewPerformance vision Version 3.0 - What's New
Performance vision Version 3.0 - What's New
 
RMOUG2016 - Resource Management (the critical piece of the consolidation puzzle)
RMOUG2016 - Resource Management (the critical piece of the consolidation puzzle)RMOUG2016 - Resource Management (the critical piece of the consolidation puzzle)
RMOUG2016 - Resource Management (the critical piece of the consolidation puzzle)
 
Boost your Oracle RAC manageability with Policy-Managed Databases
Boost your Oracle RAC manageability with Policy-Managed DatabasesBoost your Oracle RAC manageability with Policy-Managed Databases
Boost your Oracle RAC manageability with Policy-Managed Databases
 
Oracle Drivers configuration for High Availability, is it a developer's job?
Oracle Drivers configuration for High Availability, is it a developer's job?Oracle Drivers configuration for High Availability, is it a developer's job?
Oracle Drivers configuration for High Availability, is it a developer's job?
 
SQL Optimization With Trace Data And Dbms Xplan V6
SQL Optimization With Trace Data And Dbms Xplan V6SQL Optimization With Trace Data And Dbms Xplan V6
SQL Optimization With Trace Data And Dbms Xplan V6
 
Presentation 12c pdb
Presentation 12c pdbPresentation 12c pdb
Presentation 12c pdb
 
Advanced ASE Performance Tuning Tips
Advanced ASE Performance Tuning Tips Advanced ASE Performance Tuning Tips
Advanced ASE Performance Tuning Tips
 
Apache Lens at Hadoop meetup
Apache Lens at Hadoop meetupApache Lens at Hadoop meetup
Apache Lens at Hadoop meetup
 
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
Oracle Active Data Guard 12c: Far Sync Instance, Real-Time Cascade and Other ...
 
chapter 17.pdf
chapter 17.pdfchapter 17.pdf
chapter 17.pdf
 

Mehr von Trivadis

Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...
Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...
Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...Trivadis
 
Azure Days 2019: Trivadis Azure Foundation – Das Fundament für den ... (Nisan...
Azure Days 2019: Trivadis Azure Foundation – Das Fundament für den ... (Nisan...Azure Days 2019: Trivadis Azure Foundation – Das Fundament für den ... (Nisan...
Azure Days 2019: Trivadis Azure Foundation – Das Fundament für den ... (Nisan...Trivadis
 
Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)
Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)
Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)Trivadis
 
Azure Days 2019: Master the Move to Azure (Konrad Brunner)
Azure Days 2019: Master the Move to Azure (Konrad Brunner)Azure Days 2019: Master the Move to Azure (Konrad Brunner)
Azure Days 2019: Master the Move to Azure (Konrad Brunner)Trivadis
 
Azure Days 2019: Keynote Azure Switzerland – Status Quo und Ausblick (Primo A...
Azure Days 2019: Keynote Azure Switzerland – Status Quo und Ausblick (Primo A...Azure Days 2019: Keynote Azure Switzerland – Status Quo und Ausblick (Primo A...
Azure Days 2019: Keynote Azure Switzerland – Status Quo und Ausblick (Primo A...Trivadis
 
Azure Days 2019: Grösser und Komplexer ist nicht immer besser (Meinrad Weiss)
Azure Days 2019: Grösser und Komplexer ist nicht immer besser (Meinrad Weiss)Azure Days 2019: Grösser und Komplexer ist nicht immer besser (Meinrad Weiss)
Azure Days 2019: Grösser und Komplexer ist nicht immer besser (Meinrad Weiss)Trivadis
 
Azure Days 2019: Get Connected with Azure API Management (Gerry Keune & Stefa...
Azure Days 2019: Get Connected with Azure API Management (Gerry Keune & Stefa...Azure Days 2019: Get Connected with Azure API Management (Gerry Keune & Stefa...
Azure Days 2019: Get Connected with Azure API Management (Gerry Keune & Stefa...Trivadis
 
Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...
Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...
Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...Trivadis
 
Azure Days 2019: Wie bringt man eine Data Analytics Plattform in die Cloud? (...
Azure Days 2019: Wie bringt man eine Data Analytics Plattform in die Cloud? (...Azure Days 2019: Wie bringt man eine Data Analytics Plattform in die Cloud? (...
Azure Days 2019: Wie bringt man eine Data Analytics Plattform in die Cloud? (...Trivadis
 
Azure Days 2019: Azure@Helsana: Die Erweiterung von Dynamics CRM mit Azure Po...
Azure Days 2019: Azure@Helsana: Die Erweiterung von Dynamics CRM mit Azure Po...Azure Days 2019: Azure@Helsana: Die Erweiterung von Dynamics CRM mit Azure Po...
Azure Days 2019: Azure@Helsana: Die Erweiterung von Dynamics CRM mit Azure Po...Trivadis
 
TechEvent 2019: Kundenstory - Kein Angebot, kein Auftrag – Wie Du ein individ...
TechEvent 2019: Kundenstory - Kein Angebot, kein Auftrag – Wie Du ein individ...TechEvent 2019: Kundenstory - Kein Angebot, kein Auftrag – Wie Du ein individ...
TechEvent 2019: Kundenstory - Kein Angebot, kein Auftrag – Wie Du ein individ...Trivadis
 
TechEvent 2019: Oracle Database Appliance M/L - Erfahrungen und Erfolgsmethod...
TechEvent 2019: Oracle Database Appliance M/L - Erfahrungen und Erfolgsmethod...TechEvent 2019: Oracle Database Appliance M/L - Erfahrungen und Erfolgsmethod...
TechEvent 2019: Oracle Database Appliance M/L - Erfahrungen und Erfolgsmethod...Trivadis
 
TechEvent 2019: Security 101 für Web Entwickler; Roland Krüger - Trivadis
TechEvent 2019: Security 101 für Web Entwickler; Roland Krüger - TrivadisTechEvent 2019: Security 101 für Web Entwickler; Roland Krüger - Trivadis
TechEvent 2019: Security 101 für Web Entwickler; Roland Krüger - TrivadisTrivadis
 
TechEvent 2019: Trivadis & Swisscom Partner Angebote; Konrad Häfeli, Markus O...
TechEvent 2019: Trivadis & Swisscom Partner Angebote; Konrad Häfeli, Markus O...TechEvent 2019: Trivadis & Swisscom Partner Angebote; Konrad Häfeli, Markus O...
TechEvent 2019: Trivadis & Swisscom Partner Angebote; Konrad Häfeli, Markus O...Trivadis
 
TechEvent 2019: DBaaS from Swisscom Cloud powered by Trivadis; Konrad Häfeli ...
TechEvent 2019: DBaaS from Swisscom Cloud powered by Trivadis; Konrad Häfeli ...TechEvent 2019: DBaaS from Swisscom Cloud powered by Trivadis; Konrad Häfeli ...
TechEvent 2019: DBaaS from Swisscom Cloud powered by Trivadis; Konrad Häfeli ...Trivadis
 
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...Trivadis
 
TechEvent 2019: More Agile, More AI, More Cloud! Less Work?!; Oliver Dörr - T...
TechEvent 2019: More Agile, More AI, More Cloud! Less Work?!; Oliver Dörr - T...TechEvent 2019: More Agile, More AI, More Cloud! Less Work?!; Oliver Dörr - T...
TechEvent 2019: More Agile, More AI, More Cloud! Less Work?!; Oliver Dörr - T...Trivadis
 
TechEvent 2019: Kundenstory - Vom Hauptmann zu Köpenick zum Polizisten 2020 -...
TechEvent 2019: Kundenstory - Vom Hauptmann zu Köpenick zum Polizisten 2020 -...TechEvent 2019: Kundenstory - Vom Hauptmann zu Köpenick zum Polizisten 2020 -...
TechEvent 2019: Kundenstory - Vom Hauptmann zu Köpenick zum Polizisten 2020 -...Trivadis
 
TechEvent 2019: Vom Rechenzentrum in die Oracle Cloud - Übertragungsmethoden;...
TechEvent 2019: Vom Rechenzentrum in die Oracle Cloud - Übertragungsmethoden;...TechEvent 2019: Vom Rechenzentrum in die Oracle Cloud - Übertragungsmethoden;...
TechEvent 2019: Vom Rechenzentrum in die Oracle Cloud - Übertragungsmethoden;...Trivadis
 
TechEvent 2019: The sleeping Power of Data; Eberhard Lösch - Trivadis
TechEvent 2019: The sleeping Power of Data; Eberhard Lösch - TrivadisTechEvent 2019: The sleeping Power of Data; Eberhard Lösch - Trivadis
TechEvent 2019: The sleeping Power of Data; Eberhard Lösch - TrivadisTrivadis
 

Mehr von Trivadis (20)

Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...
Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...
Azure Days 2019: Azure Chatbot Development for Airline Irregularities (Remco ...
 
Azure Days 2019: Trivadis Azure Foundation – Das Fundament für den ... (Nisan...
Azure Days 2019: Trivadis Azure Foundation – Das Fundament für den ... (Nisan...Azure Days 2019: Trivadis Azure Foundation – Das Fundament für den ... (Nisan...
Azure Days 2019: Trivadis Azure Foundation – Das Fundament für den ... (Nisan...
 
Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)
Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)
Azure Days 2019: Business Intelligence auf Azure (Marco Amhof & Yves Mauron)
 
Azure Days 2019: Master the Move to Azure (Konrad Brunner)
Azure Days 2019: Master the Move to Azure (Konrad Brunner)Azure Days 2019: Master the Move to Azure (Konrad Brunner)
Azure Days 2019: Master the Move to Azure (Konrad Brunner)
 
Azure Days 2019: Keynote Azure Switzerland – Status Quo und Ausblick (Primo A...
Azure Days 2019: Keynote Azure Switzerland – Status Quo und Ausblick (Primo A...Azure Days 2019: Keynote Azure Switzerland – Status Quo und Ausblick (Primo A...
Azure Days 2019: Keynote Azure Switzerland – Status Quo und Ausblick (Primo A...
 
Azure Days 2019: Grösser und Komplexer ist nicht immer besser (Meinrad Weiss)
Azure Days 2019: Grösser und Komplexer ist nicht immer besser (Meinrad Weiss)Azure Days 2019: Grösser und Komplexer ist nicht immer besser (Meinrad Weiss)
Azure Days 2019: Grösser und Komplexer ist nicht immer besser (Meinrad Weiss)
 
Azure Days 2019: Get Connected with Azure API Management (Gerry Keune & Stefa...
Azure Days 2019: Get Connected with Azure API Management (Gerry Keune & Stefa...Azure Days 2019: Get Connected with Azure API Management (Gerry Keune & Stefa...
Azure Days 2019: Get Connected with Azure API Management (Gerry Keune & Stefa...
 
Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...
Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...
Azure Days 2019: Infrastructure as Code auf Azure (Jonas Wanninger & Daniel H...
 
Azure Days 2019: Wie bringt man eine Data Analytics Plattform in die Cloud? (...
Azure Days 2019: Wie bringt man eine Data Analytics Plattform in die Cloud? (...Azure Days 2019: Wie bringt man eine Data Analytics Plattform in die Cloud? (...
Azure Days 2019: Wie bringt man eine Data Analytics Plattform in die Cloud? (...
 
Azure Days 2019: Azure@Helsana: Die Erweiterung von Dynamics CRM mit Azure Po...
Azure Days 2019: Azure@Helsana: Die Erweiterung von Dynamics CRM mit Azure Po...Azure Days 2019: Azure@Helsana: Die Erweiterung von Dynamics CRM mit Azure Po...
Azure Days 2019: Azure@Helsana: Die Erweiterung von Dynamics CRM mit Azure Po...
 
TechEvent 2019: Kundenstory - Kein Angebot, kein Auftrag – Wie Du ein individ...
TechEvent 2019: Kundenstory - Kein Angebot, kein Auftrag – Wie Du ein individ...TechEvent 2019: Kundenstory - Kein Angebot, kein Auftrag – Wie Du ein individ...
TechEvent 2019: Kundenstory - Kein Angebot, kein Auftrag – Wie Du ein individ...
 
TechEvent 2019: Oracle Database Appliance M/L - Erfahrungen und Erfolgsmethod...
TechEvent 2019: Oracle Database Appliance M/L - Erfahrungen und Erfolgsmethod...TechEvent 2019: Oracle Database Appliance M/L - Erfahrungen und Erfolgsmethod...
TechEvent 2019: Oracle Database Appliance M/L - Erfahrungen und Erfolgsmethod...
 
TechEvent 2019: Security 101 für Web Entwickler; Roland Krüger - Trivadis
TechEvent 2019: Security 101 für Web Entwickler; Roland Krüger - TrivadisTechEvent 2019: Security 101 für Web Entwickler; Roland Krüger - Trivadis
TechEvent 2019: Security 101 für Web Entwickler; Roland Krüger - Trivadis
 
TechEvent 2019: Trivadis & Swisscom Partner Angebote; Konrad Häfeli, Markus O...
TechEvent 2019: Trivadis & Swisscom Partner Angebote; Konrad Häfeli, Markus O...TechEvent 2019: Trivadis & Swisscom Partner Angebote; Konrad Häfeli, Markus O...
TechEvent 2019: Trivadis & Swisscom Partner Angebote; Konrad Häfeli, Markus O...
 
TechEvent 2019: DBaaS from Swisscom Cloud powered by Trivadis; Konrad Häfeli ...
TechEvent 2019: DBaaS from Swisscom Cloud powered by Trivadis; Konrad Häfeli ...TechEvent 2019: DBaaS from Swisscom Cloud powered by Trivadis; Konrad Häfeli ...
TechEvent 2019: DBaaS from Swisscom Cloud powered by Trivadis; Konrad Häfeli ...
 
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
 
TechEvent 2019: More Agile, More AI, More Cloud! Less Work?!; Oliver Dörr - T...
TechEvent 2019: More Agile, More AI, More Cloud! Less Work?!; Oliver Dörr - T...TechEvent 2019: More Agile, More AI, More Cloud! Less Work?!; Oliver Dörr - T...
TechEvent 2019: More Agile, More AI, More Cloud! Less Work?!; Oliver Dörr - T...
 
TechEvent 2019: Kundenstory - Vom Hauptmann zu Köpenick zum Polizisten 2020 -...
TechEvent 2019: Kundenstory - Vom Hauptmann zu Köpenick zum Polizisten 2020 -...TechEvent 2019: Kundenstory - Vom Hauptmann zu Köpenick zum Polizisten 2020 -...
TechEvent 2019: Kundenstory - Vom Hauptmann zu Köpenick zum Polizisten 2020 -...
 
TechEvent 2019: Vom Rechenzentrum in die Oracle Cloud - Übertragungsmethoden;...
TechEvent 2019: Vom Rechenzentrum in die Oracle Cloud - Übertragungsmethoden;...TechEvent 2019: Vom Rechenzentrum in die Oracle Cloud - Übertragungsmethoden;...
TechEvent 2019: Vom Rechenzentrum in die Oracle Cloud - Übertragungsmethoden;...
 
TechEvent 2019: The sleeping Power of Data; Eberhard Lösch - Trivadis
TechEvent 2019: The sleeping Power of Data; Eberhard Lösch - TrivadisTechEvent 2019: The sleeping Power of Data; Eberhard Lösch - Trivadis
TechEvent 2019: The sleeping Power of Data; Eberhard Lösch - Trivadis
 

Row Limiting, PL/SQL Functions and Temporal Validity in Oracle 12c

  • 1. 2014 © Trivadis BASEL BERN BRUGG LAUSANNE ZUERICH DUESSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MUNICH STUTTGART VIENNA Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity DOAG 2014, Nürnberg (DE) Christian Antognini 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 1
  • 2. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 3 @ChrisAntognini Senior principal consultant, trainer and partner at Trivadis in Zurich (CH) christian.antognini@trivadis.com http://antognini.ch Focus: get the most out of Oracle Database Logical and physical database design Query optimizer Application performance management Author of Troubleshooting Oracle Performance (Apress, 2008/2014) OakTable Network, Oracle ACE Director
  • 3. 2014 © Trivadis 1.Native Support for Top-N Queries 2.PL/SQL in SQL Statements 3.Temporal Validity 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 4 AGENDA
  • 4. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity Native Support for Top-N Queries 5
  • 5. 2014 © Trivadis The SELECT statement has been enriched by the ROW_LIMITING_CLAUSE Based on SQL:2011 Absolute top-N as well as percent top-N queries are possible Absolute OFFSET may be declared TIES handling is supported Data should be ordered to get a decent top-N result 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 6 ROW_LIMITING_CLAUSE
  • 6. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 7 Top-N Rows SELECT first_name, last_name, salary FROM hr.employees ORDER BY salary DESC FETCH FIRST 5 ROWS ONLY FIRST_NAME LAST_NAME SALARY -------------------- ------------------------- ---------- Steven King 24000 Neena Kochhar 17000 Lex De Haan 17000 John Russell 14000 Karen Partners 13500 ROW | ROWS can be used interchangeably
  • 7. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 8 Absolute Offset SELECT first_name, last_name, salary FROM hr.employees ORDER BY salary DESC OFFSET 5 ROWS FETCH NEXT 5 ROWS ONLY FIRST_NAME LAST_NAME SALARY -------------------- ------------------------- ---------- Michael Hartstein 13000 Nancy Greenberg 12000 Shelley Higgins 12000 Alberto Errazuriz 12000 Lisa Ozer 11500 FIRST | NEXT can be used interchangeably
  • 8. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 9 Top Percent Rows SELECT first_name, last_name, salary FROM hr.employees ORDER BY salary DESC FETCH FIRST 5 PERCENT ROWS ONLY FIRST_NAME LAST_NAME SALARY -------------------- ------------------------- ---------- Steven King 24000 Neena Kochhar 17000 Lex De Haan 17000 John Russell 14000 Karen Partners 13500 Michael Hartstein 13000 The number of rows returned is always a “ceiled” value in percent
  • 9. 2014 © Trivadis Also SQL:2011 doesn’t have it 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 10 No Percent Offset SELECT first_name, last_name, salary FROM hr.employees ORDER BY salary DESC OFFSET 5 PERCENT ROWS FETCH NEXT 5 PERCENT ROWS ONLY ORA-00905: missing keyword
  • 10. 2014 © Trivadis Use WITH TIES to specify how to handle equalities at the edge of the row set 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 11 Ties Handling SELECT first_name, last_name, salary FROM hr.employees ORDER BY salary DESC FETCH FIRST 1 PERCENT ROWS ONLY FIRST_NAME LAST_NAME SALARY -------------------- ------------------------- ---------- Steven King 24000 Neena Kochhar 17000
  • 11. 2014 © Trivadis Use WITH TIES to specify how to handle equalities at the edge of the row set 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 12 Ties Handling SELECT first_name, last_name, salary FROM hr.employees ORDER BY salary DESC FETCH FIRST 1 PERCENT ROWS WITH TIES FIRST_NAME LAST_NAME SALARY -------------------- ------------------------- ---------- Steven King 24000 Neena Kochhar 17000 Lex De Haan 17000
  • 12. 2014 © Trivadis Also SQL:2011 doesn’t have it 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 13 No Offset with Ties Handling SELECT first_name, last_name, salary FROM employees ORDER BY salary DESC OFFSET 2 ROWS WITH TIES FETCH NEXT 1 PERCENT ROWS WITH TIES ORA-00933: SQL command not properly ended
  • 13. 2014 © Trivadis Every implementation of a top-N query has to order the result set Taking advantage of an index is also possible Either the WINDOW SORT or WINDOW SORT PUSHED RANK are used 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 14 Performance ---------------------------------------------- | Id | Operation | Name | ---------------------------------------------- | 0 | SELECT STATEMENT | | | 1 | VIEW | | | 2 | WINDOW SORT PUSHED RANK| | | 3 | TABLE ACCESS FULL | EMPLOYEES | ----------------------------------------------
  • 14. 2014 © Trivadis Top-N queries are easier using ROW_LIMITING_CLAUSE No need to use inline views with RANK() / DENSE_RANK() / ROW_NUMBER() to determine the rank of a row No need to use nested inline views using ORDER BY, ROWNUM Not being able to specify a percent OFFSET and an OFFSET with TIES might be a problem for paginating issues But who does a paginating where the size of the returned dataset is unknown due to a per cent based specifications or an unknown number of ties? 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 15 Assessment
  • 15. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity PL/SQL in SQL Statements 16
  • 16. 2014 © Trivadis It is possible to define PL/SQL functions and procedures within a SQL statement They are only accessible inside this SQL statement 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 17 New WITH Clause Feature WITH FUNCTION round2five (in_amount NUMBER) RETURN NUMBER IS BEGIN RETURN ROUND(in_amount*20)/20; END; SELECT last_name, first_name, salary , round2five(salary * 1.3131573) as new_sal_rounded FROM hr.employees WHERE ROWNUM <= 15
  • 17. 2014 © Trivadis More than one function/procedure may be defined Functions/procedures may access functions/procedures defined earlier within the same WITH clause Functions/procedures have to be defined prior to subquery factoring clause(s) Functions/procedures may be accessed by the subquery factoring clause(s) Functions/procedures specified in a WITH clause have priority over schema based functions/procedures sharing the same name But not over SYS functions like USER/SYSDATE 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 18 Options and Rules (1)
  • 18. 2014 © Trivadis If the function/procedure declaration is not in a top level SELECT statement or is not part of a SELECT statement at all then the WITH_PLSQL hint has to be used Can be used in views AUTONOMOUS_TRANSACTION possible RESULT_CACHE is not supported in WITH clause functions 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 19 Options and Rules (2)
  • 19. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 20 Example – Function with Exception Handler WITH FUNCTION is_numeric (in_value IN VARCHAR2) RETURN NUMBER IS l_number number; BEGIN l_number := to_number(in_value); return 1; EXCEPTION WHEN value_error then return -1; END; ...
  • 20. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 21 Example – Usage Within a View CREATE OR REPLACE VIEW employee_view AS WITH FUNCTION get_manager_formatted (in_manager_id IN NUMBER) RETURN VARCHAR2 DETERMINISTIC IS ... SELECT * FROM employee_view WHERE rownum <= 15;
  • 21. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 22 Example – AUTONOMOUS_TRANSACTION CREATE OR REPLACE VIEW employee_view AS WITH FUNCTION track_salary_access (in_rowid IN ROWID ,in_salary IN NUMBER) RETURN NUMBER IS PRAGMA AUTONOMOUS_TRANSACTION; BEGIN INSERT INTO employee_log (row_id) VALUES (in_rowid); COMMIT; RETURN in_salary; END; SELECT employee_id, first_name, last_name , track_salary_access(rowid, salary) salary FROM hr.employees;
  • 22. 2014 © Trivadis Do not expect major differences The code doesn’t run in the SQL engine! WITH clause program units might be faster than schema-based program units Only parameter passing was optimized Equivalent performance can be achieved with schema-based program units by using the UDF pragma 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 23 Performance
  • 23. 2014 © Trivadis Cool stuff Whenever you use a function/procedure at more than one place, you should create a schema object to keep it maintainable SQL Developer 4.0.x does support this feature SQL*Plus prior to 12c does not support this feature 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 24 Limitations / Assessment
  • 24. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity Temporal Validity 25
  • 25. 2014 © Trivadis Total Recall (System Time) Temporal Validity (Business Time) 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 26 Temporal Validity versus Total Recall (FBDA)
  • 26. 2014 © Trivadis Total Recall (System Time) Previous and current states Backdated changes are not possible1) Future changes are not possible1) Only system time supported Temporal Validity (Business Time) Previous, current and future states Backdated changes are possible Future changes are possible Multiple valid time periods supported 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 27 Temporal Validity versus Total Recall (FBDA) 1) at least not as part of standard DML
  • 27. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 28 Temporal Validity – Period, Semantics and Granularity 1981-02-20 2014-01-01 2015-04-01 1981-02-20 00:00:00 2014-01-01 00:00:00 2015-04-01 00:00:00 1981-02-20 00:00:00.000000 2014-01-01 00:00:00.000000 2015-04-01 00:00:00.000000 Start End CHICAGO Start End SAN FRANCISCO
  • 28. 2014 © Trivadis valid_time_column is the name of temporal period virtual and hidden default prefix for start_time_column and end_time_column start_time_column and end_time_column (NULL = ) hidden by default 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 29 CREATE TABLE Enhancements
  • 29. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 30 ALTER TABLE Enhancements ALTER TABLE dept ADD (vt_start DATE, vt_end DATE, PERIOD FOR vt (vt_start, vt_end))
  • 30. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 31 Visible Period Start and End Columns SQL> SELECT * FROM dept; DEPTNO DNAME LOC VT_START VT_END ---------- -------------- ------------- ---------- ---------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON
  • 31. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 32 Hidden, Virtual Column SQL> SELECT column_name, data_type, data_length , hidden_column, virtual_column FROM user_tab_cols WHERE table_name = 'DEPT' AND column_name LIKE 'VT%'; COLUMN_NAME DATA_TYPE DATA_LENGTH HIDDEN_COLUMN VIRTUAL_COLUMN ----------- --------- ----------- ------------- -------------- VT NUMBER 22 YES YES VT_START DATE 7 NO NO VT_END DATE 7 NO NO
  • 32. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 33 Constraint SQL> SELECT table_name, constraint_type, search_condition FROM user_constraints WHERE table_name = 'DEPT'; TABLE_NAME CONSTRAINT_TYPE SEARCH_CONDITION ---------- --------------- -------------------------------- DEPT C (VT_START < VT_END) and (VT > 0)
  • 33. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 34 AS OF PERIOD Query SQL> SELECT * 2 FROM dept AS OF PERIOD FOR vt DATE '2015-01-01' 3 ORDER BY deptno; DEPTNO DNAME LOC VT_START VT_END ---------- -------------- ------------- ---------- ---------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES SAN FRANCISCO 2014-01-01 40 OPERATIONS BOSTON
  • 34. 2014 © Trivadis ENABLE_AT_VALID_TIME LEVEL -ALL: no filter -CURRENT: filter records to display currently valid data -ASOF: filter records to display valid data as of <query_time> QUERY_TIME DISABLE_ASOF_VALID_TIME Clears an ASOF filter Same as "ENABLE_AT_VALID_TIME('ALL')" 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 35 New Procedures in DBMS_FLASHBACK_ARCHIVE
  • 35. 2014 © Trivadis 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 36 No DML Support – Do It Your Self… SQL> UPDATE dept SET vt_end = DATE '2014-01-01' WHERE deptno = 30; SQL> INSERT INTO dept (deptno, dname, loc, vt_start) 2 VALUES (30, 'SALES', 'SAN FRANCISCO', DATE '2014-01-01'); SQL> SELECT * FROM dept WHERE deptno = 30 ORDER BY vt_start NULLS FIRST; DEPTNO DNAME LOC VT_START VT_END ---------- -------------- ------------- ---------- ---------- 30 SALES CHICAGO 2014-01-01 30 SALES SAN FRANCISCO 2014-01-01
  • 36. 2014 © Trivadis Temporal validity is supported with Multitenant as of 12.1.0.2 In 12.1.0.1 -DDL and DML works -Temporal flashback query filters are applied in a non-CDB instance only No support for temporal joins or temporal GROUP BY FLASHBACK_QUERY_CLAUSE Temporal flashback query filters are not applied on views 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 37 Limitations / Assessment
  • 37. 2014 © Trivadis Core Messages Native Support for Top-N Queries There is no good reason for not using it PL/SQL in SQL Statements If correctly used, very good feature Temporal Validity It’s too soon! 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 38
  • 38. 2014 © Trivadis Questions and answers ... BASEL BERN BRUGG LAUSANNE ZUERICH DUESSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MUNICH STUTTGART VIENNA Christian Antognini Principal Senior Consultant christian.antognini@trivadis.com 18 November 2014 Three in 12c: Row Limiting, PL/SQL WITH SQL and Temporal Validity 40