Posts

Showing posts from August, 2020

Basic Walkthrough DB2 Part-5

  Basic Walkthrough DB2 Part-5 In this part we will study some more useful database objects. For example VIEWS, TRIGGERS, PROCEDURES and few other. As we had an introduction to trigger creation in part 2, we will discuss how we run scripts first. DB2 supports different kind of scripts. You can run system shell scripts (.bat, .cmd, .js, .vbs,.sh and many more).   Let us try to understand how we can run scripts. Simple SQL script looks like   C:\Program Files\IBM\SQLLIB\BIN> db2 –t -f script.sql connect to sample; select id,name,dept,job from staff; select count(*) from staff; connect reset;   This was a simple SQL script. This is to be run in db2 command window. The syntax has been indicated in blue. Being an example script, I just listed few commands. In actual scripts these lines are usually over hundreds. Scripts can also be invoked in verbose mode (as echo on in DOS). C:\Program Files\IBM\S...

Basic Walkthrough DB2 Part-4

  Basic Walkthrough DB2 Part-4 In previous part we had created the database (single table database) and populated the table with some data. The data seemed all right and we had nice time retrieving the data. Except one that (friend of friend)’s last name begins with small ‘w’. We will correct this and move on to creating triggers and other stuff. Let us try updating the last name with capital ‘W’. We will see contents and update the row based on some unique parameters. Which means that while updating if our predicate selects more than one row, all selected rows will be updated. So be careful while identifying the target row. Update ADDRESS SET LNAME=’Walker’ Where PHONE=’ 419-932-9322’ DB20000I   The SQL command completed successfully. Thank God. The cor rection was cool. To have al look at the modified data issue the command : SELECT * FROM ADDRESS . The * basically means all columns . C:\Program Files\IBM\SQLLIB\BIN>db2 select * f...