0% found this document useful (0 votes)
52 views35 pages

System I DB

The document discusses IBM System i database concepts. It describes physical and logical files, file members, and terminology used in IBM i operating systems. Examples of displaying physical file members and their data are also shown.

Uploaded by

sagaru_id
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views35 pages

System I DB

The document discusses IBM System i database concepts. It describes physical and logical files, file members, and terminology used in IBM i operating systems. Examples of displaying physical file members and their data are also shown.

Uploaded by

sagaru_id
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

IBM System i™

IBM® System i Database

Zakaria Ansori
[email protected]

i want stress-free IT.


i want control.
i want an i. © 2007 IBM Corporation
IBM System i

Traditional Program-described File

Each Program has it‘s own data definitions!

2
i want an i. © 2007 IBM Corporation
IBM System i

Two Interfaces

Data Description
Specifications
(DDS)

Library
Native

Object Type =
SQL *FILE
STRSQL
Schema
*LIB

Strategic

3
i want an i. © 2007 IBM Corporation
IBM System i

Database Objects – Terminology


SQL OS/400
schema/collection library

table physical file

view logical file

index keyed logical file

row record

column field

log journal

4
i want an i. © 2007 IBM Corporation
IBM System i

Terminology

5
i want an i. © 2007 IBM Corporation
IBM System i

Physical/Logical Files
Schema/Database/Library

Physical
Filea
Files (data)
Fileb
Filec
selection Filed
projection
union Filee
join

Logical Files
(INDEXES)
(no data)
File_x File_y
Open
Data
Paths
(ODP)

Application
Program

6
i want an i. © 2007 IBM Corporation
IBM System i

Physical File Structure


ƒ File Header
– File Description LIBRARYX/DBFILE
– Qualified File library/name Header
– Owner fld-1 fld-2 fld-3 fld-4
– Object Authority
– Number of records
Dataspace
– Field Level Description
– Field names
– Attributes
ƒ Dataspace
– Actual Data
– Multiple File Members data
Cursor
– Not used by SQL data
ƒ Index Space data
– Index
ƒ Cursor data

Member-1
Member-2

Member-n
iSeries
Unique

7
i want an i. © 2007 IBM Corporation
IBM System i

File Members
Display Physical File Member
File Member
Display Physical File . . . . . . : CUSTOMERS Library . . . . : ERPDATA
File . . . . . . : CUSTOMERS Library CUSTCDT
Member .. .. .. .. .: : ERPDATA Record . . . . . : 1
Member . . . . . : SECOND Control
Record . ........:. 1 Column . . . . . : 1
Control . . . . . Find .. .. .. .. .. .: . 1
Column
Find . . . . . . . *...+....1....+....2....+....3....+....4....+....5....+....6
938472Henning G K4859 Elm Ave DallasTX7521750003003700000000
*...+....1....+....2....+....3....+....4....+....5....+....6
918374Davon 839283Jones
A C249 North St LondonTX7521750003003700000000 B D21B NW 135 StClay NY1304104001010000000000
833245Lee 392859Vine
D S21B NW 135 StClay NY1304104001010000000000 S SPO Box 79 BrotonVT0504607001043900000000
123859Jenner T PPO Box 79 938485Johnson J A3 Alpine Way Helen GA3054599992398750003350
BrotonVT0504607001043900000000
345485James 397267Tyron
S A3 Alpine Way Helen GA3054599992398750003350 W E13 Myrtle Dr HectorNY1484110001000000000000
389572Stevens K L208 Snow PassDenverCO8022604001005875000150
393457Peters D A13 Myrtle Dr HectorNY1484110001000000000000
323472Wang 846283Alison J S787 Lake Dr Isle MN5634250003001000000000
C M208 Snow PassDenverCO8022604001005875000150
475938Doe
889900Hoover E J787 Lake Dr SydneyMN5634250003001000000000 J W59 Archer Rd SutterCA9568507002025000010000
693829Thomas A N3 Dove CircleCasperWY8260999992000000000000
423438HumphreyH W59 Archer Rd SutterCA9568507002025000010000
593029WilliamsE D485 SE 2 Ave DallasTX7521802001002500000000
693829Thomas A N3 Dove CircleCasperWY8260999992000000000000
192837Lee
593029WilliamsE D485 SE 2 Ave BangorTX7521802001002500000000 F L5963 Oak St HectorNY1484107002048950000050
192837Lee 583990Abraham M T392 Mill St Isle MN5634299993050000000000
F L5963 Oak St ForestNY1484107002048950000050
583990Abraham M T392 Mill St IslandMN5634299993050000000000 ****** END OF DATA ******
****** END OF DATA ******

Display Physical File Member


File . . . . . . : CUSTOMERS Library . . . . : ERPDATA
LIBRARYX/DBFILE
Member . . . . . : THIRD Record . . . . . : 1
Header
Control . . . . . Column . . . . . : 1 fld-1 fld-2 fld-3 fld-4
Find . . . . . . .
Dataspace
*...+....1....+....2....+....3....+....4....+....5....+....6
323472Wang C M208 Snow PassDenverCO8022604001005875000150
889900Hoover E J787 Lake Dr SydneyMN5634250003001000000000
423438HumphreyH W59 Archer Rd SutterCA9568507002025000010000
693829Thomas A N3 Dove CircleCasperWY8260999992000000000000 Cursor data
593029WilliamsE D485 SE 2 Ave BangorTX7521802001002500000000 data
data
192837Lee F L5963 Oak St ForestNY1484107002048950000050
583990Abraham M T392 Mill St IslandMN5634299993050000000000
****** END OF DATA ******

Members

8
i want an i. © 2007 IBM Corporation
IBM System i

File Information (1)


ƒ File Description Header
– Explicit File Name
– Library Name
– File Name (10 characters)
– Alternative File Name (20 characters)
– File Type
– Data -
– Source - program code
ƒ Database Attributes
– File Definitions
– Externally Described
– Column (or Field) Level Specifications
– Field information stored with file
– Program Described
– Row (or Record) level Description LIBRARYX/DBFILE

– Field information within program(s) Header fld-1 fld-2 fld-3 fld-4


– File Creation Date Dataspace
– File Size Limits
– Record Length
– Initial records
– Size of increment Cursor data
data
– Number of increments data

Members

DSPFD Command

9
i want an i. © 2007 IBM Corporation
IBM System i

File Information (2)


ƒ Database Attributes
– Number of members
– Maximum
– Current
ƒ Reuse Deleted Records
ƒ Force Write to Disk
ƒ File Activity
– Number
– Opens/Closes
LIBRARYX/DBFILE
– Update/Delete Operations
Header
– Date of Last fld-1 fld-2 fld-3 fld-4

– Change Dataspace

– Save
– Restore
ƒ File Member Information Cursor data

– Name/Creation Date data


data

– Last Update (date/time)


– Number or Records
Members

DSPFD Command

10
i want an i. © 2007 IBM Corporation
IBM System i

Field Description – Record Information


ƒ Columns (Field) Information
–Field Name
–Data Type
–Character
–Numeric
–Binary
–Length
–Buffer Positions
–Usage
–Input/Output
–Column Heading

LIBRARYX/DBFILE

Header fld-1 fld-2 fld-3 fld-4

Dataspace

Cursor data
data
data

DSPFFD Command
Members
(Green Screen)
11
i want an i. © 2007 IBM Corporation
IBM System i

Create a Physical File with DDS


Field Reference File :
R FLDREFP
PERSNR 5S 0 COLHDG('Personal-' 'nummer')
NAME 1000 VARLEN(36)
COLHDG('Name')
GEBDAT L COLHDG('Geburts-' 'datum')
ABTLG 4S 0 COLHDG('Abteilung')
GEHALT 7 2 COLHDG('Gehalt') ALWNULL
...

Physical File Description with DDS :


REF(FLDREFP)
R PERSTPF1
PERSNR R
NAME R
GEBDAT R
ABTLG R ALWNULL
GEHALT R

12
i want an i. © 2007 IBM Corporation
IBM System i

Create a Physical File with SQL

CREATE TABLE MYLIB.CUSTCDT (


CUSNUM NUMERIC(6, 0) NOT NULL DEFAULT 0 ,
LSTNAM CHAR(8) NOT NULL DEFAULT '' ,
STREET CHAR(13) NOT NULL DEFAULT '' ,
CITY CHAR(6) NOT NULL DEFAULT '' ,
STATE CHAR(2) NOT NULL DEFAULT '' ,
CDTLMT NUMERIC(4, 0) NOT NULL DEFAULT 0 ) ;

13
i want an i. © 2007 IBM Corporation
IBM System i

Disk Storage Management

OS/400

ƒ All data is spread across available disk arms


– Optimum performance - automatically
ƒ Not all information is necessarily contiguous
– Improved performance
– Balanced disk arm utilization
ƒ Optional rebalancing
– space/arm utilization
ƒ Information accessed by name not hardware address
ƒ Minimal Database Administration

14
i want an i. © 2007 IBM Corporation
IBM System i

Impact on Data Retrieval


ƒ An ASP can (does) span multiple disks
– Contains Multiple Libraries
ƒ Data Objects not bounded by Disk Volumes
– Data may span multiple disk drives
ƒ Application Database
– Multiple Libraries
– Multiple Objects
– Physical Files
– Logical Files Installed Disk Drives
– Data Areas
ASP-1 ASP-2 ASP-n
– Data Queues
– And so forth
– IFS Objects
– Multiple directories
– Sub-directories Library-A
Library-B
Library-C

object-A
object-B
object-C

15
i want an i. © 2007 IBM Corporation
IBM System i

Physical Files (Data)

ƒ Actual Information Stored in DB2 UDB Physical Files


– Type *DATA (versus *SOURCE)
ƒ Specify
– File Name
– <library-name>/<file-name>
– Data held in <member-name>
ƒ Number of Members in file
– Data Format
– Record (row) Length
– Field (column) Organization
– Type
Character
Decimal
Binary and so forth
– Length
– Reuse Deleted Records
– REUSEDLT = *YES/*NO
– Records to force a write
– FRCRATIO=*NONE/<value>

16
i want an i. © 2007 IBM Corporation
IBM System i

Deleted Records
ƒ Through DBMS Support (DB2 UDB)
– REUSEDLT = *YES
– Flagged by DB2 UDB
– Records not made available to applications on *READ
– Parameter REUSEDLT in CRTPF/CHGPF
– *YES
Space freed by deletion of a record is available for additions (new records)
– *NO
Space is not freed when a record is flagged for deletion
– Space "freed" by record deletion
– File "compression" possible
– Reorganize Physical File Mbr (RGZPFM command)

ƒ Reduces File size (dependent on number of deletions)

deleted records (DB2 UDB)

File

"new" records to be added


REUSEDLT=*YES
REUSEDLT=*NO

17
i want an i. © 2007 IBM Corporation
IBM System i

Force Records to Disk

ƒ Arises from Single Level Storage Implementation


– Frequently access pages tend to remain in memory
– Applies to ALL OBJECTS
ƒ Override for Physical Files
– Data written to Disk determined by parameter FRCRATIO
– *NONE ..... System Managed
– <value>..... Number of Records
– Added/Updated
ƒ Consider Impact of Sudden Power Outage!
– Memory is Volatile
– Data loss?
– Battery Backup
– Memory Dumps/Recovery
recently used data/updated
determined by
FRCRATIO

Memory
Disk
Data

18
i want an i. © 2007 IBM Corporation
IBM System i

Accessing the Database

Client
SQL/ISQL Query/400 OPNQRYF Access
Native Query Manager File Transfer
I/O ODBC
(record) OS/400
Query
Component Query APIs

DB2 for iSeries


Optimizer
record-level
processing set-level
processing

Data Management

Technology Independent Machine Interface

Database

19
i want an i. © 2007 IBM Corporation
IBM System i

Data Access
ƒ Software interacting with DB2 UDB/400
– Applications
– High Level Languages
– Application Packages
– iSeries Query Tools
– GUI
– iSeries Access for Windows (5722-XE1)
– iSeries Navigator
– Character-based interface
– Query Manager (5722-QU1)
– DB2 Query Manager (5722-ST1)
– OS/400 Commands
Copy File (CPYF)
Create Duplicate Object (CRTDUPOBJ)
Display File (DSPPFM)
– Non-IBM Tools

20
i want an i. © 2007 IBM Corporation
IBM System i

SQL Packaging

Database Manager
SQL parser and runtime support
Query Management
Several SQL APIs No Charge
Call Level Interface
Performance Tools
RUNSQLSTM

DB2 UDB for iSeries Query Manager and


SQL Development Kit (5722-ST1)
STRSQL Licensed Program
SQL Preprocessors
Query Manager
SQL REXX Interface

21
i want an i. © 2007 IBM Corporation
IBM System i

Data Access via SQL

Programming Interfaces

Static SQL Dynamic SQL Extended Dynamic SQL

Embedded Static Embedded Dynamic QSQPRCED

Toolbox JDBC &


JDBC, SQLJ
iSeries Access ODBC

OLE DB, .NET XDA API set

CLI, ODBC

Net.Data

RUNSQLSTM

22
i want an i. © 2007 IBM Corporation
IBM System i

iSeries as “DB Server"


OS/400 OS/400

JDBC
CLI*
Embedded
DRDA AIX
Native/DDM
JDBC iSeries Toolbox JDBC DB2
DRDA DB2 Connect
DB2 Information Integrator
UDB
Linux for
JDBC
ODBC
iSeries Toolbox JDBC iSeries
DB2 Connect
DRDA iSeries ODBC
Windows
JDBC iSeries Access
ODBC DB2 Connect
OLE DB DB2 Information Integrator
.NET
DRDA
* OS/400 PASE only supports CLI

23
i want an i. © 2007 IBM Corporation
IBM System i

Do you need a DBA on iSeries?

Maybe...

Consider...
ƒDatabase Analyst or Architect (not administrator)
ƒTechnical issues of moving to a data-centric world
ŠBusiness logic moving into the database
ŠMore data, used in more places, by more clients

24
i want an i. © 2007 IBM Corporation
IBM System i

Database Skill/Tasks
UNIX/Wintel DBA Tasks DB2 UDB for iSeries
Manage DASD Space Allocation Completely Automated
Review Table Space Allocations and Extents Completely Automated
Review and Balance Indexes Completely Automated
Application Rebinding Completely Automated
Maintain Database Integrity Completely Automated
Update Database Statistics Completely Automated
Synchronized OS and DB User Security Completely Automated
Reload Data for Hardware and Software Completely Automated
Upgrades
Load Data into Data Base Integrated Utility (Parallel)
Build and Manage DB Backup and Recovery Integrated GUI
Create and Review Indexes for Tables Integrated GUI
Performance Analysis and Tuning (DB and Integrated GUI
System)
Create and Maintain DB Schema Integrated GUI, DB2 OLAP,
and 3rd Party Tools (ERwin,S-Designer)
Automated DB Performance Profiling insure/SQL
Advanced DB Performance Analysis and Tuning insure/SQL
Data Replication and Consolidation Multiple IBM and 3rd Party Products

Integrated GUI - iSeries Navigator


insure/SQL by Centerfield Technologies

25
i want an i. © 2007 IBM Corporation
IBM System i

Others UDB facilities

26
i want an i. © 2007 IBM Corporation
IBM System i

REFERENTIAL INTEGRITY

27
i want an i. © 2007 IBM Corporation
IBM System i

28
i want an i. © 2007 IBM Corporation
IBM System i

TRIGGERS

29
i want an i. © 2007 IBM Corporation
IBM System i

30
i want an i. © 2007 IBM Corporation
IBM System i

Trigger
Application-independent Triggers:
•Written once; used by many •Enforce business rules
Activated by database manager when •Enforce data validation and audit trail
operations performed on database •Preserve data consistency
•'Fired' by specified database Triggers versus Stored Procedures
operations and take action written •Triggers invoked by database events
in trigger •Stored procedures invoked by application
•Interface-independent CALL

DB2/400

SENDFAX
4711
program
5436
4711

When a new order is inserted or updated, a trigger is fired:


• Trigger retrieves information about order and customer
• A confirmation fax is automatically sent

31
i want an i. © 2007 IBM Corporation
IBM System i

32
i want an i. © 2007 IBM Corporation
IBM System i

33
i want an i. © 2007 IBM Corporation
IBM System i

Journaling

34
i want an i. © 2007 IBM Corporation
IBM System i

35
i want an i. © 2007 IBM Corporation

You might also like