TH Technology
Analytic Views
for Mortals:
Worth A Look?
When and Where
Karen Cannell
kcannell@thtechnology.com
TH Technology
Thanks to our Sponsors!
Partners
Premier
Logo:
TH TechnologyTH Technology
Analytical Views for Mortals …
• Oracle Analytical Views
• How to Build, How to Query
• Not Just for OLAP and BI
TH TechnologyTH Technology
About Me …
• TH Technology – Oracle Consulting Services, APEX Focus
• Mechanical/SW Engineer - Analyzed, designed,
developed, converted, upgraded, enhanced legacy &
database applications for 30+ years
• Building Web/APEX applications for government, medical,
engineering industries since HTMLDB beginnings
• Leveraging Oracle 10g,11g,12c,18 suite of tools
• Editor Emeritus, ODTUG Technical Journal
• Oracle Ace
• APress Author
• ODTUG Director
TH Technology
TH TechnologyTH Technology
About You …
• Oracle Technology ?
• OLAP Users?
• APEX Users ?
• Why Are You Here?
Analytics …
TH TechnologyTH Technology
Agenda
• What Are Analytical Views
• How to Build
• How to Query
• Who ~ Why ~ When ~Where to Use
• Questions ~ Discussion
TH Technology
Analytic
Views:
to BuildWhat ?
TH TechnologyTH Technology
Oracle Objects
• Table
• Data Storage in Rows/Columns
• View - Virtual Table,
• No Data Storage (Stored SQL Query)
• Materialized View
• Stored Query Results
TH TechnologyTH Technology
Analytic View
• No Data Storage
• Organize Data via Dimensional Model
• Navigation, Join, Aggregation,
Calculation Rules Built In
• Complex Object → Simpler Queries
TH TechnologyTH Technology
Analytic Views
• Layer on Top of Star Schema
• Fact Data Included in AV
• Dimensions, Hierarchies Defined in
the AV
• Calculations Defined in the AV
• Metadata Built Into the AV
19
TH Technology
Analytic
Views:
to BuildQuick
Example
Demo
TH Technology
Slide per Bud Endress, Oct 2017
TH TechnologyTH Technology
Analytic Views
• Oracle 12.2 +
• No Cost Feature
• Like a View
• Does Not Store Data
• Query via SQL
• Access Data from Other Objects
• Join Multiple Tables
TH TechnologyTH Technology
Analytic Views
• Simplify SQL for Analytic Queries
• No Joins, No GROUP BYs
• Calculations Defined in Analytic View
• Aggregates ~ Calculations ~ Ranks ~ Forecasts
• Query Calc’d Values from the Analytic View
Make Dimensional, Hierarchical Analyses More Accessible
➔➔➔ Simpler, Faster Development
TH Technology
Analytic
Views:
to BuildHow to
Build
Attr Dimensions
Hierarchies
Analytic Views
TH TechnologyTH Technology
Tools
• Oracle Database 12.2 +
• Oracle XE 18 (When Released)
https://www.oracle.com/database/technologies/appd
ev/xe.html
• SQL Developer
https://www.oracle.com/database/technologies/appdev/sql
-developer.html
• LiveSQL
https://livesql.oracle.com
TH TechnologyTH Technology
Data
• Example Sales History Schema
• Fact Tables:
• SALES, COSTS
• Dimension Tables:
• PRODUCTS, CUSTOMERS,
PROMONTIONS, TIMES
TH TechnologyTH Technology
TH TechnologyTH Technology
Analytic View Objects
ATTRIBUTE DIMENSION
HIERARCHY
Simple SQL
TH TechnologyTH Technology
TH TechnologyTH Technology
System Privileges
• CREATE ANALYTIC VIEW
• CREATE ANY ANALYTIC VIEW
• ALTER ANY ANALYTIC VIEW
• DROP ANY ANALYTIC VIEW
• CREATE ATTRIBUTE DIMENSION
• CREATE ANY ATTRIBUTE DIMENSION
• ALTER ANY ATTRIBUTE DIMENSION
• DROP ANY ATTRIBUTE DIMENSION
• CREATE HIERARCHY
• CREATE ANY HIERARCHY
• ALTER ANY HIERARCHY
• DROP ANY HIERARCHY
TH TechnologyTH Technology
Object Privileges
• SELECT - Query
• READ - Query
• ALTER - Rename
Example grants:
GRANT ALL ON AVDEMO.SALES_AV TO AV_USER2;
GRANT ALTER ON AVDEMO.SALES_AV TO AV_USER3;
TH TechnologyTH Technology
AV Objects
• ATTRIBUTE DIMENSION
• Specifies Data Source, Attributes, Levels
• HIERARCHY
• Organizes Dimensions Hierarchically Order
• ANALYTIC VIEW
• Aggregations, Calculations, Joins of Fact Data
Specified by Attr. Dims, Hierarchies and
Measures Facts and Calcs
TH TechnologyTH Technology
TH TechnologyTH Technology
TH TechnologyTH Technology
Attribute Dimensions
• SH Time
• Base Calendar Year query
• Base Fiscal Year query
• These will be combined into one
Attr Dimension
TH Technology
Sample Time Attr Dimension
TH TechnologyTH Technology
Now Add CLASSIFICATION
TH TechnologyTH Technology
Now Add CLASSIFICATION …
TH TechnologyTH Technology
CLASSIFICATIONS
• Metadata (Documentation)
• Dimensions – Hierarchies – Avs – Members –
Attributes - Measures
• Caption
• Description
• Format_string
• Shortcut Syntax for caption and
description
TH TechnologyTH Technology
Hierarchies
• Reference an Attribute
Dimension
• Organize Dimension Values into
Hierarchies
TH TechnologyTH Technology
SH Hierarchies
• Time
• Products
• Customers
• Channels
• Promotions
TH TechnologyTH Technology
Analytic View DDL Format
CREATE OR REPLACE ANALYTIC VIEW <name>
<classification caption and description>
USING <fact table>
DIMENSION BY ( <list of dimension refs> )
HIERARCHIES ( <list of hierarchy references> )
MEASURES ( <list of measures> )
DEFAULT MEASURE … ;
TH TechnologyTH Technology
TH TechnologyTH Technology
Analytic View – Parts Recap
• USING – Fact Table – Where to start
• DIMENSION BY – What Dimensions Queries on
the AV Will Use
• HIERARCHY – Which Hierarchies Queries Will Use
• MEASURES – Calculations: Sum, LEAD, LAG,
Combinations – What Calculations Are Needed
• CLASSIFICATION – Metadata - the Documentation
• Usually On AV and Measures
TH TechnologyTH Technology
Measures – Time Series
LAG 1 … ACROSS ANCESTOR AT LEVEL YEAR
Previous Year
AVG(sales) … BETWEEN 11 PRECEDING AND CURRENT
MEMBER
12 Month Period
See LiveSQL
Creating Time Series Calculations in Analytic
Views
TH TechnologyTH Technology
AVs w Materialized Views
• Query Rewrite on MVs ==
Performance Gain
• CACHE
TH TechnologyTH Technology
AVs w In Memory
• Base Tables In-Memory ➔
Greater Performance Gain
TH TechnologyTH Technology
Validating Analytic Views
• DBMS_HIERARCHY
• VALIDATE_HIERARCHY
• VALIDATE_ANALYTIC_VIEW
• VALIDATE_CHECK_SUCCESS
• CREATE_VALIDATE_LOG_TABLE
https://docs.oracle.com/en/database/oracle/oracle-
database/12.2/dwhsg/overview-analytic-views.html#GUID-
73BE6787-3590-46FB-86F0-D402C244A687
TH TechnologyTH Technology
How it Works
TH Technology
Analytic
Views:
to Build
How to
Query
TH TechnologyTH Technology
Queries Against Analytic Views
• Simple
• Add Calculated Measures
• Combine Fact and Calculated
Measure
• SHARE_OF
• Drills
TH TechnologyTH Technology
Query Analytic View - Simple
TH TechnologyTH Technology
Query AV + Calculated Measure
TH TechnologyTH Technology
Query AV – Specifics in WHERE
TH TechnologyTH Technology
Drill – Change LEVEL in WHERE
• Change LEVEL in WHERE
TH TechnologyTH Technology
Drill – Change LEVEL in WHERE
TH TechnologyTH Technology
SQL Developer Quick-Start
• SQL Dev 18.1+
• Oracle 12.2+
Amazing!
TH TechnologyTH Technology
Analytic View Data Viewer
TH Technology
Analytic
Views:
to Build
Why ~
When ~
Where
TH TechnologyTH Technology
Use Analytic Views For …
• Data Warehousing
• Extend Star Schema, Dimension
• BI Reporting Systems
• Data Visualization
• Data Analysts
• “BI Lite”
Any Dimensional, Hierarchical Queries
Easier, Faster
TH Technology
Analytic Views
in APEX
Quick Demo – “BI Lite” In APEX
TH TechnologyTH Technology
Transitioning Your Data
• KNOW YOUR DATA
• PLAN
• Star Schema, Constraints
• Dimensions
• Hierarchies
• Let SQL Developer Help
• Test, Timing, Test, Test
TH Technology
Analytic
Views:
Wrapup
to Build
Questions
Discussion
TH TechnologyTH Technology
Analytic Views
• Simpler SQL for Analytic Queries
• Best Performance Gain over Star
Schema, In Memory
• SQL Dev QuickStart
• Faster Route to Data Viz, BI,
“BI-Lite” Implementations
TH TechnologyTH Technology
TH Technology
Comments?
Questions?
Thank You
Evaluations Please!
Karen Cannell
kcannell@thtechnology.com
TH TechnologyTH Technology
Resources
• Analytic Views LiveSQL Demos
https://livesql.oracle.com/apex/livesql/file/tutorial_EDVE861IID1QUD1NIUPU5ALEW.html
• Analytic Views in SH Sample Schema
https://livesql.oracle.com/apex/livesql/file/tutorial_EDVE861IJ168OTUP6ZZ
01MX84.html
• Analytic View Support in SQL Developer
https://www.thatjeffsmith.com/archive/2017/03/oracle-database-12c-release-2-
analytic-views-sql-developer/
• Using Analytic Views
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r2/Analyti
cViews/UsingAVs.html#overview
TH TechnologyTH Technology
Analytic Views
• “Hierarchical / Dimensional
Model Over the Dimension and
Fact Tables of a Star Schema …”
• Best Performance
• Star Schema, In Memory
• W MViews, MViews In Memory
TH TechnologyTH Technology

Utah Geek Events Big Mountain Data: Oracle Analytic Views: Worth It?