Creating Tablespaces and Tables in DB2
BCIS 4620
z
Architecture
Databases have tablespaces
Tablespaces have tables
Tables have key indexes
z
Create a TableSpace
--CREATE TABLESPACES
CREATE TABLESPACE P###TSXX IN P###DB USING
STOGROUP UNTDISK;
COMMIT;
z
Create a Table
--CREATE TESTXX TABLE
CREATE TABLE TESTXX
(COURSE_NO CHAR(6) NOT NULL,
COURSE_NAME VARCHAR(25) NOT NULL,
CREDITS DECIMAL (2,0) NOT NULL,
PRIMARY KEY (COURSE_NO))
IN P###DB.M###TSXX;
COMMIT;
z
Create a PK Index
--CREATE PK INDEX ON TESTXX
CREATE UNIQUE INDEX UNTP###.X1XX
ON UNTP###.TESTXX (COURSE_NO)
USING STOGROUP UNTDISK;
COMMIT;
z
Creating Tablespaces and Tables in DB2
BCIS 4620
z
Architecture
Databases have tablespaces
Tablespaces have tables
Tables have key indexes
z
Naming Conventions
For all the names below ### refers to your UNTP number and
XX Refers to the first two letters of the table name.
You may have to change your XX based on if it is the same as
another table.
Example you have two tables Consultant and Course, so the
tablespaces can’t be named TSCO for both. So you may change
the tablespace for Course to CR instead.
z
Naming Conventions
Databases – P###DB
Tablespaces - P###TSXX
Tables – The name of the entity
Indexes - UNTP###.X1XX
Here, the first X stands for index.
z
Create a TableSpace
--CREATE TABLESPACES
CREATE TABLESPACE P###TSXX IN P###DB USING
STOGROUP UNTDISK;
COMMIT;
z
Create a Table
--CREATE XXTABLE TABLE
CREATE TABLE XXTABLE
(XXTABLE _NO CHAR(6) NOT NULL,
XXTABLE _NAME VARCHAR(25) NOT NULL,
XXTABLE_CREDITS DECIMAL (2,0) NOT NULL,
PRIMARY KEY (XXTABLE _NO))
IN P###DB.M###TSXX;
COMMIT;
z
Create a Table (with Foreign Key)
--CREATE XXTABLE TABLE
CREATE TABLE XXTABLE
(XXTABLE _NO CHAR(6) NOT NULL,
XXTABLE _NAME VARCHAR(25) NOT NULL,
XXTABLE_CREDITS DECIMAL (2,0) NOT NULL,
PRIMARY KEY (XXTABLE _NO),
FOREIGN KEY(XXTABLE 2_ID) REFERENCES
XXTABLE2)
IN P###DB.M###TSXX;
COMMIT;
z
Create a Table (with Composite PK)
--CREATE XXTABLE TABLE
CREATE TABLE XXTABLE
(XXTABLE1 _NO CHAR(6) NOT NULL,
XXTABLE _NAME VARCHAR(25) NOT NULL,
XXTABLE_CREDITS DECIMAL (2,0) NOT NULL,
XXTABLE2_ID INTEGER NOT NULL,
PRIMARY KEY (XXTABLE1 _NO, XXTABLE2_ID),
FOREIGN KEY(XXTABLE 2_ID) REFERENCES
XXTABLE2,
FOREIGN KEY(XXTABLE 1_NO) REFERENCES
XXTABLE1)
IN P###DB.M###TSXX;
COMMIT;
z
Create a PK Index
--CREATE PK INDEX ON XXTABLE
CREATE UNIQUE INDEX UNTP###.X1XX
ON UNTP###. XXTABLE (XXTABLE _NO)
USING STOGROUP UNTDISK;
COMMIT;
z
Create a FK Index
--CREATE FK INDEX ON XXTABLE
CREATE INDEX UNTP###.X2XX
ON UNTP###. XXTABLE (XXTABLE2 _ID)
USING STOGROUP UNTDISK;
COMMIT;
z
TomBrennanSoftware/VistaTN3270/beep1.wav
TomBrennanSoftware/VistaTN3270/beep2.wav
TomBrennanSoftware/VistaTN3270/beep3.wav
TomBrennanSoftware/VistaTN3270/beep4.wav
TomBrennanSoftware/VistaTN3270/click1.wav
TomBrennanSoftware/VistaTN3270/click2.wav
TomBrennanSoftware/VistaTN3270/click3.wav
TomBrennanSoftware/VistaTN3270/click4.wav
TomBrennanSoftware/VistaTN3270/example1.bmp
TomBrennanSoftware/VistaTN3270/example2.bmp
TomBrennanSoftware/VistaTN3270/macros/clipboard.mac
************************************************
* Clipboard
************************************************
WinExec("clipbrd.exe");
TomBrennanSoftware/VistaTN3270/macros/copyfield.mac
*****************************************************
****
* CopyField
*****************************************************
****
Key("SelectField",CursorRow,CursorCol)
Key("Copy")
TomBrennanSoftware/VistaTN3270/macros/copyline.mac
*****************************************************
****
* CopyLine
*****************************************************
****
Key("SelectLine",CursorRow,CursorCol)
Key("Copy")
TomBrennanSoftware/VistaTN3270/macros/copyrepeat.mac
*****************************************************
****
* CopyRepeat
*****************************************************
****
Key("SelectField",CursorRow,CursorCol)
Key("Copy")
Key("PasteRepeat")
TomBrennanSoftware/VistaTN3270/macros/copyword.mac
*****************************************************
****
* CopyWord
*****************************************************
****
Key("SelectWord",CursorRow,CursorCol)
Key("Copy")
TomBrennanSoftware/VistaTN3270/macros/hotspot.mac
*****************************************************
*****************
* HotSpot Macro
*****************************************************
*****************
*
* Edit a mouse key to point to this macro (for example, a right
click)
* to enable screen hot-spots.
*
* To add your own hotspots, just add Case statements and action
* statements within the Select block.
*
*-------- don't do anything unless screen is unlocked -------------
---
if status != "unlocked"
exit
endif
*-------- get the word at the cursor position ------------------------
Key("MoveCursor") ;* move cursor to mouse position
Key("SelectWord") ;* select word at mouse position
text = Screen(StartRow,StartCol,EndCol-StartCol+1) ;* get
selected text
*-------- handle url links on the screen -----------------------------
if left(text,7) = "http://"
Key("Reset")
ShellExecute("open",text,"","",1)
exit
endif
*-------- strip enclosing parenthesis---------------------------------
a = Len(text)
if Left(text,1) = "("
if Right(text,1) = ")"
text = Mid(text,2,a-2)
endif
endif
*-------- strip = after PF key value ---------------------------------
a = Instr(0,text,"=")
if a > 1
text = Left(text,a-1)
endif
*-------- strip : after PF key value ---------------------------------
a = Instr(0,text,":")
if a > 1
text = Left(text,a-1)
endif
*-------- handle PF keys ---------------------------------------------
Select text ;* select function matching text
Case "PF1","F1","1"
Key("PF1")
Case "PF2","F2","2"
Key("PF2")
Case "PF3","F3","3"
Key("PF3")
Case "PF4","F4","4"
Key("PF4")
Case "PF5","F5","5"
Key("PF5")
Case "PF6","F6","6"
Key("PF6")
Case "PF7","F7","7"
Key("PF7")
Case "PF8","F8","8"
Key("PF8")
Case "PF9","F9","9"
Key("PF9")
Case "PF10","F10","10"
Key("PF10")
Case "PF11","F11","11"
Key("PF11")
Case "PF12","F12","12"
Key("PF12")
Case "PF13","F13","13"
Key("PF13")
Case "PF14","F14","14"
Key("PF14")
Case "PF15","F15","15"
Key("PF15")
Case "PF16","F16","16"
Key("PF16")
Case "PF17","F17","17"
Key("PF17")
Case "PF18","F18","18"
Key("PF18")
Case "PF19","F19","19"
Key("PF19")
Case "PF20","F20","20"
Key("PF20")
Case "PF21","F21","21"
Key("PF21")
Case "PF22","F22","22"
Key("PF22")
Case "PF23","F23","23"
Key("PF23")
Case "PF24","F24","24"
Key("PF24")
Case "PA1"
Key("PA1")
Case "PA2"
Key("PA2")
Case "PA3"
Key("PA3")
Default
Key("MoveCursor") ;* if not in list, just do
Key("Enter") ;* ENTER at Cursor Location
EndSelect
TomBrennanSoftware/VistaTN3270/macros/notepad.mac
************************************************
* Note Pad
************************************************
WinExec("notepad.exe");
�
TomBrennanSoftware/VistaTN3270/macros/rule.mac
*****************************************************
************
* Toggle Rule
*****************************************************
************
current = GetOption("Cursor","Ruler")
If current = 0 then
new = 3
Else
new = 0
Endif
SetOption("Cursor","Ruler",new)
TomBrennanSoftware/VistaTN3270/macros/sessiona.mac
*****************************************************
****
* Session A
*****************************************************
****
Session("A");
TomBrennanSoftware/VistaTN3270/macros/sessionb.mac
*****************************************************
******************
* Session B
*****************************************************
******************
Session("B")
TomBrennanSoftware/VistaTN3270/macros/sessionc.mac
*****************************************************
******************
* Session C
*****************************************************
******************
Session("C")
TomBrennanSoftware/VistaTN3270/macros/sessiond.mac
*****************************************************
******************
* Session D
*****************************************************
******************
Session("D")
TomBrennanSoftware/VistaTN3270/macros/sessione.mac
*****************************************************
******************
* Session E
*****************************************************
******************
Session("E")
TomBrennanSoftware/VistaTN3270/macros/user1.mac
*****************************************************
****
* Use this macro for your own use
*****************************************************
****
TomBrennanSoftware/VistaTN3270/macros/user2.mac
*****************************************************
****
* Use this macro for your own use
*****************************************************
****
TomBrennanSoftware/VistaTN3270/macros/user3.mac
*****************************************************
****
* Use this macro for your own use
*****************************************************
****
TomBrennanSoftware/VistaTN3270/macros/user4.mac
*****************************************************
****
* Use this macro for your own use
*****************************************************
****
TomBrennanSoftware/VistaTN3270/macros/user5.mac
*****************************************************
****
* Use this macro for your own use
*****************************************************
****
TomBrennanSoftware/VistaTN3270/macros/vst$list.mac
*****************************************************
*
*****************************************************
*
* CMS File List from Transfer Panel
*****************************************************
*
*****************************************************
*
*****************************************************
*
* Setup
*****************************************************
*
*---- type the list command --------------------------
Key("Clear")
Wait(10,Status="unlocked")
Type("LISTFILE "+XferHLI)
Key("Enter")
Wait(10,OnScreen("R;") | OnScreen("Ready;") |
OnScreen("MORE..."))
*****************************************************
*
* Loop to read screen data
*****************************************************
*
start = 2
count = 0
While (1)
*---- get filenames --------------------------------
For row = start to ScreenHeight
line = Trim(Screen(row,1))
If Len(line) >= 20
If Mid(line,9,1) = " " & Mid(line,18,1) = " "
XferAddStg(Lowercase(line))
count = count + 1
Endif
Endif
Next row
*---- check for end of list ------------------------
If OnScreen("R;") | OnScreen("Ready;")
Exit
Endif
*---- clear and wait for new screen ----------------
Key("Clear")
Wait(10,OnScreen("R;") | OnScreen("Ready;") |
OnScreen("MORE..."))
start = 1
EndWhile
Exit
TomBrennanSoftware/VistaTN3270/macros/vst$lstc.mac
*****************************************************
*
*****************************************************
*
* TSO Dataset List from Transfer Panel
*****************************************************
*
*****************************************************
*
*****************************************************
*
* Setup
*****************************************************
*
Key("Right")
Key("BackTab")
Key("EraseEndOfField")
firstrow = CursorRow + 1 ;* start searching here
*---- type the listcat command -----------------------
If XferHLI = ""
Type("LISTCAT")
Key("Enter")
Else
Type("LISTCAT LVL("+XferHLI+")")
Key("Enter")
Endif
Wait(10,Status="unlocked")
*****************************************************
*
* Loop to read screen data
*****************************************************
*
dsncount = 0
For row=firstrow to ScreenHeight
line = Screen(row,1)
*------ hit Enter if more data is available --------
If Left(line,4) = " ***"
Key("Enter")
Wait(10,Status="unlocked")
row = 0
Continue
Endif
*------ break if READY is seen ---------------------
If Left(line,7) = " READY "
If Screen(row+1,2,3) = "***"
Key("Enter")
Wait(10,Status="unlocked")
Endif
Break
Endif
*------ search for dataset names -------------------
If Left(line,10) = " NONVSAM -"
XferAddStg("'"+LowerCase(Trim(Mid(line,18,44)))+"'")
dsncount = dsncount + 1
Else
dsn = Mid(line,2,ScreenWidth)
If DataType(Left(dsn,1)) = "A"
dsn = Trim(dsn)
pos = Instr(0,dsn,".")
If pos & Not(InStr(0,dsn," "))
dsn = Trim(Mid(dsn,pos+1,44))
XferAddStg(LowerCase(Trim(dsn)))
dsncount = dsncount + 1
Endif
Endif
Endif
Next row
Exit
TomBrennanSoftware/VistaTN3270/macros/vst$lstd.mac
*****************************************************
*
*****************************************************
*
* TSO Member List from Transfer Panel
*****************************************************
*
*****************************************************
*
*****************************************************
*
* Setup
*****************************************************
*
Key("Right")
Key("BackTab")
Key("EraseEndOfField")
firstrow = CursorRow + 1 ;* start searching here
*---- type the listds command ------------------------
Type("LISTDS "+XferDSN+" MEMBERS")
Key("Enter")
Wait(10,Status="unlocked")
*****************************************************
*
* Loop to read screen data
*****************************************************
*
memcount = 0
members = False
For row=firstrow to ScreenHeight
line = Screen(row,1)
*------ hit Enter if more data is available --------
If Left(line,4) = " ***"
Key("Enter")
Wait(10,Status="unlocked")
row = 0
Continue
Endif
*------ break if READY is seen ---------------------
If Left(line,7) = " READY "
If Screen(row+1,2,3) = "***"
Key("Enter")
Wait(10,Status="unlocked")
Endif
Break
Endif
*------ check for member name ----------------------
If Left(line,12) = " --MEMBERS--"
members = True
Continue
Endif
If members
text = Trim(Mid(line,4,ScreenWidth)) + " "
If DataType(Left(text,1)) = "A"
memlen = Instr(0,text," ")
mem = Trim(Left(text,memlen))
If memlen = Len(text)
XferAddStg(LowerCase(mem))
memcount = memcount + 1
Endif
p = Instr(0,text,"ALIAS(")
If p != 0
XferAddStg(LowerCase(mem))
memcount = memcount + 1
p = p + 6
aliases = Mid(text,p,9999)
If Instr(0,aliases,")")
aliases = Left(aliases,Len(aliases)-2)+","
EndIf
p = 1
While p < Len(aliases)
i = Instr(p,aliases,",")
alias = Mid(aliases,p,i)
XferAddStg(LowerCase(alias))
p = p + i + 1
EndWhile
Endif
Endif
Endif
Next row
Exit
TomBrennanSoftware/VistaTN3270/standard.bar
TomBrennanSoftware/VistaTN3270/standard.key
TomBrennanSoftware/VistaTN3270/standard.pad
TomBrennanSoftware/VistaTN3270/standard.ses
TomBrennanSoftware/VistaTN3270/vista.ini
[Vista]
LastSession=standard.ses
Hostnames=192.86.32.88,192.86.32.91
IPnames=192.86.32.88,192.86.32.91
Portnums=623,23
TN3270E=1,1
SSL=0,0
Lunames=,
Consultant SkillsConsultant_Skill
Client
Project
Project_Skills
SubProject
C_FName
C_MI
C_IDPK
C_LName
C_Address
C_City
C_State
C_Zip
C_Phone
C_Email
S_IDPK
S_Desc
C_IDFKPK
S_IDFKPK
CL_IDPK
CL_Name
CL_Phone
CL_Contact
P_IDPK
P_Name
C_IDFK
CL_IDFK
P_IDFKPK
S_IDFKPK
SP_IDPK
P_IDFK
SP_Name
Project_Consultant
Project_Eval
C_IDFKPK
PC_StartDate
PC_EndDate
P_IDFKPK
PC_TotalHours
P_IDFKPK
C_IDFK
PE_Date
C_IDFKPK
PE_Score
PE_Comment
The PK C_ID
references the
consultant
being
evaluated. The
FK is the
manager doing
the evaluation.
Creating Tablespaces and Tables in DB2BCIS 4620zArchit.docx

Creating Tablespaces and Tables in DB2BCIS 4620zArchit.docx