Playing in the Sandbox Pam Odden
Objectives <ul><li>Get some idea of how sandboxes can be useful in development </li></ul><ul><li>Learn how to create table...
What’s a Sandbox? <ul><li>What is a sandbox?   An area of space in the DB2 region allocated for the use of one developer, ...
My Sandbox <ul><li>My sandbox is a database named DEVPJODB </li></ul><ul><li>select * from sysibm.sysdatabase where name =...
Creating a New Tablespace with File-AID <ul><li>File-AID for DB2  Tablespace Create  SSID: TSN  </li></ul><ul><li>COMMAND ...
Creating a new table with File-AID <ul><li>File-AID for DB2  Table Create  Row 1 to 5 of 8  </li></ul><ul><li>COMMAND ===>...
Adding Columns Manually <ul><li>File-AID for DB2  Table Create  Row 1 to 5 of 5  </li></ul><ul><li>COMMAND ===> DEFAULT  S...
Setting Defaults <ul><li>Esssssssssssssssssssssssssss Default Values ssssssssssssssssssssssssssssN </li></ul><ul><li>e  Ro...
My New Table and Tablespace <ul><li>select * from sysibm.systablespace where dbname = 'DEVPJODB';  </li></ul><ul><li>-----...
Data in  my New Table <ul><li>INSERT INTO PJO.DEMO1  </li></ul><ul><li>(PAMS_COL_2  </li></ul><ul><li>, PAMS_COL_3)  </li>...
Creating a Table from a Model <ul><li>File-AID for DB2  Table Create  Row 1 to 5 of 22  </li></ul><ul><li>COMMAND ===>  SC...
Creating an Index <ul><li>File-AID for DB2  Index Create  Row 1 to 9 of 22  </li></ul><ul><li>COMMAND ===>  SCROLL ===> PA...
Populating a Table using File-AID’s  Copy Utility <ul><li>In TSO, go to option O.FD for File-AID for DB2 </li></ul><ul><li...
Copy Utility with a Selection Template <ul><li>File-AID for DB2 -------------- Table Copy Selection ----------------------...
Specifying Rows for Selection <ul><li>File-AID for DB2 -------- Copy Row Selection -------------- Row 1 to 10 of 164  </li...
Creating a New Table using SPUFI <ul><li>CREATE TABLESPACE DEMO3TS  </li></ul><ul><li>IN DEVPJODB  </li></ul><ul><li>USING...
Populating a Table using SPUFI <ul><li>INSERT INTO PJO.DEMO3  </li></ul><ul><li>(SCHOOLNUM  </li></ul><ul><li>, MY_NAME_CO...
Using the New Procedures <ul><li>Database reports </li></ul><ul><ul><li>Run in PRF in the system you want the report for <...
Summary <ul><li>Use the sandbox to create small tables for testing and experimenting. </li></ul><ul><li>You must create a ...
Upcoming SlideShare
Loading in …5
×

Playing in the Sandbox, Part 1

394 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
394
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • A sandbox is a play area – NOT to be confused with a catbox, as I heard them referred to in the last class session! Don’t feel pressured if you are a DB2 beginner and this is overwhelming. Some superusers will enjoy this new opportunity, others may use it little or not at all.
  • CREATOR is the owner of the db. CREATED BY is the individual’s ID who created it. IBMREQD indicates whether the row was supplied by IBM. (Remember the SYSDUMMY1 table? It’s ibmreqd column is Y. ROSHARE indicates whether db is shared with another DB2 subsystem. Blank = not shared. TIMESTAMP when made shareable. Defaults to 0001 etc. TYPE Workfile db (W) or not. GROUPMEMBER only for workfile dbs. ENCODING A ascii, E ebcdic, blank for IBM and workfiles.
  • You need a tablespace before you can create a table. A tablespace is a pretty physical entity in DB2. It is a file to put your table in. Here, DB2 would be different on the mainframe from DB2 on NT. Space can be defined using a Stogroup or user-defined VSAM data sets. Using Stogroup allows DB2 to handle the underlying VSAM files. Primary quantity and secondary quantity are like extents in file definition. Both will be rounded to the next full segment when allocated. I took default in File-AID the first time I created a tablespace, and got 12 (4K pgs) for priqty and 1 (4K page) for secqty. It was quite small and I got a lot of extents when I added 3000 rows to my table. ERASE means the space is over-written with binary zeros when the table is dropped. Used for sensitive data. Usually use NO. Pctfree and freepage allow space to be reserved for inserts. Pctfree allows some of each page for future inserts, and is often enough by itself. For heavy updating, freepage keeps some empty pages available. GPBCACHE is how the group buffer pool is handled. In TSN we always use bufferpool 0. Use CLOSE YES. Has to do with opening and closing of underlying VSAM data sets. NO was better for older DB2 versions. LOCKSIZE ANY allows DB2 to control locking. Segment size is the number of pages assigned to a segment. May be any multiple of 4 from 4 to 64.
  • I tried skipping the tablespace, wondering if it would do it on the fly with the table. It did not.
  • This is the last way I would recommend to create a table. For a brand new table, you can type in all the columns. However, if you need to make a change or do it over again, you would have to start from scratch again. (Which I did, since I did CREATE before doing DEFAULTs.) You can use the default defaults (space for char, zero for numbers, now for date and time) without defining defaults.
  • The first time I did this, I did the create first. Needless to say, my defaults were not there. I tried altering the table using fileaid, but did not get the chance to add defaults, perhaps because I had already added a row. I had to drop the table and start over again – one of the reasons I do not recommend manually typing in columns as a way to create a table.
  • Because I am the creator of the table, I can refer to it just by its name, without PJO. Note Pqty and sqty are in pages. 4K pages * 180 = 720K.
  • Creating a large amount of test data in this way would take a long time.
  • When I pressed enter, the table name of my model, ASTU_STUDENT, was cleared out. I typed it into the slide. The columns from ASTU showed up in the list at the bottom. I deleted many, and added MY_COL. If you want cols from more than one table, you can then put the next table as a model. When you have it the way you want it, don’t forget to CREATE.
  • The tables we create in our sandboxes will mostly be small and not require many indexes. Don’t just think you don’t need an index and blow off this screen. You can’t use your table until you have a primary index if it has a primary key. Very few of the tables here use RI, and we only set up a primary key if they are, so this won’t happen often. In fact, Kathy removed the primary key from ASTU in TSN when I mentioned it had one. The first and second primary key columns were already selected for me, I just took the defaults and entered an index name and did CREATE. Just a note- remember space is not unlimited, and the purpose of the sandboxes is not to hold millions of rows of data. Try to keep the tables small, and if you have a need to store a large amount of data, it would be nice to let Kathy or myself know. We’ll be keeping an eye on the size of the tables in the sandboxes along with other TSN maintenance.
  • The help pages for this function provide a lot of valuable explanation. These bullets are from the first page.
  • I checked my table, PJO.DEMO2, and it has rows for the students in school 351, and MY_COL is populated with the timestamp.
  • Here a tablespace and table are created using SQL DDL (data definition language). A benefit of doing it this way is that the SQL is saved and can be executed again, and modified.
  • If you need a compile urgently – you can bold the subject and send an urgent email. Of course, I still have to look in my Groupwise to notice it. I am making an effort to check frequently, but you are always welcome to stop by and tap your foot in my cube while I do it.
  • In the next class we will look at How to create copybooks for our new tables How to grant authority to other developers to use them More ways to populate tables, including using data exported from production tables, using the KEEP command in PRF, and using SPUFI through File-AID. Currently all the sandboxes are in TSN, but if anyone routinely works in BSN and would prefer to have one there, please let Kathy or myself know.
  • Playing in the Sandbox, Part 1

    1. 1. Playing in the Sandbox Pam Odden
    2. 2. Objectives <ul><li>Get some idea of how sandboxes can be useful in development </li></ul><ul><li>Learn how to create tablespaces, tables, and indexes in the sandbox using File-AID for DB2 </li></ul><ul><li>Learn how to create objects using SPUFI </li></ul><ul><li>A few comments on the new procedures </li></ul>
    3. 3. What’s a Sandbox? <ul><li>What is a sandbox? An area of space in the DB2 region allocated for the use of one developer, like the area in PDFLIB. your-user-id , or like the C drive on your PC. It is your very own database. </li></ul><ul><li>What will I use it for? During development it is often convenient to be able to try out more than one design, but formally requesting new tables from the DBA discourages experimentation. In the sandbox you can create a few versions of tables, indexes and views and see which works best for your application. </li></ul><ul><li>During testing it is often convenient to use just a subset of the production data, and to create specific test cases. Sandbox tables can be populated quickly with data from existing tables, and modified as needed. </li></ul><ul><li>Do I have to? No. The sandboxes are for the convenience of developers. Don’t feel pressured if you are a DB2 beginner and this is overwhelming. Some super-users and super-user-wannabees will enjoy this new opportunity, others may use it little or not at all. </li></ul><ul><li>An extra benefit is the understanding and experience gained by manipulating structures and data in DB2. </li></ul>
    4. 4. My Sandbox <ul><li>My sandbox is a database named DEVPJODB </li></ul><ul><li>select * from sysibm.sysdatabase where name = 'DEVPJODB'; </li></ul><ul><li>NAME CREATOR STGROUP BPOOL DBID IBMREQD CREATEDBY ROSHARE </li></ul><ul><li>---------+---------+---------+---------+---------+---------+---------+------ </li></ul><ul><li>DEVPJODB SYSADM SYSDEFLT BP0 277 N SYSADM </li></ul><ul><li>TIMESTAMP TYPE GROUP_MEMBER CREATEDTS </li></ul><ul><li>---+---------+---------+---------+---------+---------+---------+---------+-- </li></ul><ul><li>0001-01-01-00.00.00.000000 2002-06-03-12.43.30.935619 </li></ul><ul><li>ALTEREDTS ENCODING_SCHEME SBCS_CCSID DBCS_CCSID MIXED_CCSID </li></ul><ul><li>------+---------+---------+---------+---------+---------+---------+---------+------ </li></ul><ul><li>2002-06-03-12.43.30.935619 E 500 0 0 </li></ul><ul><li>So far it has no tablespaces, tables, or anything else in it </li></ul>
    5. 5. Creating a New Tablespace with File-AID <ul><li>File-AID for DB2 Tablespace Create SSID: TSN </li></ul><ul><li>COMMAND ===> create </li></ul><ul><li>Database Name ===> DEVPJODB </li></ul><ul><li>Tablespace Name ===> DEMO1TS </li></ul><ul><li>STOGROUP ===> SYSDEFLT FREEPAGE ===> 0 BUFFERPOOL ===> BP0 </li></ul><ul><li>PRIQTY(K) ===> 720 PCTFREE ===> 10 LOCKSIZE ===> ANY </li></ul><ul><li>SECQTY(K) ===> 72 NUMPARTS ===> CLOSE ===> YES </li></ul><ul><li>ERASE ===> NO GBPCACHE ===> ALL DSETPASS ===> </li></ul><ul><li>LOCKMAX ===> SYSTEM SEGSIZE ===> 4 </li></ul><ul><li>COMPRESS ===> NO LOCKPART ===> </li></ul><ul><li>LARGE ===> MAXROWS ===> </li></ul><ul><li>-- OR -- </li></ul><ul><li>VCAT ===> </li></ul><ul><li>In TSO, go to option O.FD for File-AID for DB2 </li></ul><ul><li>Select option 3.2 Create, Drop, Alter DB2 Objects. Select Tablespace. (See screen prints) </li></ul><ul><li>Always use the STOGROUP SYSDEFLT </li></ul><ul><li>For a larger tablespace, use PRIQTY 1440, SECQTY 144 </li></ul><ul><li>Please do NOT create LARGE or PARTITIONED tablespaces </li></ul><ul><li>Please do NOT use compression </li></ul><ul><li>The HELP screens are excellent. Press PF1, then use Enter to page through an explanation of each parameter. </li></ul>
    6. 6. Creating a new table with File-AID <ul><li>File-AID for DB2 Table Create Row 1 to 5 of 8 </li></ul><ul><li>COMMAND ===> SCROLL ===> PAGE </li></ul><ul><li>SSID: TSN </li></ul><ul><li>Creator => PJO Database => DEVPJODB Editproc => </li></ul><ul><li>Table Name => DEMO1 Tablespace => DEMO1TS Validproc => </li></ul><ul><li>Restrict Drop => NO (Yes or No) CCSID => (EBCDIC or ASCII) </li></ul><ul><li>Data Capture => NO (Yes or No) </li></ul><ul><li>Temporary => NO (Yes or No) </li></ul><ul><li>MODEL TABLE (Optional, * or pattern for list) </li></ul><ul><li>Creator => PJO </li></ul><ul><li>Table Name => Model Check Constraints => NO (Yes or No) </li></ul><ul><li>Length Unit Allow </li></ul><ul><li>Column Name Type ,scale (for Nulls Fieldproc </li></ul><ul><li>(LL,SS) LOB) (Y/N/D) </li></ul><ul><li>------------------ ------------------ ------- ----- ------- ---------- </li></ul><ul><li>'''''' </li></ul><ul><li>'''''' </li></ul><ul><li>'''''' </li></ul><ul><li>'''''' </li></ul><ul><li>In TSO, go to option O.FD for File-AID for DB2 </li></ul><ul><li>Select option 3.2 Create, Drop, Alter DB2 Objects. Select Table. </li></ul><ul><li>Use your user ID for CREATOR. </li></ul><ul><li>Enter your dbname, tablespace name, and table name. </li></ul>
    7. 7. Adding Columns Manually <ul><li>File-AID for DB2 Table Create Row 1 to 5 of 5 </li></ul><ul><li>COMMAND ===> DEFAULT SCROLL ===> PAGE </li></ul><ul><li>SSID: TSN </li></ul><ul><li>Creator => PJO Database => DEVPJODB Editproc => </li></ul><ul><li>Table Name => DEMO1 Tablespace => DEMO1TS Validproc => </li></ul><ul><li>Restrict Drop => NO (Yes or No) CCSID => (EBCDIC or ASCII) </li></ul><ul><li>Data Capture => NO (Yes or No) </li></ul><ul><li>Temporary => NO (Yes or No) </li></ul><ul><li>MODEL TABLE (Optional, * or pattern for list) </li></ul><ul><li>Creator => PJO </li></ul><ul><li>Table Name => Model Check Constraints => NO (Yes or No) </li></ul><ul><li>Length Unit Allow </li></ul><ul><li>Column Name Type ,scale (for Nulls Fieldproc </li></ul><ul><li>(LL,SS) LOB) (Y/N/D) </li></ul><ul><li>------------------ ------------------ ------- ----- ------- ---------- </li></ul><ul><li>000001 PAMS_COL_1 CHAR 20 D </li></ul><ul><li>000002 PAMS_COL_2 DATE Y </li></ul><ul><li>000003 PAMS_COL_3 INTEGER N </li></ul><ul><li>000004 PAMS_COL_4 DECIMAL 9,2 D </li></ul><ul><li>'''''' </li></ul><ul><li>Length is not needed for types DATE and INTEGER, as they are always a set length. </li></ul><ul><li>Use the DEFAULT command to enter defaults for the columns with D in Allow Nulls </li></ul>
    8. 8. Setting Defaults <ul><li>Esssssssssssssssssssssssssss Default Values ssssssssssssssssssssssssssssN </li></ul><ul><li>e Row 1 to 2 of 2 e </li></ul><ul><li>e COMMAND ===> SCROLL ===> PAGE e </li></ul><ul><li>e e </li></ul><ul><li>e Specify Column Default Values for: PJO.DEMO1 e </li></ul><ul><li>e e </li></ul><ul><li>e COLUMN NAME TYPE(LEN) VALUE More:> e </li></ul><ul><li>e ------------------ ---------------- ----+---10----+---20----+---30-- e </li></ul><ul><li>e PAMS_COL_1 CHAR(20) ‘UNKNOWN’ e </li></ul><ul><li>e PAMS_COL_4 DECIMAL(9,2) 1.0 e </li></ul><ul><li>e ************************** Bottom of data *************************** e </li></ul><ul><li>e e </li></ul><ul><li>e e </li></ul><ul><li>e e </li></ul><ul><li>e e </li></ul><ul><li>PF3 back to previous screen, then enter CREATE in command line to create the table. </li></ul><ul><li>Be sure to define the defaults BEFORE doing the CREATE </li></ul>
    9. 9. My New Table and Tablespace <ul><li>select * from sysibm.systablespace where dbname = 'DEVPJODB'; </li></ul><ul><li>---------+---------+---------+---------+---------+---------+---------+----- </li></ul><ul><li>NAME CREATOR DBNAME DBID OBID PSID BPOOL PARTITIONS </li></ul><ul><li>---------+---------+---------+---------+---------+---------+---------+----- </li></ul><ul><li>DEMO1TS PJO DEVPJODB 277 1 2 BP0 0 </li></ul><ul><li>select * from sysibm.systablepart where tsname = 'DEMO1TS'; </li></ul><ul><li>---------+---------+---------+---------+---------+---------+---------+---------+ </li></ul><ul><li>PARTITION TSNAME DBNAME IXNAME IXCREATOR PQTY SQTY </li></ul><ul><li>---------+---------+---------+---------+---------+---------+---------+---------+ </li></ul><ul><li>0 DEMO1TS DEVPJODB 180 18 </li></ul><ul><li>select * from sysibm.systables where dbname = 'DEVPJODB'; </li></ul><ul><li>---------+---------+---------+---------+---------+---------+---------+---------+ </li></ul><ul><li>NAME CREATOR TYPE DBNAME TSNAME DBID OBID COLCOUNT </li></ul><ul><li>---------+---------+---------+---------+---------+---------+---------+---------+ </li></ul><ul><li>DEMO1 PJO T DEVPJODB DEMO1TS 277 4 4 </li></ul><ul><li>There are many more columns than shown here; I didn’t copy them all. </li></ul><ul><li>Note that PQTY and SQTY are in pages (4K each). </li></ul>
    10. 10. Data in my New Table <ul><li>INSERT INTO PJO.DEMO1 </li></ul><ul><li>(PAMS_COL_2 </li></ul><ul><li>, PAMS_COL_3) </li></ul><ul><li>VALUES </li></ul><ul><li>(CURRENT DATE </li></ul><ul><li>, 456); </li></ul><ul><li>---------+---------+---------+---------+---------+---------+ </li></ul><ul><li>DSNE615I NUMBER OF ROWS AFFECTED IS 1 </li></ul><ul><li>DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0 </li></ul><ul><li>---------+---------+---------+---------+---------+---------+ </li></ul><ul><li>SELECT * FROM PJO.DEMO1; </li></ul><ul><li>---------+---------+---------+---------+---------+---------+ </li></ul><ul><li>PAMS_COL_1 PAMS_COL_2 PAMS_COL_3 PAMS_COL_4 </li></ul><ul><li>---------+---------+---------+---------+---------+---------+ </li></ul><ul><li>UNKNOWN 06/20/2002 456 1.00 </li></ul><ul><li>Note the defaults showed up in the columns I did not enter a value for. </li></ul>
    11. 11. Creating a Table from a Model <ul><li>File-AID for DB2 Table Create Row 1 to 5 of 22 </li></ul><ul><li>COMMAND ===> SCROLL ===> PAGE </li></ul><ul><li>SSID: TSN </li></ul><ul><li>Creator => PJO Database => DEVPJODB Editproc => </li></ul><ul><li>Table Name => DEMO2 Tablespace => DEMO2TS Validproc => </li></ul><ul><li>Restrict Drop => NO (Yes or No) CCSID => (EBCDIC or ASCII) </li></ul><ul><li>Data Capture => NO (Yes or No) </li></ul><ul><li>Temporary => NO (Yes or No) </li></ul><ul><li>MODEL TABLE (Optional, * or pattern for list) </li></ul><ul><li>Creator => SSASIDB1 </li></ul><ul><li>Table Name => ASTU_STUDENT Model Check Constraints => NO (Yes or No) </li></ul><ul><li>Length Unit Allow </li></ul><ul><li>Column Name Type ,scale (for Nulls Fieldproc </li></ul><ul><li>(LL,SS) LOB) (Y/N/D) </li></ul><ul><li>------------------ ------------------ ------- ----- ------- ---------- </li></ul><ul><li>000001 CCSDSTATUS CHAR 1 D </li></ul><ul><li>000002 SCHOOLNUM CHAR 3 D </li></ul><ul><li>000003 MY_COL TIMESTMP D </li></ul><ul><li>000004 STULINK INTEGER D </li></ul><ul><li>000005 ENTERDATE DATE D </li></ul><ul><li>Enter the model creator and tablename and press Enter. </li></ul><ul><li>The columns from the model are listed and can be modified. </li></ul><ul><li>I added MY_COL by Inserting a row </li></ul>
    12. 12. Creating an Index <ul><li>File-AID for DB2 Index Create Row 1 to 9 of 22 </li></ul><ul><li>COMMAND ===> SCROLL ===> PAGE </li></ul><ul><li>Table created, Index required on primary key. </li></ul><ul><li>Creator ===> PJO Creator : PJO </li></ul><ul><li>Index Name ===> DEMO2X Table Name: DEMO2 </li></ul><ul><li>Index Type ===> 2 (1/2) Partitioned ===> N (Y/N) </li></ul><ul><li>Cluster ===> Y (Y/N) Unique ===> 1 (1. Yes, 2. No, </li></ul><ul><li>Piecesize ===> (K) 3. Unique when not null) </li></ul><ul><li>SELECT A/D COLUMN NAME DATA TYPE(LENGTH) </li></ul><ul><li>(1,2,..,n) </li></ul><ul><li>__ _ CCSDSTATUS CHAR(1) </li></ul><ul><li>1_ _ SCHOOLNUM CHAR(3) </li></ul><ul><li>__ _ MY_COL TIMESTMP(26) </li></ul><ul><li>__ _ STULINK INTEGER(4) </li></ul><ul><li>__ _ ENTERDATE DATE(10) </li></ul><ul><li>__ _ LEAVEDATE DATE(10) </li></ul><ul><li>__ _ ENTERCODE CHAR(3) </li></ul><ul><li>__ _ LEAVECODE CHAR(3) </li></ul><ul><li>2_ _ PERMNUM CHAR(12) </li></ul><ul><li>Since my model table has a primary key, I was automatically brought to this screen to create the primary index. You must have an index for a primary key. </li></ul><ul><li>Just enter an index name and type CREATE on the command line. </li></ul>
    13. 13. Populating a Table using File-AID’s Copy Utility <ul><li>In TSO, go to option O.FD for File-AID for DB2 </li></ul><ul><li>Select option 3.3 Copy Rows Between Tables </li></ul><ul><li>This provides a facility to </li></ul><ul><ul><li>- specify which rows and columns are to be copied </li></ul></ul><ul><ul><li>- limit the number of rows to be copied </li></ul></ul><ul><ul><li>- delete existing rows prior to copy </li></ul></ul><ul><ul><li>- map columns from the source table/view to the target table/view </li></ul></ul><ul><ul><li>- specify the total number of rows to be discarded due to errors </li></ul></ul><ul><ul><li>- automatically create target table (Note: it did create my table ‘on the fly’, but only when I put it in an existing tablespace.) </li></ul></ul>
    14. 14. Copy Utility with a Selection Template <ul><li>File-AID for DB2 -------------- Table Copy Selection ------------------------- </li></ul><ul><li>COMMAND ===> SSID ===> TSN </li></ul><ul><li>Specify Table Copy Option: </li></ul><ul><li>Specify Option ===> T Blank - Full Table Copy </li></ul><ul><li>T - Use a Selection Template </li></ul><ul><li>S - Use SQL for Selection (SPUFI) </li></ul><ul><li>From Table To Table </li></ul><ul><li>--------------- --------- </li></ul><ul><li>Creator ===> SSASIDB1 Creator ===> pjo </li></ul><ul><li>Table Name ===> astu_student Table Name ===> demo2 </li></ul><ul><li>Maximum Rows To Select ===> * (* for all rows) </li></ul><ul><li>Column Selection ===> NO (Yes or No) </li></ul><ul><li>Delete Existing Rows ===> NO (Yes or No) </li></ul><ul><li>Column Name Matching ===> YES (Yes or No) </li></ul><ul><li>Discard Limit ===> 20 </li></ul><ul><li>F1=HELP F2=SPLIT F3=END F4=RETURN F6=EXECUTE F7=UP </li></ul><ul><li>F8=DOWN F9=SWAP F10=LEFT F11=RIGHT F12=RETRIEVE </li></ul><ul><li>If you are copying over data you no longer want, use YES in Delete Existing Rows </li></ul><ul><li>If there are duplicate primary keys or other problems, those rows will be discarded </li></ul><ul><li>If you need to select source and target columns with different names, use YES in Column Selection </li></ul><ul><li>Use PF6 or type EXECUTE in the command line to start copying </li></ul><ul><li>I got an error both times (-752, Invalid Connect stmt.) but each time I then got a message that nnn rows were copied, and the rows were in my table. </li></ul>
    15. 15. Specifying Rows for Selection <ul><li>File-AID for DB2 -------- Copy Row Selection -------------- Row 1 to 10 of 164 </li></ul><ul><li>COMMAND ===> SCROLL ===> PAGE </li></ul><ul><li>SSID: TSN </li></ul><ul><li>Use SQL to view/save the SQL source </li></ul><ul><li>From Table </li></ul><ul><li>------------------ </li></ul><ul><li>Creator : SSASIDB1 </li></ul><ul><li>Table Name: ASTU_STUDENT </li></ul><ul><li>COLUMN NAME TYPE(LEN) WHERE </li></ul><ul><li>------------------ ------------------ ----+---10----+---20----+---30----+---4 </li></ul><ul><li>CCSDSTATUS CHAR(1) </li></ul><ul><li>SCHOOLNUM CHAR(3) = '351' </li></ul><ul><li>STULINK INTEGER </li></ul><ul><li>ENTERDATE DATE </li></ul><ul><li>LEAVEDATE DATE </li></ul><ul><li>ENTERCODE CHAR(3) </li></ul><ul><li>LEAVECODE CHAR(3) </li></ul><ul><li>PERMNUM CHAR(12) </li></ul><ul><li>SOCSECNUM CHAR(10) </li></ul><ul><li>FAMILYNUM INTEGER </li></ul><ul><li>Enter where conditions </li></ul><ul><li>Press PF1 for help, then select 2 for Where Clause Specification to get a list of conditional operators and help constructing where clause </li></ul><ul><li>When finished, PF3 back to the prior screen to execute. </li></ul>
    16. 16. Creating a New Table using SPUFI <ul><li>CREATE TABLESPACE DEMO3TS </li></ul><ul><li>IN DEVPJODB </li></ul><ul><li>USING STOGROUP SYSDEFLT </li></ul><ul><li>PRIQTY 8 </li></ul><ul><li>SECQTY 144 </li></ul><ul><li>ERASE NO </li></ul><ul><li>SEGSIZE 4 </li></ul><ul><li>BUFFERPOOL BP0 </li></ul><ul><li>CLOSE YES </li></ul><ul><li>LOCKSIZE ANY </li></ul><ul><li>PCTFREE 10 </li></ul><ul><li>FREEPAGE 0; </li></ul><ul><li>---------+---------+---------+---------+---------+--------- </li></ul><ul><li>DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0 </li></ul><ul><li>CREATE TABLE PJO.DEMO3 </li></ul><ul><li>(SCHOOLNUM CHAR(03) NOT NULL WITH DEFAULT, </li></ul><ul><li>MY_NAME_COL CHAR(30) NOT NULL WITH DEFAULT, </li></ul><ul><li>RUN_DATE DATE NOT NULL WITH DEFAULT, </li></ul><ul><li>LOAD_IND CHAR(01) NOT NULL WITH DEFAULT, </li></ul><ul><li>STAT_RUN_DATE DATE ) </li></ul><ul><li>IN DEVPJODB.DEMO3TS; </li></ul><ul><li>---------+---------+---------+---------+---------+---------+------ </li></ul><ul><li>DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0 </li></ul><ul><li>This sql may be copied from PDFLIB.PJO.SQL(SAMPLDDL) </li></ul>
    17. 17. Populating a Table using SPUFI <ul><li>INSERT INTO PJO.DEMO3 </li></ul><ul><li>(SCHOOLNUM </li></ul><ul><li>, MY_NAME_COL </li></ul><ul><li>, RUN_DATE </li></ul><ul><li>, LOAD_IND </li></ul><ul><li>, STAT_RUN_DATE) </li></ul><ul><li>SELECT </li></ul><ul><li>R.SCHOOLNUM </li></ul><ul><li>, SUBSTR(A.SCHOOLNAME,1,30) </li></ul><ul><li>, R.RUN_DATE </li></ul><ul><li>, R.LOAD_IND </li></ul><ul><li>, R.STAT_RUN_DATE </li></ul><ul><li>FROM SSTATDB1.RUN_CTL R </li></ul><ul><li>INNER JOIN SSASIDB1.ASCH_SCHOOL A </li></ul><ul><li>ON R.SCHOOLNUM = A.SCHOOLNUM </li></ul><ul><li>WHERE R.SCHOOLNUM > '900'; </li></ul><ul><li>DSNE615I NUMBER OF ROWS AFFECTED IS 38 </li></ul><ul><li>DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0 </li></ul><ul><li>SELECT * FROM DEMO3; </li></ul><ul><li>---------+---------+---------+---------+---------+---------+---------+--------- </li></ul><ul><li>SCHOOLNUM MY_NAME_COL RUN_DATE LOAD_IND STAT_RUN_DATE </li></ul><ul><li>---------+---------+---------+---------+---------+---------+---------+--------- </li></ul><ul><li>901 KING (MARTHA) ES 03/13/2002 Y 03/13/2002 </li></ul><ul><li>902 COX (DAVID) ES 03/13/2002 Y 03/13/2002 </li></ul><ul><li>903 THORPE ES 03/13/2002 Y 03/13/2002 </li></ul><ul><li>904 BARTLETT ES 03/13/2002 Y 03/13/2002 </li></ul><ul><li>This sql may be copied from PDFLIB.PJO.SQL(SAMPLDDL) </li></ul>
    18. 18. Using the New Procedures <ul><li>Database reports </li></ul><ul><ul><li>Run in PRF in the system you want the report for </li></ul></ul><ul><ul><li>Easiest way to find them is to enter L (for list) next to FORM under Opt, then change CREATOR to SYSAD2, then find the report in the list </li></ul></ul><ul><ul><li>You can also enter R (for Run) next to FORM under Opt, and enter SYSAD2.DEV_TABLE_COLS or whatever report you want under NAME </li></ul></ul><ul><li>Compile Requests </li></ul><ul><ul><li>2 nd line – May I delete the ALT or TEST load modules? I will only delete these if you answer YES or check the box. You can still run your test, as your library concatenation will find the load module in INTERIM or PROD, so please indicate YES unless you need the module kept. </li></ul></ul><ul><ul><li>Close CICS Trans – I will not do this unless requested. Be aware that users may get –805 when I have compiled but not yet done the new copy. If I disable the transaction, anyone trying to use it will get Resource Unavailable until it is back up. </li></ul></ul>
    19. 19. Summary <ul><li>Use the sandbox to create small tables for testing and experimenting. </li></ul><ul><li>You must create a tablespace first as a separate step before creating a table. </li></ul><ul><li>Objects can be created using screens in File-AID for DB2, or using DDL (data definition language) in SPUFI. </li></ul><ul><li>If your table is similar to one that already exists, use the existing table as a model, then delete the columns you don’t want and add any new columns </li></ul><ul><li>If you use the same name as an existing table, be careful to always use the correct creator when referring to your own table. </li></ul><ul><li>Objects no longer needed can be dropped (removed) using the DROP TABLE and/or DROP TABLESPACE commands, either in File-AID or SPUFI. (See screen prints.) </li></ul>

    ×