Beruflich Dokumente
Kultur Dokumente
A “schema” in DB2 refers to a qualifying name used to group objects together within a
database.All tables have a fully qualified name consisting of its schema name and the
table name. If the schema we choose is, say, “Finance” and the tables we create are called
Employee and Department, then the fully qualified name for each table is
“Finance.Employee” and “Finance.Department”. Schemas allow us to create 2 tables
with the same name in the same database.
Setting Up DB2
IBM DB2 Setup-Tools Configuration Assistant
1. Select Communications Protocal TCP/IP
2. Specifiy Communication parameters 167.6.207.174, Port 50000
3. Database Name/ Database Alias Db2T
Command Editor
Use the Command Editor to generate, edit, execute, and manipulate SQL statements, IMS
commands, and DB2 commands; to work with the resulting output; and to view a
graphical representation of the access plan for explained SQL statements.
1. A comment in a SQL statement starts with two dashes and goes to the end of the line:
2. DB2 SQL does not come with a designated statement delimiter (terminator), though a
semicolon is often used.
Table
A table is an organized set of columns and rows. The number, type, and relative position,
of the various columns in the table is recorded in the DB2 catalogue.
View
A view is another way to look at the data in one or more tables (or other views). For
example,a user of the following view will only see those rows (and certain columns) in
the EMPLOYEE table where the salary of a particular employee is greater than or equal
to the average
salary for their particular department.
CREATE VIEW employee_view AS
SELECT a.empno, a.firstnme, a.salary, a.workdept
FROM employee a
WHERE a.salary >=
(SELECT AVG(b.salary)
FROM employee b
WHERE a.workdept = b.workdept);
CAST Expression
CASE Expression
CASE expressions enable one to do if-then-else type processing inside of SQL statements.