DDL or DDS? A comparison of tools used to define data on the System i. By Robert Berendt



Similar documents
4 Simple Database Features

Intro to Embedded SQL Programming for ILE RPG Developers

Chapter 4. SQL Concepts & Facilities. Is SQL an End User Tool? AS/400 ANSI SQL Advanced Facilities

Oracle Database 10g Express

IBM Power Systems Software. The ABCs of Coding High Performance SQL Apps DB2 for IBM i. Presented by Jarek Miszczyk IBM Rochester, ISV Enablement


Maintaining Stored Procedures in Database Application

Embedding SQL in High Level Language Programs

Databases What the Specification Says

5.1 Database Schema Schema Generation in SQL

Working with DB2 UDB objects

Create a Database Driven Application

ERserver. DB2 Universal Database for iseries SQL Programming with Host Languages. iseries. Version 5

Conventional Files versus the Database. Files versus Database. Pros and Cons of Conventional Files. Pros and Cons of Databases. Fields (continued)

DbSchema Tutorial with Introduction in SQL Databases

Using SQL Server Management Studio

Optimizing Performance. Training Division New Delhi

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model

Introduction to SQL and database objects

MS SQL Performance (Tuning) Best Practices:

Database Administration with MySQL

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

Fundamentals of Database Design

Database Migration from MySQL to RDM Server

CSI 2132 Lab 3. Outline 09/02/2012. More on SQL. Destroying and Altering Relations. Exercise: DROP TABLE ALTER TABLE SELECT

SQL Programming. CS145 Lecture Notes #10. Motivation. Oracle PL/SQL. Basics. Example schema:

A basic create statement for a simple student table would look like the following.

DB2 for i. Analysis and Tuning. Mike Cain IBM DB2 for i Center of Excellence. mcain@us.ibm.com

DBMS / Business Intelligence, SQL Server

Database Programming with PL/SQL: Learning Objectives

DB2 for i5/os: Tuning for Performance

Application Development Guide: Programming Server Applications

5. CHANGING STRUCTURE AND DATA

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

NEMUG Feb Create Your Own Web Data Mart with MySQL

Chapter 9 Java and SQL. Wang Yang wyang@njnet.edu.cn

Chapter 1: Introduction. Database Management System (DBMS) University Database Example

SQL Server An Overview

Oracle Database 10g: Introduction to SQL

Oracle 10g PL/SQL Training

SQL Basics for RPG Developers

SQL Simple Queries. Chapter 3.1 V3.0. Napier University Dr Gordon Russell

LOBs were introduced back with DB2 V6, some 13 years ago. (V6 GA 25 June 1999) Prior to the introduction of LOBs, the max row size was 32K and the

Lecture 6. SQL, Logical DB Design

IT2305 Database Systems I (Compulsory)

Performance Tuning for the Teradata Database

CSC 443 Data Base Management Systems. Basic SQL

1.264 Lecture 11. SQL: Basics, SELECT. Please start SQL Server before each class

SQL NULL s, Constraints, Triggers

Embedded SQL programming

The Relational Model. Why Study the Relational Model?

14 Triggers / Embedded SQL

SQL Server for developers. murach's TRAINING & REFERENCE. Bryan Syverson. Mike Murach & Associates, Inc. Joel Murach

Physical Database Design and Tuning

W I S E. SQL Server 2008/2008 R2 Advanced DBA Performance & WISE LTD.

Performance rule violations usually result in increased CPU or I/O, time to fix the mistake, and ultimately, a cost to the business unit.

SQL Data Definition. Database Systems Lecture 5 Natasha Alechina

1. Physical Database Design in Relational Databases (1)

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

IT2304: Database Systems 1 (DBS 1)

There are four technologies or components in the database system that affect database performance:

The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

How To Improve Performance In A Database

Advanced SQL. Jim Mason. Web solutions for iseries engineer, build, deploy, support, train

How To Create A Table In Sql (Ahem)

Review: Participation Constraints

Programming with SQL

Information Systems SQL. Nikolaj Popov

Guide to Upsizing from Access to SQL Server

Instant SQL Programming

Database Query 1: SQL Basics

2. Oracle SQL*PLUS Winter Some SQL Commands. To connect to a CS server, do:

not at all a manual simply a quick how-to-do guide

Creating Database Tables in Microsoft SQL Server

Top 10 Oracle SQL Developer Tips and Tricks

Using Temporary Tables to Improve Performance for SQL Data Services

Chapter 6: Physical Database Design and Performance. Database Development Process. Physical Design Process. Physical Database Design

Chapter 9, More SQL: Assertions, Views, and Programming Techniques

Section of DBMS Selection & Evaluation Questionnaire

CSCE 156H/RAIK 184H Assignment 4 - Project Phase III Database Design

Database DB2 Universal Database for iseries Embedded SQL programming

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

Guide to SQL Programming: SQL:1999 and Oracle Rdb V7.1

Embedded SQL. Unit 5.1. Dr Gordon Russell, Napier University

Introduction to Triggers using SQL

Programming Database lectures for mathema

Introduction to SQL ( )

Application Development With Data Studio

CSE 530A Database Management Systems. Introduction. Washington University Fall 2013

Physical File. Collection or Schema

4 Logical Design : RDM Schema Definition with SQL / DDL

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. Introduction to Databases. Why databases? Why not use XML?

!"# $ %& '( ! %& $ ' &)* + ! * $, $ (, ( '! -,) (# *&23. mysql> select * from from clienti;

MOC 20461C: Querying Microsoft SQL Server. Course Overview

DB2 V8 Performance Opportunities

InterBase 6. Embedded SQL Guide. Borland/INPRISE. 100 Enterprise Way, Scotts Valley, CA

Geodatabase Programming with SQL

Using the Query Analyzer

iseries SQL Programming: You ve Got the Power!

Transcription:

DDL or DDS? A comparison of tools used to define data on the System i. By Robert Berendt

Data Definition Specifications UNIQUE R ITEMMASTR ITEMNBR 17A COMP(NE ' ') ITEMCLAS 2A COMP(NE ' ') PRICE 9P 2 COMP(GT 0) K ITEMNBR

UPDDTA on DDS file

SQL against DDS file INSERT INTO ROB/ITEMMAST VALUES(' ', ' ', -5) 1 rows inserted in ITEMMAST in ROB.

inav against DDS file

DDL defined file CREATE TABLE ROB/DDLMAST (ITEMNBR CHAR (17 ) NOT NULL WITH DEFAULT, PRIMARY KEY (ITEMNBR), CHECK (ITEMNBR<>' ' ), ITEMCLAS CHAR (2 ) NOT NULL WITH DEFAULT, CHECK (ITEMCLAS<>' ' ), PRICE DECIMAL (9, 2) NOT NULL WITH DEFAULT, CHECK (PRICE>0 )) RCDFMT DDLMASTR

SQL against DDL file INSERT INTO ROB/DDLMAST VALUES(' ', ' ', -5) INSERT or UPDATE not allowed by CHECK constraint.

inav against DDL file

SQL and DDS Data Validation Differences The major difference between these two types of physical database objects is the process that determines when the data is validated. For DDS, the data is validated as data is read through the open cursor. For SQL, data is validated as it is written through the open cursor.

SQL and DDS Data Validation Differences

DSPPFM of DDS file

DDS: No check on write CRTPF BADDATA RCDLEN(24) *...+...1...+...2... XXXXXXXXXXXXXXXXXXXXXXXX CPYF FROMFILE(BADDATA) TOFILE(ITEMMAST) MBROPT(*ADD) FMTOPT(*NOCHK)

DDS: Now has bad data...+...1...+...2...+...3...+...4.. ITEMNBR ITEMCLAS PRICE A 8.00-5.00- XXXXXXXXXXXXXXXXX XX +++++++++++++

Not on DDL file CPYF FROMFILE(BADDATA) TOFILE(ddlMAST) MBROPT(*ADD) FMTOPT(*NOCHK) Data mapping error on member DDLMAST. Data mapping error on member DDLMAST. C Cancel reply received for message CPF5029. Error writing to member DDLMAST in file DDLMAST. 0 records copied to DDLMAST in ROB.

Performance enhancements Many applications have an average of 25 reads to every write. If you move the validity checking to write time, performance will be better. DDL defaults to REUSEDLT, or reuse deleted records. Allows concurrent write support.

Performance enhancements (cont) DDL defined files will have a 64K page size vs 8-32K page size from DDS.

Source? Store in QDDSSRC, compile with RUNSQLSTM

What about column headings? UNIQUE R ITEMMASTR ITEMNBR 17A COMP(NE ' ') COLHDG('Item' 'Number') ITEMCLAS 2A COMP(NE ' ') COLHDG('Item' 'Class') PRICE 9P 2 COMP(GT 0) COLHDG(' ' 'Price') K ITEMNBR

Column headings in SQL CREATE TABLE ROB/DDLMAST (ITEMNBR CHAR (17 ) NOT NULL WITH DEFAULT, PRIMARY KEY (ITEMNBR), CHECK (ITEMNBR<>' ' ), ITEMCLAS CHAR (2 ) NOT NULL WITH DEFAULT, CHECK (ITEMCLAS<>' ' ), PRICE DECIMAL (9, 2) NOT NULL WITH DEFAULT, CHECK (PRICE>0 )) RCDFMT DDLMASTR;

Column headings LABEL ON COLUMN ITEMNBR IS 'Item Number'; LABEL ON COLUMN ITEMCLAS IS 'Item LABEL ON COLUMN PRICE IS 'Price'; Class';

Field Reference File CREATE TABLE EMPLOYEE AS (SELECT EMPLOYEE_ID, NAME, etc. FROM FIELDREF) WITH NO DATA Yes, it does bring the column headings along. No, it does not bring the constraints along.

Constraints ITEMCLAS CHAR (2 ) NOT NULL WITH DEFAULT, CHECK (ITEMCLAS<>' ' ), FOREIGN KEY (ITEMCLAS) REFERENCES IIC (ICLAS) ON DELETE NO ACTION ON UPDATE NO ACTION,

RCDFMT clause In older releases of i5/os SQL did not support the RCDFMT clause. Commonly what one did was CREATE TABLE and then rename it.

Embedding UDF s CREATE VIEW wpricing AS SELECT LPROD, LQORD, LCUST, LRDTE, pricing(lprod, lqord, lcust, lrdte) as PRICE FROM ordline

Multi member files Partitioned tables Foreign key constraints

Identity columns CREATE TABLE ROB/ORDMAST (ORDNBR INTEGER GENERATED ALWAYS AS IDENTITY, CUSTNBR INTEGER, ITEMNBR CHAR (17)); INSERT INTO ROB/ORDMAST (CUSTNBR, ITEMNBR) VALUES(5, 'A'); SELECT * FROM ORDMAST; ORDNBR CUSTNBR ITEMNBR 1 5 A

Identity value Exec sql VALUES IDENTITY_VAL_LOCAL() INTO :IVAR; Dump using dummy file SYSDUMMY1 and use VALUES 6.1 also supports: select ordnbr from final table ( INSERT INTO ROB/ORDMAST (CUSTNBR, ITEMNBR) VALUES(7, 'C'))

ADDPFCST trick You can use ADDPFCST to add a key to a *OUTFILE

6.1 HIDDEN & ROW CHANGE TIMESTAMP CREATE TABLE tickets( ticket_ord INTEGER, ticket_qty INTEGER, ticket_event VARCHAR(10), ticket_ts TIMESTAMP NOT NULL IMPLICITLY HIDDEN FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP); INSERT INTO tickets VALUES(1,11, mvgame1 ); NOTE: Only 3 column values passed on INSERT

6.1 HIDDEN & ROW CHANGE TIMESTAMP SELECT * FROM TICKETS TICKET_ORD TICKET_QTY TICKET_EVENT 1 11 mvgame1 SELECT TICKET_ORD, TICKET_TS FROM TICKETS TICKET_ORD TICKET_TS 1 2009-04-19-22.25.57.106071

6.1 LF s for RLA CREATE INDEX ROB/IIML01R ON IIM (IPROD) WHERE IID='IM' RCDFMT IIML01RR ADD IPROD, IDESC, ICLAS

System reference tables Select * from QSYS2/SYSCOLUMNS

Bibliography http://www-03.ibm.com/servers/eserver/iseries/db2/pdf/ Performance_DDS_SQL.pdf http://faq.midrange.com/data/cache/462.html SQL Performance Diagnosis on IBM DB2 Universal Database for iseries http://www.redbooks.ibm.com/abstracts/sg246654.html?open Modernizing IBM eserver iseries Application Data Access - A Roadmap Cornerstone http://www.redbooks.ibm.com/abstracts/sg246393.html?open

Preparing for and Tuning the SQL Query Engine on DB2 for i5/os http://www.redbooks.ibm.com/abstracts/sg246598.html?open Database performance and query optimization http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/rzajq/r zajq.pdf DB2 Universal Database for iseries Administration: The Graphical Way on V5R3 http://www.redbooks.ibm.com/abstracts/sg246092.html?open Mastering SQL Performance with Visual Explain - V5R3 Update http://www- 03.ibm.com/servers/enable/site/education/abstracts/2dc6_abs.html

Analyzing DB2 for i5/os Performance with the V5R4 SQL Plan Cache & Visual Explain http://www- 03.ibm.com/servers/enable/site/education/abstracts/e526_abs. html