Similar documents
After completing this unit, you should be able to: Define the terms

Using JDBC Data Source with DB2

Maintaining Data 3.3.1

IBM DB2 9 Family Fundamentals. Download Full Version :

Department of Computer Science University of Cyprus. EPL342 Databases. Lab 2

Cost Models. the query database statistics description of computational resources, e.g.

C Examcollection.Premium.Exam.58q

SQL Server 2008 Tutorial 3: Database Creation

Fastrack to federated replication

IBM A Assessment: DB2 9 Fundamentals-Assessment. Download Full Version :

Vendor: IBM. Exam Code: C Exam Name: DB Fundamentals. Version: Demo

A REST API processing a.jpeg image with the image provided as a MIME attachment to the JSON message

IBM A Assessment- DB2 9.5 SQL Procedure Developer-Assessment. Download Full Version :

Number: Passing Score: 800 Time Limit: 120 min File Version:

EXAMGOOD QUESTION & ANSWER. Accurate study guides High passing rate! Exam Good provides update free of charge in one year!

IBM DB2 9.5 SQL Procedure Developer. Download Full Version :

Information Systems Engineering. SQL Structured Query Language DDL Data Definition (sub)language

Application-enabling features of DB2 for z/os. June Charles Lewis DB2 for z/os Advisor IBM Mid-Atlantic Business Unit

Oracle Database 10g Express

Hidden Gems of IBM i. Scott Forstie Business Architect, Db2 for Cognitive Systems

SQL: Data De ni on. B0B36DBS, BD6B36DBS: Database Systems. h p:// Lecture 3

An Introduction to Structured Query Language

An Introduction to Structured Query Language

An Introduction to Structured Query Language

C Exam Questions Demo IBM. Exam Questions C

Data Modelling and Databases. Exercise Session 7: Integrity Constraints

Exam Questions C

SQL Data Definition Language: Create and Change the Database Ray Lockwood

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

Introduction to Oracle

IBM EXAM - C DB Fundamentals. Buy Full Product.

SQL Structured Query Language Introduction

DB2 SQL Workshop (Course Code CF12)

Introduction to SQL on GRAHAM ED ARMSTRONG SHARCNET AUGUST 2018

An Introduction to Structured Query Language

An Introduction to Structured Query Language

XML for z/os COBOL Developers

Architecture. Architecture. Introduction to Oracle 10g Express Edition. Help

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

IBM i Version 7.3. Database Administration IBM

DB2 SQL Workshop for Experienced Users (Course Code CF13)

Tables From Existing Tables

DB2 9 DBA exam 731 prep, Part 3: Database access

This document contains information on fixed and known limitations for Test Data Management.

1 INTRODUCTION TO EASIK 2 TABLE OF CONTENTS

HOW TO CREATE AND MAINTAIN DATABASES AND TABLES. By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL

DB Fundamentals Exam.

SQL Data Definition Language

IBM C DB2 9.5 SQL Procedure Developer.

My Favorite Things in DB2 11 for z/os

DB2 9 DBA exam 731 prep, Part 3: Database access

DB2 Temporal tables. Introduction. 19 April Rajesh Venkata Rama Mallina DB2 Z/OS DBA IBM

Creating and Managing Tables Schedule: Timing Topic

Introduction to IBM DB2

Managing Your Database Using Oracle SQL Developer

Create Rank Transformation in Informatica with example

Persistence Designer User s Guide. Version 3.4

SQL Data Definition and Data Manipulation Languages (DDL and DML)

2.9 Table Creation. CREATE TABLE TableName ( AttrName AttrType, AttrName AttrType,... )

Lab # 2 Hands-On. DDL Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement

The SQL Procedure Language (SQL PL)

Chapter 2. DB2 concepts

Database Management Systems,

Basic SQL. Basic SQL. Basic SQL

SQL language. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

Chapter 3: Introduction to SQL. Chapter 3: Introduction to SQL

Keys are fields in a table which participate in below activities in RDBMS systems:

Using MySQL on the Winthrop Linux Systems

A Examcollection.Premium.Exam.47q

Unit 4. Scalar Functions and Arithmetic

EndExam QUESTION & ANSWER. h p:// Accurate study guides, High passing rate! Weofferfreeupdateserviceforoneyear!

SQL: A COMMERCIAL DATABASE LANGUAGE. Complex Constraints

Query Optimization Overview

IBM DB2 UDB V7.1 Family Fundamentals.

Meet MariaDB Vicențiu Ciorbaru Software MariaDB Foundation * * 2017 MariaDB Foundation

SELF TEST. List the Capabilities of SQL SELECT Statements

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Database Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Using SQL Developer. Oracle University and Egabi Solutions use only

Teach Yourself InterBase

Data Modelling and Multimedia Databases M

Database Design. 1-3 History of the Database. Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Working with Columns, Characters and Rows. Copyright 2008, Oracle. All rights reserved.

The attendee will get a deep dive into all the DDL changes needed in order to exploit DB2 V10 Temporal tables as well as the limitations.

Data Modelling and Multimedia Databases M

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas

School of Computing and Information Technology Session: Spring CSCI835 Database Systems (Bridging Subject) Sample class test 23 July 2018

Db2 Alter Table Alter Column Set Data Type Char

Careerarm.com. 1. What is MySQL? MySQL is an open source DBMS which is built, supported and distributed by MySQL AB (now acquired by Oracle)

IBM DB2 9 Application Developer. Practice Test. Version 1.1.

OpenEdge Change Data Capture and the ETL Process WHITEPAPER AUTHOR : LAKSHMI PADMAJA

Apparo Fast Edit. Database configuration for the Apparo repository and others 1 / 20

Exam Questions C

IBM DB2 9.7 SQL Procedure Developer.

Db2 Sql Alter Table Add Column Default Value

IBM EXAM QUESTIONS & ANSWERS

Hyperion Interactive Reporting Reports & Dashboards Essentials

OneStop Reporting 4.5 OSR Administration User Guide

Transcription:

tdb2temporalmergeelt Purpose http://www.cimt-ag.de This component carries out the creation and fill procedure for Temporal Tables in the IBM DB2. Temporal Tables are introduced with DB2 v10 and provides mechanism to keep historical data in two time possible time dimensions: 1. Business Time period is the time range within the data a valid from a business perspective. The business time period is optional. 2. System Time period is the time range, which reflects the technical creation and modification of the data. The system time period will be automatically defined by timestamps of the database management system and is mandatory. If a table use both time periods it s called bi-temporal table. To get a better idea about this concept please refer to this web resource: http://www.ibm.com/developerworks/data/library/techarticle/dm-1204db2temporaldata/ Talend-Integration This component can be found in the palette under Database -> DB2 and Business Intelligence -> DB SCD. Parameters Connection configuration: Property Property Type Choose the database connection from the Metadata or use the build-in mode to setup individual configurations. (Only if use want to establish a dedicated connection for this component) Use existing connections True: choose an existing connection component in your job False: configure its own connection. Host Host (IP address or hostname) of your DB2 server. Required Port Port where the instance is listening. Default is 50000. Additional JDBC Parameters Database Source DB Schema Username Password Set here semicolon separated list of key=value pairs with JDBC parameters. The default pair in this component is: retrievemessagesfromserverongetmessage=true which cause in case of errors a readable error message instead of getting only the SQLCODE. The database you want to work with The database schema containing the source table. User name Password of the user

Source configuration: Property Source table Where condition Schema from input table Use self defined source key Track updates for all columns Supplementary Source Column Config Name (without schema) of the source table. The name will be set automatically if you drag and drop the component from a metadata table. The condition to select the source datasets. The keyword where is not needed here (it will be added in the SQL code generation in case of this attribute is not empty). Talend Schema chooser for the input table. The component can take the keys from the input schema. In case of there are no keys defined in this schema (e.g. the source table is probably a view) it is possible to define the keys which are part of the source key. It is necessary to have at least one input field declared as source key. Source key field will not update and will be used to find a single unique dataset. If this option is checked, all datasets which source key already exists in the target table causes an update and a versioning of the previous dataset (regardless if it was a real change or not). It is recommended using this option if the source provides only changed datasets (e.g. with a source selection by last modified timestamps). Per source column you can specify: Ignore: If true the column will be ignored. This is helpful if you prefer using a schema from the repository and it contains not needed columns. Track real changes for: This cause the component to track real changes of this field. Visible only if the option Track updates for all columns is switched off. Is source key: Check all columns, which identifies a unique source dataset. Visible only of option Use self defined source key is enabled. Target configuration: Property Target DB Schema Target table Database schema for the target table. Name (without schema) of the target table. Create table if not exists If the table (and its historical counterpart) does not exist, it will be created. Create indexes for source key, bus-tp, sys-tp Use a specific table space Tablespace name Surrogate Key column Use Business Timeperiod Business Timeperiod is of data type Date Business Timeperiod Start Column Business Timeperiod End Column Value Start BUS time Value End BUS time (insert) In addition to the creation of the table, also indexes on the source keys, on the business time period columns (if needed) and on the system time period columns for the target table will be created. If the target table should created within a specific table space, this table space will be created if needed in case of the table have to be created. Name of the table space in which the target table should be created. If set, a surrogate key will be added to the target table and configured as auto increment column with type BIGINT. If this option is switch on, the table and fill method a carry out a bi-temporal versioning of data. If switched on the business time period columns will work with days and ignores the time (set the time to 00:00:00) Name of the column holding the start date/timestamp of the business time period. Typically in data warehouse projects it is needed to follow project specific naming conventions for those kinds of fields. Name of the column holding the end date/timestamp of the business time period. Typically in data warehouse projects it is needed to follow project specific naming conventions for those kinds of fields. The value (as literal or a context variable) which defines the start of the business time period (timestamp or day). The value has to be of a data type inheriting java.util.date. The value (as literal or a context variable), which defines the end of the business, time period (timestamp or day) in case of insert a new data set. The value has to be of a data type inheriting java.util.date.

Value End BUS time (update) System Timeperiod Start Column System Timeperiod End Column Set history table append on Switch Off Versioning at the End Additional Columns in Target Table Delete condition Return values In case of days, this has typically 2 different values depending the situation: The value should point to a date in the far future (like a SCD end value to specify the current valid dataset). The value (as literal or a context variable), which defines the end of the business, time period (timestamp or day) in case of update an existing data set. The value has to be of a data type inheriting java.util.date. In case of days, this has typically 2 different values depending the situation: The value should contains the next time slice (e.g. the next day) after the start value of the business time period. Name of the column for the system time period start. Name of the column for the system time period end. With this option the history table can be set as append on. This option increases the performance in case of many updates. Especially in data ware house applications it is a common task to update foreign key fields in the target table or converting / transforming special values. To avoid creating historical datasets by this post processing it is possible to switch off the versioning feature at the end. Every new run of this component will switch on the versioning in case of it is switched off. If additional columns are needed (e.g. meta data columns like job instance keys, processing information and so on) it is possible to specify them here and they values. As values can be used literals or context variables matching the data type of the added column. It is possible to enable the column for the insert or update statement. If the source data contains info to mark the data for delete you can specify the condition here. It will cause an additional part of the merge statement to delete if the dataset exists and the delete condition is true. Return value ERROR_MESSAGE COUNT_MERGED Last error message Number of datasets actually merged by the component

Scenario: Bi-temporal processing of the EMPLOYEE table from the DB2 examples The component creates its own database connection and carries out a bi-temporal versioning.

Statements created by the component Create target tables and indices -- create tablespace create tablespace TBLSP_EMPLOYEE; -- create table create table DWH_ODS.EMPLOYEE ( TRANS_START TIMESTAMP(12), DWH_BUS_VALID_FROM DATE NOT NULL, DWH_BUS_VALID_TO DATE NOT NULL, DWH_SYS_VALID_FROM TIMESTAMP(12) NOT NULL, DWH_SYS_VALID_TO TIMESTAMP(12) NOT NULL, SKEY BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1), EMPNO CHAR(6) NOT NULL, FIRSTNME VARCHAR(12) NOT NULL, MIDINIT CHAR(1), LASTNAME VARCHAR(15) NOT NULL, WORKDEPT CHAR(3), PHONENO CHAR(4), HIREDATE DATE, JOB CHAR(8), EDLEVEL SMALLINT NOT NULL, SEX CHAR(1), BIRTHDATE DATE, SALARY DECIMAL(9,2), BONUS DECIMAL(9,2), COMM DECIMAL(9,2), JOB_INSTANCE_ID BIGINT ) in TBLSP_EMPLOYEE; -- setup table as temporal table alter table DWH_ODS.EMPLOYEE alter column TRANS_START set GENERATED ALWAYS AS TRANSACTION START ID; alter table DWH_ODS.EMPLOYEE alter column TRANS_START set IMPLICITLY HIDDEN; alter table DWH_ODS.EMPLOYEE alter column DWH_SYS_VALID_FROM set GENERATED ALWAYS AS ROW BEGIN; alter table DWH_ODS.EMPLOYEE alter column DWH_SYS_VALID_TO set GENERATED ALWAYS AS ROW END; alter table DWH_ODS.EMPLOYEE add PERIOD SYSTEM_TIME (DWH_SYS_VALID_FROM,DWH_SYS_VALID_TO); alter table DWH_ODS.EMPLOYEE add PERIOD BUSINESS_TIME (DWH_BUS_VALID_FROM,DWH_BUS_VALID_TO); alter table DWH_ODS.EMPLOYEE add constraint EMPLOYEE_pk primary key (EMPNO, BUSINESS_TIME WITHOUT OVERLAPS); -- create index for source key create index DWH_ODS.EMPLOYEE_src_pk on DWH_ODS.EMPLOYEE(EMPNO); -- create index for business time period create index DWH_ODS.EMPLOYEE_bustp on DWH_ODS.EMPLOYEE(DWH_BUS_VALID_FROM,DWH_BUS_VALID_TO); -- create index for system time period create index DWH_ODS.EMPLOYEE_systp on DWH_ODS.EMPLOYEE(DWH_SYS_VALID_FROM,DWH_SYS_VALID_TO); -- create history table create table DWH_ODS.EMPLOYEE_HIST like DWH_ODS.EMPLOYEE in TBLSP_EMPLOYEE; alter table DWH_ODS.EMPLOYEE_HIST append on; -- switch on versioning alter table DWH_ODS.EMPLOYEE add versioning use history table DWH_ODS.EMPLOYEE_HIST; Statement to switch on the versioning if it was switch off -- switch on versioning ALTER TABLE DWH_ODS.EMPLOYEE ADD VERSIONING USE HISTORY TABLE DWH_ODS.EMPLOYEE_HIST After the completing the processing (after the merge statement) and if the option to switch off the versioning at the end is on: -- switch off versioning ALTER TABLE DWH_ODS.EMPLOYEE DROP VERSIONING

Merge statement -- merge merge into DWH_ODS.EMPLOYEE t using ( select * from DB2INST2.EMPLOYEE where SEX='M' ) s on (t.empno = s.empno and t.dwh_bus_valid_to >?/*#1 business_time_start */ ) when not matched and not (s.job is null) then insert ( DWH_BUS_VALID_FROM, DWH_BUS_VALID_TO, EMPNO, FIRSTNME, MIDINIT, LASTNAME, WORKDEPT, PHONENO, HIREDATE, JOB, EDLEVEL, SEX, BIRTHDATE, SALARY, BONUS, COMM, JOB_INSTANCE_ID) values (?/*#2 business_time_start */, '9999-12-30', s.empno, s.firstnme, s.midinit, s.lastname, s.workdept, s.phoneno, s.hiredate, s.job, s.edlevel, s.sex, s.birthdate, s.salary, s.bonus, s.comm,?/*#3 JOB_INSTANCE_ID*/) when matched and ( (t.firstnme <> s.firstnme) or (t.midinit <> s.midinit) or (t.lastname <> s.lastname) or (t.workdept <> s.workdept) or (t.phoneno <> s.phoneno) or (t.hiredate <> s.hiredate) or (t.birthdate <> s.birthdate) or (t.salary <> s.salary) or (t.bonus <> s.bonus) or (t.comm <> s.comm) ) and not (s.job is null) then update for portion of business_time from?/*#4 business_time_start */ to '9999-12-30' set t.firstnme = s.firstnme, t.midinit = s.midinit, t.lastname = s.lastname, t.workdept = s.workdept, t.phoneno = s.phoneno, t.hiredate = s.hiredate, t.job = s.job, t.edlevel = s.edlevel, t.sex = s.sex, t.birthdate = s.birthdate, t.salary = s.salary, t.bonus = s.bonus, t.comm = s.comm, t.job_instance_id =?/*#5 JOB_INSTANCE_ID*/ when matched and (s.job is null) then delete for portion of business_time from?/*#6 business_time_start */ to '9999-12-30'