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,
.
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Creating Tablespaces and Tables in DB2BCIS 4620zArchit.docx
1. 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
2. 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
3. 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),
4. 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
5. 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
9. * 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 -----------------------------
10. 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,"=")
11. 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")
12. 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")
13. 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")
14. 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
19. ****
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
*****************************************************
****
21. 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))
22. 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;") |
25. *****************************************************
*
* 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
26. 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
27. 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
*****************************************************
*
28. *****************************************************
*
* TSO Member List from Transfer Panel
*****************************************************
*
*****************************************************
*
*****************************************************
*
* Setup
*****************************************************
*
Key("Right")
Key("BackTab")
Key("EraseEndOfField")
firstrow = CursorRow + 1 ;* start searching here
*---- type the listds command ------------------------
30. 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
31. *------ 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
32. 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