DB2 Day - 01
DB2 Day - 01
Consists of
o Data
o Images
o Documents
o Even voice
DB2 databases are Relational
A relational database is a database that is perceived by
its users as a collection of tables
Relation Table
Example – IMS
NETWORK
Candidate key
Set of attributes which uniquely identify the row
Alternate key
Remaining candidate key that were not chosen as primary key
Foreign key
An attribute of one table can be the primary key of another table
STRUCTURED QUERY LANGUAGE
Introduction
Characteristics and Components
Types
SQL Introduction
Query
Definition of data structures
Controlling access to the data
Delete/Modify occurrences of the data .
DB2 - Data Types
DB2 – DATA TYPES
• Char (n) 1 < n < 254 bytes
• Smallint 2 bytes +- 32 K
• Integer 4 bytes +- 2 GB
• Date 0001-01-01
• Time 00:00:00
• Timestamp 0001-01-01-00.00.00.000000
String Data type
Numeric Data type
Numeric Data type
SCALAR FUNCTIONS
SELECT
DDL
CREATE TABLE
CREATE INDEX
ALTER TABLE
CREATE VIEW
DROP TABLE,VIEW AND INDEX
Create Table Syntax
IN DATABASE.TABLESPACE;
What is NULL?
Step 2
Step 3
Specify the Input dataset and Output Dataset for the SQL Query and
result of the Query
Step 4
Step 5
Type END;;; for execution of the query
Select option
8 for DB2
Select option 1
for SPUFI
(or)
Type 8.1 option
directly in main
menu
Type th Type the output dataset
e Input name (PS dataset)
dataset
n a me
(PDS D
ata Set
)
Give the settings as per our
requirement then press enter
Give the queries to be
executed
Use this syntax when you are giving values for all the fields
Use this syntax when you want to give value for specific fields
SQLCODE = 0 successful Insertion
SELECT rows from Table
SELECT is the statement that retrieves the records from
the table. Complete synta
SELECT.
Optional clause w
discussed late
SELECT <column_list> FROM <table name>
NOT NULL
WITH DEFAULT
means - here data
type is CHAR, so
spaces will be
taken if not coded
NOT NULL
means that if WITH DEFAULT
means that value
value is not NULL means if
required always,
giving it will be value is not given
it can not be
assigned as NULL will be
omitted
‘TRAINING’ assigned
DEPT1 table created successfully