How To Create A Table and Enter Records

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

Steps to create a table in DB using SPUFI.

1. Type 15 and press to enter into DB2 primary menu

2. Select option 1 (Type 1 in command space) to enter into SPUFI


3. If you have already created your data set for input and output, you can use them in the place of DATA
SET NAME. (Default names given by the admin will appear on the screen for the first time when you
enter into the SPUFI window).

4. You can create PS files for both input and output data sets and use them if you want.
(make sure that your output data set is sequential data set).
5. Press enter

6. You can write SQL queries to create a table here.


7. Press F3

8. You can see Edit session has completed. Now you can press enter to continue.
9. You can check the output file with statement execution was successful with sqlcode is 0.
Which means the table has been successfully created). You can also check the log message below.

10. Press F3 and enter to go back to the main input screen.


11. To check whether the table has been created, you can check by another query as below.

12. Comment the above create query and type select * from emp
13. Press F3 to back into SPUFI and press enter
We can see the table has been created by two variables (empname and empid).
Below in the log history we can see the no. of rows displayed is 0 as there are no record entries given till
now.

14. Press F3 and Enter to go back to the main window.


15. Now we will see how to enter the records
Write insert syntax
[** Note Comment all above create and select statements ]

16. Press F3 and enter to check the log record


No. of rows affected is 1 which says the query has been successfully completed.
17. Now if you want to verify the record entries whether they are added to the table, go back to main window
(F3) and use the query select and see.
[**Note - Every time we should make sure that other statements are commented so that those statements
are not executed]
Now use select statement and press F3 to check the log history

18. New records added

We can see that employee data has been added to the table successfully with sqlcode 0.
19. Now if you want to enter more record, repeat the above steps by insert statement.

Now we can see the no. of rows affecter are 1. If you want to check the table, use select query and see the
table entries.

20. New record inserted and check be viewed below.

Second record added successfully. Similarly you can add as many record as we need.
21. If you want to enter more than one record use multiple insert statements with different empname and
empid and follow the same steps as done above.

Press F2 and Check the log record.

You might also like