Db2 400 Dasa

Embed Size (px)

DESCRIPTION

hello

Citation preview

DB2/400Data base files are of three types 1) physical files. 2) logical files. 3) field reference files.4) flat fileLogical files are of two types.1)Non-join logical files.(pfile keyword)2)Join logical files.Non-join logical files are of two types.1)single record format non-join logical file.2) Multi record format non-join logical file.Join logical files are again of three types.1)Natural join or inner join.2)Left Outer join.(jdftval).3)Self join.1) PHYSICAL FILES 1) PF1 0001.00 UNIQUE 0002.00 R PF1REC 0003.00 ENAME 20A 0004.00 ENO 4S RANGE(1 1000) 0005.00 ESAL 4S VALUES(1000 3000 9000) 0006.00 EAGE 2S 0007.00 EBASIC 4S 0008.00 ESEX 1A COMP(EQ 'M') r40009.00 EADD 50A CHECK(ME) 0010.00 EJD L DATFMT(*DMY) 0011.00 K ENO 2)PF90 0001.00 UNIQUE 0002.00 R PF90REC 0003.00 ENAME 20A 0004.00 ESAL 4S 0005.00 EID 4S 0006.00 K EID 3)PF91 0001.00 UNIQUE 0002.00 R PF91REC 0003.00 EID 4S 0004.00 EDEPT 4A 0005.00 EAGE 2S 0006.00 K EID 4)PF100 0001.00 A R REC1 0002.00 A NAME1 10A 0003.00 A ADDR 20A 5)PF101 0001.00 R REC2 0002.00 NAME2 10A 0003.00 TELEPHONE 8S 6)PF10 0001.00 R REC1 0002.00 NBR 3S 0 0003.00 NAME 20A 0004.00 K NBR 7)PF30001.00 0001.01 A R PFL 0003.00 A EMPNAME 20A 0004.00 A EMPNUM 3S 0005.00 A EMPAGE 2S 0006.00 A EMPSAL 6P 2 0007.00 A K EMPNAME 2) LOGICAL FILES 1) NON-JOIN LOGICAL FILES A) single record format non-join logical file.LF1 0001.00 R LF1REC PFILE(PF1) 0002.00 ENAME 0003.00 ENO 0004.00 ESAL 0005.00 K ENO b) Multi record format Non-join logical file.LF20001.00 R LF1REC PFILE(PF1) 0002.00 ENO 0003.00 ENAME 0004.00 K ENO 0005.00 R LF2REC PFILE(PF2) 0006.00 EDEPT 0007.00 ENO 0008.00 K ENO 2. JOIN LOGICAL FILES 2.1) ( natural join or inner join) JLF1 0001.00 R JREC JFILE(PF1 PF2) 0002.00 J JOIN(PF100 PF101) 0003.00 JFLD(NAME1 NAME2) 0004.00 JDUPSEQ(TELEPHONE *DESCEND) 0005.00 NAME1 0006.00 ADDR 0007.00 TELEPHONE b) JOIN LOGICAL FILES USING DUPLICATE SEQUENCE ( natural join or inner join) LF3 0001.00 R LF3REC JFILE(PF1 PF2) 0002.00 J JOIN(PF1 PF2) 0003.00 JFLD(ENO ENO) 0004.00 JDUPSEQ(ENAME) 0005.00 ENO JREF(PF1) 0006.00 EDEPT 07.0K ENO 2.2 ) JOIN LOGICAL FILES USING JDFTVAL.( since the file level keyword jdftval is used , it is called as left outer join logical file).LF4 0001.00 JDFTVAL 0002.00 R LF4REC JFILE(PF90 PF91) 0003.00 J JOIN(PF90 PF91) 0004.00 JFLD(EID EID) 0005.00 EID JREF(PF91) 0006.00 EDEPT 0007.00 K EID LF120001.00 JDFTVAL 0002.00 R LF123REC JFILE(PF2 PF1) 0003.00 J JOIN(PF2 PF1) 0004.00 JFLD(ENO ENO) 0005.00 ENO JREF(PF2) 0006.00 EDEPT 0007.00 ESAL 08.0K ENO JLF2 0000.01 JDFTVAL 0002.00 R JOINREC JFILE(PF10 PF11) 0003.00 J JOIN(PF10 PF11) 0004.00 JFLD(NBR NBR) 0005.00 NBR JREF(PF10) 0006.00 NAME 0007.00 SALARY 08.0K NBR 2.3) DYNSLT ALONG WITH JDFTVAL (SELECT/ OMIT KEYWORDS)LF1 0000.01 A DYNSLT 0001.00 JDFTVAL 0002.00 A R LREC1 JFILE(PF3 PF4) 0003.00 A J JOIN(PF3 PF4) 0004.00 A JFLD(EMPNUM EMPNUM) 0004.01 JDUPSEQ(EMPAGE) 0005.00 A EMPNUM JREF(PF3) 0006.00 A EMPNAME 0007.00 A EMPAGE 0008.00 A EMPSAL 0009.00 A K EMPNUM 0010.00 A O EMPNUM COMP(LT 502) 2.4) Self JoinSj1pf0001.00 R RCD10002.00 NBR 3S0003.00 NAME 10A DFT('NONE')0004.00 MGRNBR 3S NBR NAME MGRNBR 000001 235 shankar 440 000002 440 praveen 729 000003 500 srinivas 440 000004 729 srikanth 888 ****** ******** End of report ********SJ3 LF (Self join Source Member)0000.01 JDFTVAL0002.00 A R JOINREC JFILE(SJ1 SJ1)0003.00 A J JOIN(1 2)0004.00 A JFLD(MGRNBR NBR)0005.00 A NBR JREF(1)0006.00 A NAME JREF(1)0007.00 A MGRNAME RENAME(NAME)0008.00 A JREF(2)O/P:- NBR NAME NAME 000001 235 shankar praveen 000002 440 praveen srikanth 000003 500 srinivas praveen 000004 729 srikanth NONE 3) FIELD REFERENCE FILE RF1 (data base file)0002.00 A R RF1REC 0003.00 A EMPNUM 3S TEXT('EMPLOYEE NUMBER') 0004.00 A EMPNAME 20A 0005.00 A EMPAGE 2S 0006.00 A EMPSAL 6P 2 0007.00 A EMPTELPNUM 7S 3.1) PR1 (field reference file)0002.00 A REF(PVN/RF1) 0003.00 A R PR1REC 0004.00 A EMPNUM R 0005.00 A EMPNAME R 0006.00 A EMPAGE R 0007.01 A EMPSAL R 0008.00 A K EMPNUM 3.2) PHYSICAL FILE USING REF KEYWORD.PF2 0001.00 REF(PF1) 0002.00 R PF2REC TEXT('EMPLOYEE RECORD') d0003.00 ENO R 0004.00 EDEPT 4A 0005.00 K ENO 3.3) LOGICAL FILE USING REFACCPTH KEYWORD.0001.00 REFACCPTH(PRA1/PF1) 0002.00 R LFREC PFILE(PF1)BASIC COMMANDS1)To Create a Library - CRTLIB (TYPE *TEST & *PROD)2)To Create a Source PF CRTSRCPF 3)To Create a PF CRTPF < F4> or F6 option4)To Create a LF CRTLF or F6 option5)To Create a Field Reference File CRTPF ( MBR *NONE)6)To add a library to library list ADDLIBLE or EDTLIBL7)To enter data into a PF STRDFU UPDDTA8)To retrieve data from a PF RUNQRY *N 9)To add a member to a PF Prerequisite: CHGPF Max members :- 1 change to any other number & ADDPFM 10) To copy data from one object to another object CPYF 11) To get detailed description of an object DSPOBJD (Detail *Service)WRKOBJ (Detail *Service)12) To get the description of all fields of a PFDSPFFD < F4>13) To get all the Logical Files which are built over a PF DSPDBR 14) To get all the PFs used by a LFDSPFD 15) Use of DLTPCT parameter in a PF16) Use of RGZPFM & REUSEDLT (*YES) commands17) Use of REFACCPTH keyword18) Use of FORMAT keyword19) Use of MAINT parameter in a PF and types of access path maintenanceImmediate Access Path MaintenanceDelayed Access Path MaintenanceRebuild Access Path Maintenance ===============================================================FAQs related to DB2/400 part:-What are Database files?Database files are AS/400 objects that contain data or provide access to data.What are Device files?Device files contain no actual data, but gives introduction about how to use a particular device.Ex: - Printer File (PRTF), Display File (DSPF), Tape File (TAPF), Diskette File (DKTF)What are Save Files?Save Files are of type *File and attrib *Save are a special form of files that are used to save or restore data.Ex: - Similar to Log Files in Windows.What are DDM Files?DDM files are AS/400 objects, which represent files that exist on a remote machineImportant Points to be covered1.DSPFFD2.DSPFD3.DSPDBR4.DSPOBJD with parameter Detail (*service)5.WRKOBJ with parameter Detail (*service)6.Access Path & Open Data Path7.DSPPFM You can view the data that exists in a specific data member of a file by using DSPPFM command.8.Externally Described Files Data base files that are created with field level description are referred to as Externally Described Files.9.Program Described Files - Only the length of the record in the file is described to the system, the system does not know about the fields in the file. These database files are referred to as Program Described Files. Note: - by using RCDLEN parameter on CRTPF or CRTSRCPF.DB2 Limitations:-File name Max 10 CharactersRecord Format Name Max 10 Characters Field Name Max 10 CharactersIn a file Can 2 fields have same name? Can Record Format & Member have same name? FORMAT: - This keyword references another database file on AS/400 from which all the fields will be shared.DATFMT types in AS/400*MDY - mmddyy*DMY - ddmmyy*YMD - yymmdd*ISO yyyy-mm-dd*JOB It will accept as the format of the system.*JUL - yyddd*USA mm/dd/yyData types in AS/400 There are 9 data types in AS/4001.A - Character2.P Packed Decimal3.S Zoned Decimal 4.B Binary 5.F Floating point6.H Hexadecimal7.L Date 8.T Time9.Z Time StampHow will you read or update the records of the file which are using Arrival sequence access path?Using RRN Relative Record Number.Two Logical Files LF1 & LF2 are based on a Physical File PF1. The Unique Keyword is specified for LF1. If you use LF2 to add a record to PF1, can you add a record if it causes a duplicate key value in PF1?No. High Priority Questions:-Can you update a data base file using Join Logical Files?No, U can update a d/b file using Single Record Format Non Join Logical FileUsage of DDS Keyword REFACCPTH with real time example - to be covered with out failWhat is Level Check Error? Why does that occur and whats the logic behind it?Access path maintenance techniques1Immediate maintenance *immed ( Access paths used by referential constraints real time scenario to be given frequently used access paths)2Rebuild Maintenance 3Delayed maintenance ( use when there are relatively few changes to the access path while the file members are closed & reduce the system overhead by reducing the number of access paths to be maintained immediately)4To be covered individually with real time scenarioWhat are the prerequisites that need to be done before adding a member to PF? When u create a PF and did not fill up Maint parameter, then by default which access path will the system take & why with real time scenarioDifference between RGZPFM & REUSEDLT Disadvantage of REUSEDLT parameter over RGZPFM, even though both do the same work why RGZPFM is used over REUSEDLT?When did u use DYNSLT file level keyword in ur real time and pls explain it?Above 3 years exp & Low priority questionsNon - Usage of UNIT parameter using real time scenario to be covered with out fail- We avoid using UNIT parameter since managing auxiliary storage is a hazardous taskR+ (I*N)R Starting record count 10,000I No of records to add each time (increment) 1,000N Number of times to add the increment 3