Date post: | 26-Aug-2018 |
Category: |
Documents |
Upload: | phungquynh |
View: | 227 times |
Download: | 1 times |
© 2017 IBM Corporation
What's New in DB2 for i(in June, 2017)
Sarah Mackenzie
For…
© 2017 IBM Corporation
™
2
DB2 for i
• Standard compliant• Secure• Scalable• Functionally Advanced• Excellent Performance • Easier to use• Easier to maintain
V5R2
SQE Stage 1
IASPs
Identity columns
Savepoints
UNION in views
Scalar subselect
UDTFs
DECLARE GLOBAL TEMPORARY TABLE
Catalog views
V5R3
Partitioned tables
UFT-8 & UTF-16
ICU sort sequence
MQTs
Sequences
Implicit char/numeric
BINARY / VARBINARY
GET DIAGNOSTICS
DRDA Alias
DECIMAL(63)
SQE Stage 3
Ragged SWA
QDBRPLAY
Online Reorganize
7.1
XML Support
Encryption enhancements (FIELDPROCs)
Result set support in embedded SQL
CURRENTLY COMMITTED
MERGE
Global variables
Array support in procedures
Three-part names and aliases
SQE Logical file support
SQE Adaptive Query Processing
EVI enhancements
Inline functions
CREATE OR REPLACE
Partition table enhancements
Expressions in CALL
TR-timed enhancements
V5R4
WebQuery
SSD Media Preference
On Demand Performance Center
Health Center
Completion of SQL Core
Scalar fullselect
Recursive CTE
OLAP expressions
INSTEAD OF triggers
Descriptor area
XA support
DDM 2-phase
Scrollable cursor
2M SQL statement
1000 tables in a query
7.2
Row and Column Access Control
XMLTABLE
CONNECT BY
TRANSFER OWNERSHIP
TRUNCATE
More SQL Scalar functions
Named arguments and defaults for parameters
Obfuscation of SQL routines
Array support in UDFs
Timestamp precision
Multiple-action Triggers
Built-in Global Variables
1.7 Terabyte Indexes
Navigator Graphs and Charts
Regular Expressions
SQL Dynamic Compound
UPDATE ROW across partitions
System Limits - IFS
6.1
Omnifind
MySQL storage engine
DECFLOAT
Grouping sets / super groups
INSERT in FROM
VALUES in FROM
Extended Indicator Variables
Expression in Indexes
ROW CHANGE TIMESTAMP
Statistics catalog views
CLIENT special registers
SQE Stage 6
DDM and DRDA IPv6
Deferred Restore of MQT and Logicals
Environmental limits
7.3
Temporal Tables
Generated columns for auditing
OLAP Extensions
OFFSET and LIMIT
Inline User-Defined Table Functions
New Aggregate Functions
Index Merge Ordering
EVI Only Access
More Built-in Global Variables
More SQL Scalar functions
Increased routine and view limits
More Services
CREATE OR REPLACE TABLE
ATTACH & DETACH Partition
Pipelined Table Functions
© 2017 IBM Corporation
™
Prioritization Formula
3
We use customer value, cost and risk
to guide our decisions regarding enhancements
Enhancements explained here:
www.ibm.com/developerworks/ibmi/techupdates/db2
© 2017 IBM Corporation
™
Requests For Enhancement
4
Levy your requirement, vote on Open requirements:
http://ibm.biz/IBMi_RFE
How-to Article:
https://www.ibm.com/developerworks/ibmi/library/i-ibm-rfe-trs/
Most
Popular
Database
RFE
© 2017 IBM Corporation
™
7
Which release should you choose?
Enhancements in IBM i 7.2
• Database performance
SQE handles Native DB access
New I/O Costing Model
EVI Only Access
• Data-centric security
Row & Column Access Control
for SQL and DDS file
• Developer productivity
Default parameters on functions
Built-in Global Variables
Many other improvements
• Workload insight
Improved SQL Plan Cache
Performance Data Perspectives
Enhancements in IBM i 7.3
• Data-centric history
System-period Temporal table support for
SQL tables and DDS created physical files
• Data-centric accountability
Generated columns for SQL and DDS files
Authority Collection to avoid excess
authority
• On-Line Analytical Processing (OLAP)
New OLAP built-in functions
Improved capabilities for DB2 Web Query,
Cognos Analytics and other BI tools
• Improved value from priced options
DB2 SMP – Parallel execution of OLAP
DB2 Multisystem – Attach/Detach
partitions
© 2017 IBM Corporation
™
Data Security … an area of continuous investment
7.1 and
earlier
………i next
…
2010 2011 2013 20142012 20162015
7.37.2
• Generated Columns for Auditing
• Authority Collection
• Row Permissions• Column Masks• Query journals
with SQL• Function Usage
• Field Procedures• Guardium Database Activity
Monitor• Guardium Vulnerability
Assessment• Guardium Classifier
2017
8
© 2017 IBM Corporation
™
Temporal Tables in IBM i 7.3
TS
U
RB
D
I
D
I
History TABLE RECH
G
US
R
Tom
Nick
Tom
Jim
Jim
Temporal TABLE RB RE TSCH
G
I
U
I
USR
Tom
Tom
Nick
---- Who deleted this customer? -- Get that row back!--SELECT USER_NAME, C.* FROM CUSTOMERS C
FOR SYSTEM_TIME BETWEEN '0001-01-01' AND '9999-12-30' WHERE AUDIT_OP = 'D' AND CUSTNO = '102901'
DB2 Managed
9
© 2017 IBM Corporation
™
Temporal Enablement Example
ALTER TABLE accountADD COLUMN row_birth
TIMESTAMP(12) NOT NULL IMPLICITLY HIDDENGENERATED ALWAYS AS ROW BEGIN
ADD COLUMN row_deathTIMESTAMP(12) NOT NULL IMPLICITLY HIDDENGENERATED ALWAYS AS ROW END
ADD COLUMN transaction_timeTIMESTAMP(12) IMPLICITLY HIDDENGENERATED ALWAYS AS TRANSACTION START ID
ADD PERIOD SYSTEM_TIME (row_birth, row_death);
CREATE TABLE account_hist LIKE account;
ALTER TABLE account ADD VERSIONING USE HISTORY TABLE account_hist;
10
© 2017 IBM Corporation
™
Generated Columns for Auditing
ALTER TABLE accountADD COLUMN audit_type_change CHAR(1)
GENERATED ALWAYS AS (DATA CHANGE OPERATION) ADD COLUMN audit_user VARCHAR(128)
GENERATED ALWAYS AS (SESSION_USER) ADD COLUMN audit_client_IP VARCHAR(128)
GENERATED ALWAYS AS (SYSIBM.CLIENT_IPADDR)ADD COLUMN audit_job_name VARCHAR(28)
GENERATED ALWAYS AS (QSYS2.JOB_NAME) ;
11
• DB2 for i can track auditing of row-level changes
• Add generated columns to SQL Tables & DDS Created Physicals
• No need to change applications
© 2017 IBM Corporation
™
DB2 for IBM i Lab Services
12
• Facilitated workshops covering current state, requirements, future state,
possible solutions, implementation best practices, and formulation of a
strategic roadmap:
RCAC
Temporal Tables
• Customized consulting workshops
Advanced SQL and Data-centric Programming
SQL Performance Best Practices, Monitoring and Tuning
• Consulting on any DB2 for i topic
For more information, contact Mike Cain at [email protected]
© 2017 IBM Corporation
™
www.ibm.com/developerworks/ibmi/techupdates/db2
2016 2017
SF99702 Level 11SF99703 Level 1
Enhancements in 2Q/2016
• Inlined UDTFs
• Trigger (re)deployment
• More IBM i Services
• New DB2 built-in Global
Variables
• Enhanced SQL Scalar
functions
• Evaluation option for
DB2 SMP &
DB2 Multisystem
7.2 – TR47.3 – GA
7.2 – TR57.3 – TR1
7.2 – TR67.3 – TR2
Enhancements in 1Q/2017
• Performance Improvements
• JSON predicates
• More Database features in ACS
• New and enhanced SQL Scalar
Functions
• New IBM i Services
• Enhanced DB2 for i Services
• And more…
SF99702 Level 14SF99703 Level 3
Enhancements in 4Q/2016
• JSON_TABLE()
• INCLUDE for SQL
Routines
• Database features in ACS
• Faster Scalar Functions
• More IBM i Services
• New DB2 for i Services
• And more…
SF99702 Level 16SF99703 Level 4
13
Enhancements delivered via DB2 PTF Groups
© 2017 IBM Corporation
™
JSON support in DB2 for i
DB2 JSON Store
June
2015
IBM i 7.1,
7.2, & 7.3
JSON_TABLE()
November
2016
IBM i 7.2 & 7.3
JSON Query support:
Predicates:
• IS JSON
• JSON_EXISTS
March
2017
IBM i 7.2 & 7.3
© 2017 IBM Corporation
™
JSON_TABLE
“The powerful JSON_TABLE function”
http://www.ibm.com/developerworks/ibmi/library/i-json-table-trs/index.html
• Allows queries to process
JSON as relational data
• Leverage HTTP functions to
tap external JSON data
sources
• Conceptually similar to
XML_TABLE
© 2017 IBM Corporation
™
• Once the feed is discovered, consumption is simple
• JSON_TABLE() requires a valid JSON object
CREATE OR REPLACE VARIABLE towed_vehicles
CLOB(1G) CCSID 1208 ;
SET towed_vehicles = '{ "stuff" :' concat
systools.HTTPGETCLOB(
'https://data.cityofchicago.org/resource/rp42-fxjt.json',
'')
concat '}';
18
JSON and the City of Chicago
© 2017 IBM Corporation
™
SELECT TOW_DATE,
DAYNAME(TOW_DATE) AS DAYNAME,
COUNT(*) AS TOW_COUNT
FROM JSON_TABLE(towed_vehicles,
'lax $.stuff[*]'
COLUMNS(TOW_DATE DATE PATH '$."tow_date"')) x
GROUP BY TOW_DATE
ORDER BY TOW_COUNT DESC;
19
JSON and the City of Chicago
© 2017 IBM Corporation
™
JSON – IS JSON query predicate
• IS or IS NOT JSON
– The IS JSON predicate determines whether a value is in a JSON format
with the specified attributes
– VALUE, ARRAY, OBJECT, or SCALAR checking
-- Use a trigger to validate JSONCREATE TRIGGER VALIDATE_JSON BEFORE INSERT OR UPDATE OF JSON_DATA ON MYTABLEREFERENCING NEW AS NFOR EACH ROW MODE DB2ROWIF N.JSON_DATA IS NOT JSON OBJECT THENIF INSERTING THEN
SIGNAL SQLSTATE '75007'('INSERT failed due to invalid JSON');
ELSE SIGNAL SQLSTATE '75007'
(‘UPDATE failed due to invalid JSON');END IF;
END IF;
© 2017 IBM Corporation
™
JSON – JSON_EXISTS query predicate
• JSON_EXISTS
– JSON_EXISTS predicate is true if at least one value can be located
– COALESCE or IFNULL can be used to identify/process NULL values
– FALSE ON ERROR, TRUE ON ERROR, UNKNOWN ON ERROR, or
ERROR ON ERROR processing options
-- Identify the employees who do not have -- at least one emergency contact.SELECT empno, lastname FROM employeeWHERE NOT JSON_EXISTS(COALESCE(json_data, ''), 'strict $.emergency' FALSE ON ERROR);
© 2017 IBM Corporation
™
• SQL alternative to the Display Object Authority (DSPOBJAUT) command
-- description: Review authorities for a userSELECT * FROM QSYS2.OBJECT_PRIVILEGES WHERE OBJECT_NAME = 'FRANKDBA' AND
SYSTEM_OBJECT_SCHEMA = 'QSYS' AND OBJECT_TYPE = '*USRPRF';
OBJECT_PRIVILEGES
© 2017 IBM Corporation
™
• Alternative to the Display Authorization List (DSPAUTL) command
---- description: List the public security settings -- for all authorization lists--SELECT *
FROM QSYS2.AUTHORIZATION_LIST_USER_INFOWHERE AUTHORIZATION_NAME = '*PUBLIC';
AUTHORIZATION_LIST_USER_INFO
© 2017 IBM Corporation
™
• Alternative to Display Authorization List Objects (DSPAUTLOBJ) command
-- description: Count the types of objects tracked-- by all non-IBM authorization lists--SELECT AUTHORIZATION_LIST, SYSTEM_OBJECT_TYPE, OBJECT_TYPE, COUNT(SYSTEM_OBJECT_TYPE)
FROM qsys2.authorization_list_infoWHERE AUTH_LIST NOT LIKE 'Q%'GROUP BY AUTHORIZATION_LIST, SYSTEM_OBJECT_TYPE,
OBJECT_TYPE ORDER BY 1,4 DESC;
AUTHORIZATION_LIST_INFO
© 2017 IBM Corporation
™
• Extract detail from message queues, including QSYSOPR
-- Examine all inquiry messages with responsesSELECT a.message_text AS “INQUIRY”,
b.message_text AS “REPLY”FROM qsys2.message_queue_info a INNER JOIN
qsys2.message_queue_info bON a.message_key = b.associated_message_keyORDER BY b.message_timestamp DESC;
MESSAGE_QUEUE_INFO
© 2017 IBM Corporation
™
• QSYS2.USER_INFO – Add Supplement Group detail
• QSYS2.LICENSE_INFO – Add install detail
• SYSTOOLS.LICENSE_EXPIRATION_CHECK – Automate checking
And yet more services…
© 2017 IBM Corporation
™
• LISTAGG – Aggregates a set of string values for the group
into one string by appending the string-expression
-- Produce a list of comma-separated namesSELECT workdept, LISTAGG(lastname, ',') WITHIN GROUP(ORDER BY lastname) AS employees
FROM employee GROUP BY workdept
New SQL Built-in Function
© 2017 IBM Corporation
™
• LTRIM & RTRIM – Add optional 2nd parameter (trim-expression)
-- Left Trim more than blanksvalues LTRIM(' $ 10.40', '$ ') '10.40'
-- Remove outer noisevalues RTRIM(
LTRIM('""Snazzy^--"', '"-^') , '-"^'); 'Snazzy'
Enhanced SQL Built-in Function
© 2017 IBM Corporation
™
• 2,000+ Pages of fun!
• Updated twice per year
Find it here…
30
http://ibm.biz/DB2fori_SQLreference
SQL Reference
© 2017 IBM Corporation
™
ACS Version 1.1.7.0
• Run SQL Scripts
– CL Prompting
– Enhanced SQL Highlighting
– Show Object References
– Upload Results
– More “Insert from Examples”
• Printer Output
– Multiple User Filter
• IFS
– Filter
• Schemas
Database Tooling
© 2017 IBM Corporation
™
Schemas in ACS
Supported Actions:
• Definition
• Description
• Generate SQL
• Properties
• Rename
• New Database Object
• Explain
• Data
o View
o Clear
o Copy
o Initialize
• More to come…
• Actions also enabled in
Visual Explain
© 2017 IBM Corporation
™
38
• Which day where the most cars towed on?
Watson Analytics and DB2 for i – Visualizing Data
© 2017 IBM Corporation
™
39
Watson Analytics and DB2 for i – Visualizing Data
• Where were out-of-state cars that were towed originally from?
© 2017 IBM Corporation
™
40
Watson Analytics and DB2 for i Data –Understanding Relationships & Identifying Patterns
Data Source –
Daily ‘L’ Train ridership by station
© 2017 IBM Corporation
™
41
Watson Analytics and DB2 for i Data –Understanding Relationships & Identifying Patterns
© 2017 IBM Corporation
™
42
SELECT q.*,
systools.translate_english_to_spanish(q.quote)
AS "QUOTE_IN_España"
FROM session.famous_quotes q;
Using SQL to ask Watson a question