<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-35092861</id><updated>2012-01-31T17:17:20.761-07:00</updated><title type='text'>DB2 Diary from Radhesh</title><subtitle type='html'>Welcome to my Blog. This Blog is aimed towards sharing the concepts, new features, useful tips and best practices related with database administration of DB2 UDB on Linux, Unix and Windows (LUW). Occasionally, I may also share my thoughts on data, database, data center and DBA management in general. Your comments and feedback will be a valuable addition to my postings and I will highly appreciate it.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>26</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-35092861.post-1293481428793603345</id><published>2010-03-20T11:19:00.012-06:00</published><updated>2010-03-20T12:00:53.114-06:00</updated><title type='text'>Where a DB Request Spends Time in DB2 9.7?</title><content type='html'>&lt;div style="text-align: justify;"&gt;This title may sound somewhat familiar if you have been following my Blog for over a year. More than a year ago, I wrote about the shortcomings of time spent monitoring in DB2 (see my post “&lt;a href="http://radheshk.blogspot.com/2009/01/while-analyzing-slow-response-or-poor.html"&gt;Where a DB Request Spends Time&lt;/a&gt;”). Last year when DB2 9.7 was released (around June 2009), I was thrilled to see “&lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.wn.doc/doc/c0055023.html"&gt;Time-spent monitor elements are more comprehensive&lt;/a&gt;” under monitoring enhancements in DB2 9.7. Since then I have been thinking about installing DB2 9.7 on my laptop and having a closer look at this enhancement. Finally, I got chance to do so and here I am going to share my findings.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Without spending too much time trying to come up with a more complex workload, I created a table t3 with similar structure as syscat.columns and populated it with rows from syscat.columns. Then I ran a query against this table as shown below.  The real elapsed time of this SQL was more than 38 minutes (long enough for my analysis purpose).&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 1&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Jidj7mFZ_XY/S6UFlcE78VI/AAAAAAAAAFs/uD3sXqjByGE/s1600-h/Listing1.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 172px;" src="http://4.bp.blogspot.com/_Jidj7mFZ_XY/S6UFlcE78VI/AAAAAAAAAFs/uD3sXqjByGE/s400/Listing1.gif" alt="" id="BLOGGER_PHOTO_ID_5450769064752050514" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Before I start analyzing the time spent by above SQL, let me list some of the queries that I used for this analysis.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Following query gives the client idle wait time, total request time, total wait time and various processing times for each connection in the database.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 2&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Jidj7mFZ_XY/S6UGRl8KAVI/AAAAAAAAAF0/RqmWco9vOgc/s1600-h/Listing2.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 193px;" src="http://4.bp.blogspot.com/_Jidj7mFZ_XY/S6UGRl8KAVI/AAAAAAAAAF0/RqmWco9vOgc/s400/Listing2.gif" alt="" id="BLOGGER_PHOTO_ID_5450769823313822034" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;If you are interested to drill down the total wait time of each connection, following query can be used.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 3&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Jidj7mFZ_XY/S6UG4EqVwfI/AAAAAAAAAF8/mIYJtG30PNI/s1600-h/Listing3.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 263px;" src="http://1.bp.blogspot.com/_Jidj7mFZ_XY/S6UG4EqVwfI/AAAAAAAAAF8/mIYJtG30PNI/s400/Listing3.gif" alt="" id="BLOGGER_PHOTO_ID_5450770484395622898" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;A connection can have more than one Unit of Work (UOW) and if you are interested to monitor the time spent on UOW level, following query can be used.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 4&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jidj7mFZ_XY/S6UHYKUz9CI/AAAAAAAAAGE/oP7PqCPy37g/s1600-h/Listing4.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 206px;" src="http://3.bp.blogspot.com/_Jidj7mFZ_XY/S6UHYKUz9CI/AAAAAAAAAGE/oP7PqCPy37g/s400/Listing4.gif" alt="" id="BLOGGER_PHOTO_ID_5450771035671753762" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Again, if you want to drill down the total wait time of each UOW, following query can be used.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 5&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Jidj7mFZ_XY/S6UHlbcTaUI/AAAAAAAAAGM/k6C9pwAhpiE/s1600-h/Listing5.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 277px;" src="http://4.bp.blogspot.com/_Jidj7mFZ_XY/S6UHlbcTaUI/AAAAAAAAAGM/k6C9pwAhpiE/s400/Listing5.gif" alt="" id="BLOGGER_PHOTO_ID_5450771263604877634" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;If you are interested to monitor time spent on statement level, you can use &lt;span style="font-family: courier new;"&gt;mon_get_pkg_cache_stmt&lt;/span&gt; table function. Following query gives info on time spent by top 10 dynamic SQL statements (sorted by statement execution time).&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 6&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Jidj7mFZ_XY/S6UHxncCzRI/AAAAAAAAAGU/0JCfSVHgozY/s1600-h/Listing6.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 175px;" src="http://4.bp.blogspot.com/_Jidj7mFZ_XY/S6UHxncCzRI/AAAAAAAAAGU/0JCfSVHgozY/s400/Listing6.gif" alt="" id="BLOGGER_PHOTO_ID_5450771472983444754" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;If you want to drill down the wait time of dynamic SQL statements returned by above query, following query can be used.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 7&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jidj7mFZ_XY/S6UIBX6yFvI/AAAAAAAAAGc/UDvHzh7R7tU/s1600-h/Listing7.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 240px;" src="http://3.bp.blogspot.com/_Jidj7mFZ_XY/S6UIBX6yFvI/AAAAAAAAAGc/UDvHzh7R7tU/s400/Listing7.gif" alt="" id="BLOGGER_PHOTO_ID_5450771743695312626" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In all the above monitoring queries (Listing 2 through 7), I have intentionally left the WHERE clause as you can use the appropriate WHERE clause as per your specific need. Also, the result set of monitoring table functions used in above queries can be altered through the input parameters passed to those table functions. Check the documentation of these table functions for more detail.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In each of the above monitoring queries, SELECT list has indentation and the indented columns give the individual components of the time spent monitoring element selected just before the indented columns. “&lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.admin.mon.doc/doc/c0055434.html"&gt;Hierarchy of time-spent monitor elements&lt;/a&gt;” on DB2 Information Center was very helpful while writing above queries. Also, you might have noticed the most of the wait time components are suffixed with “_wait_time” and similarly most of the processing time components are suffixed with “_proc_time”. Any remaining ambiguities get clarified by looking at the documented hierarchy of time-spent monitor elements.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Though, I found the time-spent monitoring elements available at each level (Connection, UOW, Statement) comprehensive, here I am going to present only the UOW level time spent monitoring for the SQL execution in Listing 1.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Here is the output of &lt;span style="font-family: courier new;"&gt;db2_mon_uow.sql&lt;/span&gt; at the end of SQL execution in Listing 1. To make it more readable, I have presented it vertically.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 8&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Jidj7mFZ_XY/S6UINz4n5RI/AAAAAAAAAGk/2QNkO5uVMBQ/s1600-h/Listing8.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 196px;" src="http://2.bp.blogspot.com/_Jidj7mFZ_XY/S6UINz4n5RI/AAAAAAAAAGk/2QNkO5uVMBQ/s400/Listing8.gif" alt="" id="BLOGGER_PHOTO_ID_5450771957360878866" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In the above output and in fact in all the columns selected in Listing 2 through 7, the unit of time is millisecond.  As you can see total request time (~2242 seconds) is very close to sum of various time components (~2237 seconds) that constitutes the total request time. Even a minor difference (5 seconds or 0.2 %) can be clearly explained by “Other” category as documented under “&lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.admin.mon.doc/doc/c0055434.html"&gt;Hierarchy of time-spent monitor elements&lt;/a&gt;” on DB2 Information Center. Though, the real elapsed time as shown in the output of “time” command (in Listing 1) is higher than the total request time reported by DB2, it can be due to the difference in time recording boundaries used by “time” command versus what’s used by DB2.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Similarly, if you want to drill down the total wait time, here is the output from &lt;span style="font-family: courier new;"&gt;db2_mon_uow_wait.sql&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 9&lt;/span&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jidj7mFZ_XY/S6UISWamMSI/AAAAAAAAAGs/hfWYToISgXQ/s1600-h/Listing9.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 266px;" src="http://3.bp.blogspot.com/_Jidj7mFZ_XY/S6UISWamMSI/AAAAAAAAAGs/hfWYToISgXQ/s400/Listing9.gif" alt="" id="BLOGGER_PHOTO_ID_5450772035349655842" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The difference between total wait time and sum of individual wait time components is just 65 milliseconds.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;With this time spent monitoring enhancement, now we can easily find out where a DB request is spending maximum time and accordingly address any problem areas in database if present. Kudos to IBM DB2 team for putting this enhancement in DB2 9.7.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-1293481428793603345?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/1293481428793603345/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=1293481428793603345&amp;isPopup=true' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/1293481428793603345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/1293481428793603345'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2010/03/where-db-request-spends-time-in-db2-97.html' title='Where a DB Request Spends Time in DB2 9.7?'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_Jidj7mFZ_XY/S6UFlcE78VI/AAAAAAAAAFs/uD3sXqjByGE/s72-c/Listing1.gif' height='72' width='72'/><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-3540793375247775118</id><published>2010-02-02T22:21:00.002-07:00</published><updated>2010-02-02T22:36:39.943-07:00</updated><title type='text'>DBA's Strengths</title><content type='html'>&lt;div style="text-align: justify;"&gt;Did you ever get so engrossed doing something that hours passed by and you did not even realize? It might have happened while watching an interesting movie or playing your favorite video game or similar fun stuff.  But did it ever happen while doing your DBA job, the job which pays you salary? I am sure it must have happened unless you are in a completely wrong profession. However, how often does it happen? Do you enjoy doing everything that you have been doing as a DBA? Most likely your answers would be “rarely” and “no”. Imagine how productive you would be if we flip this situation such that most of your job related activities fall under the category which you enjoy doing? Such activities are basically your &lt;span style="font-style: italic;"&gt;strengths&lt;/span&gt; and you have a natural inclination towards such activities.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Marcus Buckingham, a speaker, trainer, researcher and author has been involved in finding solutions to exactly this type of workplace issues.  I got chance to read some of his books (First Break All the Rules, Now Discover Your Strengths, Go Put Your Strengths to Work) and a core finding  in his books can be summarized as:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify; font-style: italic;"&gt;We should try to identify our strengths and focus on our strengths to further grow it rather than spend all our time and effort on our weaknesses. Also, the best managers work hard to understand what their employee’s true talents/strengths are and then shape the job to allow the employee to perform to their maximum. It doesn't pay to focus on people's weaknesses; focus on their strengths.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In his book “Go Put Your Strengths to Work”, he lists following four signs that can help you identify your strengths:&lt;br /&gt;&lt;/div&gt;&lt;ul style="font-style: italic;"&gt;&lt;li&gt;When you do it, you feel effective&lt;/li&gt;&lt;li&gt;Before you do it, you actively look forward to it&lt;/li&gt;&lt;li&gt;While you are doing it, you feel inquisitive and focused&lt;/li&gt;&lt;li&gt;After you’ve done it, you feel fulfilled and authentic&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;If you are interested to learn more about his works, I would recommend reading his books. I would not be able to create the same impact in this blog even if I try to. However, here I would like to analyze his suggestions in context of DBA job and DBA team.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Traditionally, DBA roles have been classified as Application DBA, System DBA, Development DBA, Production DBA etc. These are very broad classifications and DBAs under each category still end up doing many of the activities which are not their strengths and they don’t enjoy doing it. The challenge is how to setup a DBA team where each DBA enjoys doing most of the activities that he is doing. First I will approach this problem from a DBA Manager’s perspective and then from an individual DBA’s perspective.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;First of all, each DBA in the team should try to find out if they even like doing DBA job or they should pursue a different profession. After this high level elimination round, the team should be left of only those DBAs who really like being a DBA. Next we have to focus on how to distribute the responsibilities in such a way that most of the DBAs enjoy doing most of their assigned activities. For that, we have to first list down the activities on a more granular level that can really be associated with the likes (strengths) and dislikes (weaknesses) of a DBA. For example, here I have listed some of the DBA activities. They can be made more granular if required. Many more such activities can be added to the list.&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Analyzing new application requirements and associated database changes&lt;/li&gt;&lt;li&gt;Converting a new database logical design to physical design&lt;/li&gt;&lt;li&gt;Creating new database&lt;/li&gt;&lt;li&gt;Storage capacity planning&lt;/li&gt;&lt;li&gt;SQL tuning&lt;/li&gt;&lt;li&gt;Configuration parameter tuning&lt;/li&gt;&lt;li&gt;Creating database standards and naming conventions&lt;/li&gt;&lt;li&gt;Performing database upgrades&lt;/li&gt;&lt;li&gt;Physical design of DDL changes &lt;/li&gt;&lt;li&gt;Implementing DDL changes&lt;/li&gt;&lt;li&gt;Performance diagnosis&lt;/li&gt;&lt;li&gt;Setting up performance monitoring&lt;/li&gt;&lt;li&gt;Troubleshooting database errors&lt;/li&gt;&lt;li&gt;Automating repetitive and mundane tasks&lt;/li&gt;&lt;li&gt;Exploring and implementing DBMS new features&lt;/li&gt;&lt;li&gt;Managing database scheduled jobs &lt;/li&gt;&lt;li&gt;Reacting to database user complains&lt;/li&gt;&lt;li&gt;Performing database security review&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;After listing the activities on such a granular level, each DBA should try to identify top 4 to 6 activities that really show the signs of being their strengths. The activities which show the signs opposite to that of strengths are the weaknesses and each DBA should also identify top 4 to 6 activities that are their weaknesses. In fact more activities will get added to the list while DBAs will be trying to identify their strengths and weaknesses. Once all the DBAs have identified their strengths and weaknesses, the responsibilities should be assigned in such a way that each DBA should be doing more of their strengths and less of their weaknesses.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;A common concern about this approach is, if every DBA will be doing the interesting stuff, who will do the boring stuff. In my experience, interesting and boring words are very subjective. Something that is interesting to me does not have to be interesting for others also and vice versa. One can argue, who will find it interesting to resolve an alert in the middle of night. However, we should try to separate the actual activity with the circumstances under which we are doing it. We have to find out if the DBA hates resolving the alert or just because it’s in the middle of night. I agree there are few mundane things that most DBAs will hate doing. Wherever possible such mundane activities should be automated. This way, analyzing each activity carefully and assigning the responsibilities considering strengths and weaknesses of individual DBAs will result in a team where each DBA will do more of what they enjoy doing and will enhance the team productivity.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In reality, going through this whole exercise will not be as simple as it sounds here. For an individual DBA, just identifying his strengths and weaknesses will require lot of introspection over a period of several weeks. Some caution is required while identifying the strengths and weaknesses. Normally, we attach a hypothetical superiority or inferiority with each activity and we desire to do only the superior activities. We think that we will enjoy doing those activities and they are our strengths.  However, our strengths are those which pass the litmus test of above mentioned 4 signs and not the activities which we think superior and desire to do it. Strengths should also not be confused with Skills. There are many activities that we are very skilled at because we have done it several times, however they might not necessarily reflect the 4 signs of strengths. This strength based approach of assigning roles and responsibilities within DBA team will require more introspection from each individual DBA as well as more managerial effort from the manager, however it’s worth doing.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;If you are a DBA and your manager has no interest in strength based assignment of roles and responsibilities, you can still apply these techniques at least for you (or maybe along with some of your colleagues). You might be thinking that you do what your manager assigns to you. However, consciously or sub- consciously you also play a major role in deciding what activities you do more and what you do less. After identifying your strengths, you can try to volunteer more in the areas of your strengths and wherever possible reduce your involvement in the areas of your weaknesses.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-3540793375247775118?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/3540793375247775118/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=3540793375247775118&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/3540793375247775118'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/3540793375247775118'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2010/02/dbas-strengths.html' title='DBA&apos;s Strengths'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-3614147923061493446</id><published>2010-01-13T23:19:00.002-07:00</published><updated>2010-01-13T23:26:08.922-07:00</updated><title type='text'>Multi-terabyte</title><content type='html'>&lt;div style="text-align: justify;"&gt;After a long gap, I am back again to share some of my thoughts. Leaving my Blog dry for so long makes me feel drained as well. However, I try to console myself thinking now it’s the age of information overload. Also, the growth of community websites in past few years is pouring so much information that it’s difficult for one to cope up with it. Hence, no harm slowing down my contribution to this information overload :)&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Even though I was not posting anything on my Blog, I was not completely detached from it. In the meanwhile, I was tackling with the junk comments on my posts :)  Yes, you read it correctly... junk comments, not junk emails. Since the email applications already have ways to filter out most of the junk emails, the junkies are targeting blogs now.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;One day while looking at my blog, my eyes got stuck at a keyword used in my profile and triggered a chain of thoughts... this word was “multi-terabyte”.  I recalled when I had written that profile, I did not mean more than 10 terabytes by it. Just 5 years ago from now, a 10 terabyte data warehouse was considered to be huge and working with such databases used to make me feel privileged.  However, now a days I doubt if anyone will consider a smaller than 100 terabyte data warehouse huge. In fact, we have already started talking about petabyte size of data warehouses.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;That naturally makes me think, will DB2 be able to support muti-petabyte warehouses in future with its current architecture. If not, what’s there in IBM’s roadmap to support such warehouses? Well, I have not heard much except the empty promises that current scalability features (data partitions, balanced configuration units etc.) should be able to tackle it.  Beyond DB2 world, I do see some promising work and an important one to note would be Column-oriented DBMS.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Column-oriented DBMS is not a new concept, though recently it has started getting more traction. If you are hearing about it first time, you can get a quick overview of it on the &lt;a href="http://en.wikipedia.org/wiki/Column-oriented_DBMS"&gt;Wikipedia&lt;/a&gt;. Also, you will find tons of articles regarding it if you &lt;span style="font-style: italic;"&gt;google&lt;/span&gt; it. IBM has been downplaying column-oriented DBMS mentioning that it’s not suitable for all type of workloads in data warehousing environment, the companies who provide Column-oriented DBMS still have a very small footprint in the data warehousing market and so on. These arguments are basically deviating the discussion from the main point.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The important question is, will the majority of workload in data warehousing environment greatly benefit by Column-oriented DBMS approach or not. And the researches on this topic have answered this question affirmatively. Also, I have not come across any clear statement from IBM or IBMers disproving this fact. Well, I am not proposing that IBM should change DB2 from row-oriented to column-oriented or come up with a brand new column-oriented DBMS. However, it can provide an option for column-oriented tables in DB2. May be it will make more sense to have this option on table space level and all the tables under that table space will be stored column-oriented. Please don’t take me wrong, I don’t think this feature is going to be so easy to implement. I can anticipate its far reaching impact on DB2 core engine and optimizer, but so what? When IBM came up with hybrid XML/relational DB2 engine for native support of XML data, it was not a simple feature. If I recall correctly, IBM publicized it to involve 5 years of development time by a large development team.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;The next important question is, is it worth investing so much effort in column-oriented table space feature. I think it is... because it will prepare DB2 for the next generation data warehouses. DB2 has been stronger in the data warehousing market compared to OLTP and this feature will help it become even stronger in the data warehousing market. However, I am curious to hear your thoughts on this.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-3614147923061493446?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/3614147923061493446/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=3614147923061493446&amp;isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/3614147923061493446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/3614147923061493446'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2010/01/multi-terabyte.html' title='Multi-terabyte'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-3452277226097840218</id><published>2009-06-20T17:10:00.005-06:00</published><updated>2009-06-20T17:43:28.098-06:00</updated><title type='text'>SQL Tips &amp; Techniques- String Splitting</title><content type='html'>&lt;div style="text-align: justify;"&gt;In my previous post &lt;a href="http://radheshk.blogspot.com/2008/02/sql-tips-techniques-string-aggregation.html"&gt;SQL Tips &amp;amp; Techniques- String Aggregation&lt;/a&gt;, I discussed how to perform string aggregation. Recently, I received a question to do the reverse using SQL i.e. String Splitting.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 1&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jidj7mFZ_XY/Sj1uGfZe9ZI/AAAAAAAAAFI/vrwm35A1xM0/s1600-h/Listing1.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 163px;" src="http://3.bp.blogspot.com/_Jidj7mFZ_XY/Sj1uGfZe9ZI/AAAAAAAAAFI/vrwm35A1xM0/s400/Listing1.gif" alt="" id="BLOGGER_PHOTO_ID_5349552990172673426" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;For example, we have a table myTab2 with column values as shown above.  As you can see, the string value in LIST column is a list of sub-strings separated with “, “. Now, we would like to split the string in LIST column and present the sub-strings in separate rows. Hence, the query should return two rows for CATEGORY = 1, three rows for CATEGORY = 2 and two rows for CATEGORY = 3.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Here is the query that performs the required string splitting.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Jidj7mFZ_XY/Sj1udNrISOI/AAAAAAAAAFQ/XeDiZDjLurM/s1600-h/Listing2.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 334px;" src="http://4.bp.blogspot.com/_Jidj7mFZ_XY/Sj1udNrISOI/AAAAAAAAAFQ/XeDiZDjLurM/s400/Listing2.gif" alt="" id="BLOGGER_PHOTO_ID_5349553380551837922" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The above query uses recursive SQL and it will return the following.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jidj7mFZ_XY/Sj1u1LCPlBI/AAAAAAAAAFY/OpFcGbLBoPA/s1600-h/Listing3.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 217px;" src="http://3.bp.blogspot.com/_Jidj7mFZ_XY/Sj1u1LCPlBI/AAAAAAAAAFY/OpFcGbLBoPA/s400/Listing3.gif" alt="" id="BLOGGER_PHOTO_ID_5349553792160338962" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I learned the above use of recursive SQL from Knut Stolze’s developerWorks article &lt;a href="http://www.ibm.com/developerworks/db2/library/techarticle/0303stolze/0303stolze1.html"&gt;Parsing Strings in SQL&lt;/a&gt;. If you know a different way to do the string splitting using SQL, please share it.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-3452277226097840218?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/3452277226097840218/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=3452277226097840218&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/3452277226097840218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/3452277226097840218'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2009/06/sql-tips-techniques-string-splitting.html' title='SQL Tips &amp; Techniques- String Splitting'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Jidj7mFZ_XY/Sj1uGfZe9ZI/AAAAAAAAAFI/vrwm35A1xM0/s72-c/Listing1.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-7875001108591623865</id><published>2009-04-11T20:01:00.007-06:00</published><updated>2009-04-11T20:35:20.512-06:00</updated><title type='text'>DB2 Authentication &amp; Password Encryption Method</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;Few days ago, I received an e-mail from my colleague with following error message&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Jidj7mFZ_XY/SeFRwzWHpOI/AAAAAAAAAEY/pUqv61Veho4/s1600-h/Listing1.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 50px;" src="http://2.bp.blogspot.com/_Jidj7mFZ_XY/SeFRwzWHpOI/AAAAAAAAAEY/pUqv61Veho4/s400/Listing1.gif" alt="" id="BLOGGER_PHOTO_ID_5323626133387191522" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;I verified the password of db2inst1 on OS level and the password “db2test” was correct. I verified the authentication related configuration parameters and everything looked okay. The authentication type was set to SERVER. The connection was working fine if we only run “db2 connect to test” and do not specify user and using keywords. The version of DB2 was 8.1 and the OS was SUSE Linux Enterprise Server 10.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;&lt;br /&gt;&lt;br /&gt;You might be thinking how come I am still dealing with DB2 version 8.1. Well, as I have mentioned in my earlier posts, the company I work for (Stratavia Corporation) has software product for data center automation called &lt;/span&gt;&lt;a style="font-family: georgia;" href="http://www.stratavia.com/datapalette.php"&gt;Data Palette&lt;/a&gt;&lt;span style="font-family:georgia;"&gt;. Data Palette still supports DB2 V8.1 and hence we have to test it on DB2 V8.1 also. Going back to the original problem, I approached our system administrator to figure out what is so unique about db2inst1 password that is causing the above authentication error. We found that the password encryption method used for db2inst1 was different than the other V8.1 instances where we don’t have the above mentioned authentication problem. On this problematic system, the password encryption method was “blowfish”. We changed it to “md5” as shown in the portion of “/etc/default/passwd” below. On SUSE Linux, “/etc/default/passwd” has the configuration parameter to control the password encryption method.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Jidj7mFZ_XY/SeFR2k_Xq7I/AAAAAAAAAEg/Aid4zHK-NIg/s1600-h/Listing2.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 59px;" src="http://1.bp.blogspot.com/_Jidj7mFZ_XY/SeFR2k_Xq7I/AAAAAAAAAEg/Aid4zHK-NIg/s400/Listing2.gif" alt="" id="BLOGGER_PHOTO_ID_5323626232612891570" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;After changing the password encryption method, we set the password of db2inst1 and it was encrypted using md5 this time. On Linux systems, you can check the encrypted password in /etc/shadow file (you have to be root). The length of blowfish encrypted password is almost double than md5 encrypted password. Also, I think md5 encrypted password starts with $1 and blowfish encrypted password starts with $2.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;&lt;br /&gt;&lt;br /&gt;After the above change, the authentication problem was gone. So it appears DB2 V8.1 (Fix pack 0) does not support authentication with password that is encrypted using blowfish encryption. Out of curiosity, I upgraded the same instance to V8.2 to test if blowfish password encryption will work or not and with V8.2 blowfish encryption worked fine. Hence, we should keep in mind that DB2 authentication (while using OS authentication) has dependency on password encryption method used by OS. The user password may work fine on the OS level, but DB2 authentication may still fail if DB2 does not support the password encryption method used by OS.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-7875001108591623865?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/7875001108591623865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=7875001108591623865&amp;isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/7875001108591623865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/7875001108591623865'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2009/04/db2-authentication-password-encryption.html' title='DB2 Authentication &amp; Password Encryption Method'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Jidj7mFZ_XY/SeFRwzWHpOI/AAAAAAAAAEY/pUqv61Veho4/s72-c/Listing1.gif' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-4788888692564336293</id><published>2009-02-16T07:54:00.003-07:00</published><updated>2009-02-18T10:15:21.333-07:00</updated><title type='text'>DB2 and EC2</title><content type='html'>&lt;div style="text-align: justify;"&gt;Though irrelevant, there is a similarity of alphabetical pattern between DB2 and EC2. E comes just after D and C comes just after B in the alphabet. May be this similarity aroused my interest in EC2... J Also, IBM and Amazon have partnered together to deliver DB2 in Amazon EC2 (Elastic Compute Cloud) environment.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Cloud computing, the biggest buzz word in current date, is no more perceived as mere hype. It has already started helping small startup companies. There are new businesses emerging on top of cloud computing infrastructure. Gradually more and more companies will start embracing the cloud computing.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Though I have been hearing about cloud computing for over a year, I never bothered to think about how similar or different it would be managing DB2 databases hosted in cloud computing environment. When I read the IBM’s &lt;a href="http://money.cnn.com/news/newsfeeds/articles/marketwire/0473370.htm"&gt;announcement&lt;/a&gt; (actually followed the link from Anant Jhingran’s &lt;a href="http://jhingran.typepad.com/anant_jhingrans_musings/2009/02/ibms-middleware-services-on-amazon.html"&gt;blog post&lt;/a&gt;), it crossed my mind that very soon we DBA’s may have to deal with the DB2 instances hosted in the cloud computing environment. Suddenly, several questions started arising in my mind. Will it be accessible through web browser only or we can still use our favorite SSH client or Remote Desktop (in case of Windows)? How will be the database physical design? Can we also access these virtual servers through VPN and so on...?&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Out of curiosity, I thought of signing up for the Amazon’s service and get a feel of EC2. Looking at their &lt;a href="http://aws.amazon.com/ec2/#pricing"&gt;pricing&lt;/a&gt;, it did not appear to cost much just to get a feel of it. On a second thought, I decided to go through their &lt;a href="http://aws.amazon.com/documentation/"&gt;documentation&lt;/a&gt; first. The documentation is concise and to the point. It helped to clear the clouds over my understanding of Elastic Compute Cloud.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Here is a very high level summary of what I learned about EC2 from their documentation.&lt;br /&gt;&lt;ol&gt;&lt;li style="text-align: justify;"&gt;The virtual servers in EC2 environment are basically the running instances of AMI (Amazon Machine Image). AMI contains all the software, including OS and associated configuration settings, applications, libraries etc. &lt;/li&gt;&lt;li style="text-align: justify;"&gt;There are already many existing AMI (free as well as paid). Also, new AMI can be created from scratch or based on an existing AMI. However, new AMI has to be saved on Amazon S3 (Simple Storage Service) and there is a charge for this storage.&lt;/li&gt;&lt;li style="text-align: justify;"&gt;There are different types of instances based on CPU, Memory, Storage and I/O requirements and accordingly Amazon has different pricing for each type of instance.&lt;/li&gt;&lt;li style="text-align: justify;"&gt;AMI instances are not persistent. You lose all the changes when you shutdown your OS or terminate the AMI instance. &lt;/li&gt;&lt;li style="text-align: justify;"&gt;For all the online data that requires persistence (for example, a DB2 database), they have a different solution. It’s called Elastic Block Store (EBS). EBS is storage volume that can be attached to the host (running instances of AMI) and it can either be used as raw device or a file system can be created on it. &lt;/li&gt;&lt;li style="text-align: justify;"&gt;Snapshots of EBS can be created on the Amazon S3 (Simple Storage Service). EBS snapshot can be used to launch new EBS volumes using the previous snapshot as the starting point of those new volumes.&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Static IP addresses can also be assigned to instances. They are called Elastic IP address.&lt;/li&gt;&lt;li style="text-align: justify;"&gt;We can access the servers hosted in EC2 environment using SSH client or Remote Desktop. &lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I like the ease of provisioning, server downsizing and upsizing available in EC2 environment. Also, it appears to me that set up and maintenance of disaster recovery and business continuity solutions will be relatively easier in EC2 environment. Testing the additional computing power (capacity planning) for increased workload will be much easier and cost effective. We don’t have to make permanent investment in computing power and then later realize that the investment did not solve the capacity problem.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Having said all the good things about EC2, I do agree that we will come across several unpleasant aspects of it when we start using it. I found some of the experiences discussed on &lt;a href="http://www.daemonology.net/blog/2009-01-19-broken-s3-sla.html"&gt;Colin Percival’s blog&lt;/a&gt;.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In general, one of the big concerns about cloud computing is company policies and security issues related with storing company’s data outside company network. Though EC2 appears to have reasonable security provision, I am not an expert on network security and hence I will abstain from making any comment on security. However, if cloud computing provides or will provide robust security, I would anticipate revisions in company policies over a period of time to adapt to the new computing environment.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-4788888692564336293?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/4788888692564336293/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=4788888692564336293&amp;isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4788888692564336293'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4788888692564336293'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2009/02/db2-and-ec2.html' title='DB2 and EC2'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-8140617103344593990</id><published>2009-01-13T20:35:00.009-07:00</published><updated>2009-01-13T21:07:08.827-07:00</updated><title type='text'>Where a DB Request Spends Time?</title><content type='html'>&lt;div style="text-align: justify;"&gt;While analyzing slow response or poor database performance, you might be curious to know where a database request spends time. This information will feed to database performance intelligence and guide the tuning effort in the right direction. However, I doubt if anyone ever found a satisfactory answer to this question for a DB2 database.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Basically, a database request may spend time either waiting for a service (wait time) or being serviced (service time). In fact this applies to any request to a computer system. The total time spent by a database request should be sum total of all the wait times and the service times for that request. Also, a database request may spend time inside the database system as well as outside the database system (e.g. Network). For a database request, the monitoring features of a database system should ideally provide all these wait times and service times spent inside database system.&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In this post I will investigate the monitoring info available through db2batch and snapshot monitoring in attempt to identify the individual components that make up the total time spent by a SQL statement. First, I will investigate the monitoring info captured by &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/core/r0002043.htm"&gt;db2batch&lt;/a&gt;. Listing 1 shows the SQL script I used for db2batch test&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Jidj7mFZ_XY/SW1eGqa31iI/AAAAAAAAAC0/mqconIhDeQ0/s1600-h/Listing1.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 57px;" src="http://1.bp.blogspot.com/_Jidj7mFZ_XY/SW1eGqa31iI/AAAAAAAAAC0/mqconIhDeQ0/s400/Listing1.gif" alt="" id="BLOGGER_PHOTO_ID_5290988605789427234" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;In case you are curious about the definition of table t1, it has the same structure as syscat.columns and I inserted all the rows from syscat.columns four times into t1. Also, t1 is created under a DMS tablespace with the associated buffer pool of just 1000 4K pages.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;PERF_DETAIL 3 instructs db2batch to capture summary of monitoring information. Listing 2 shows the db2batch output after filtering out all the lines not related with time from the monitoring info&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Listing 2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Jidj7mFZ_XY/SW1exdspU1I/AAAAAAAAAC8/hf5vcOcyqG0/s1600-h/Listing2.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 372px;" src="http://2.bp.blogspot.com/_Jidj7mFZ_XY/SW1exdspU1I/AAAAAAAAAC8/hf5vcOcyqG0/s400/Listing2.gif" alt="" id="BLOGGER_PHOTO_ID_5290989341108687698" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;The SQL statement took total 130.567 seconds. Out of which Agent CPU Time was 124.36 seconds, but what about the remaining time (6.207 seconds). Even if we assume that buffer pool read time is not inclusive in Agent CPU Time, still it does not sum up to total elapsed time.&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Next I will investigate the DB2 snapshot monitoring and identify any time related stats. Ideally, a database request should correspond to a statement. However, application level snapshot provides more time related stats, hence I will present a test example using application snapshot.&lt;/div&gt;&lt;br /&gt;I created a test script as shown in Listing 3:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jidj7mFZ_XY/SW1ffOyHWlI/AAAAAAAAADE/9BqQwGIJrec/s1600-h/Listing3.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 118px;" src="http://3.bp.blogspot.com/_Jidj7mFZ_XY/SW1ffOyHWlI/AAAAAAAAADE/9BqQwGIJrec/s400/Listing3.gif" alt="" id="BLOGGER_PHOTO_ID_5290990127379077714" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I ran the script with the time command as shown below&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Listing 4&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Jidj7mFZ_XY/SW1gAcSv_nI/AAAAAAAAADM/0TCQUsdKKx4/s1600-h/Listing4.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 78px;" src="http://4.bp.blogspot.com/_Jidj7mFZ_XY/SW1gAcSv_nI/AAAAAAAAADM/0TCQUsdKKx4/s400/Listing4.gif" alt="" id="BLOGGER_PHOTO_ID_5290990697941302898" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Here is the content of test.out&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Listing 5&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Jidj7mFZ_XY/SW1gmZLA06I/AAAAAAAAADU/peaeb3KOOyg/s1600-h/Listing5.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 168px;" src="http://1.bp.blogspot.com/_Jidj7mFZ_XY/SW1gmZLA06I/AAAAAAAAADU/peaeb3KOOyg/s400/Listing5.gif" alt="" id="BLOGGER_PHOTO_ID_5290991349938574242" border="0" /&gt;&lt;/a&gt;Listing 6 shows the time related lines from the application snapshot&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Listing 6&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Jidj7mFZ_XY/SW1hhmrL33I/AAAAAAAAADc/-BCFbwpwOUo/s1600-h/Listing6.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 145px;" src="http://1.bp.blogspot.com/_Jidj7mFZ_XY/SW1hhmrL33I/AAAAAAAAADc/-BCFbwpwOUo/s400/Listing6.gif" alt="" id="BLOGGER_PHOTO_ID_5290992367175458674" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: justify;"&gt;Now let’s try to analyze the output of this test. The script test.sh took 2 minutes and 11.12 seconds (131.12 seconds). The query was run locally on the database server to avoid any network time. Also, the query returns just a single row to minimize the time associated with sending the result set to standard output. That’s the reason “Elapsed time of last completed uow” from application snapshot is pretty close to the time captured by the time command. Even the difference of fraction of a second is mostly because of other statements in test.sh (connect, get snapshot, terminate etc.).&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Since the statement was run in auto-commit mode, the UOW comprises of single statement. Thus the SELECT statement took 130.9 seconds. Now let’s try to break up the 130.9 seconds and identify the individual components. We see that User CPU Time by agents is 124.78 seconds. Apart from that, the following time components sum up to less than a second&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 7&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Jidj7mFZ_XY/SW1iPDbgY-I/AAAAAAAAADk/cv4kgcXyqkM/s1600-h/Listing7.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 104px;" src="http://4.bp.blogspot.com/_Jidj7mFZ_XY/SW1iPDbgY-I/AAAAAAAAADk/cv4kgcXyqkM/s400/Listing7.gif" alt="" id="BLOGGER_PHOTO_ID_5290993147988435938" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Adding them all to User CPU time will still be less than 126 seconds. So where was the remaining 5 seconds spent? In fact, many of the time components shown in Listing 7 (sort time, buffer pool read time etc.) might be inclusive in User CPU Time. In any case, we don’t have any accountability of at least 5 seconds. This gap of unaccountable time will be even longer for more complex queries. Also, note that all the time components shown in Listing 7 are not even available at the statement level where it makes more sense.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;With these simple examples, I just wanted to show that DB2 monitoring does not provide the complete picture of all the time spent inside the database system. I have reached to the same conclusion even with the event monitoring. Ideally, the database monitoring should provide the total time spent by a statement and its individual components in a parent-child format. I would love to hear from you if you have any more insight or info regarding the time spent by a database request inside DB2.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-8140617103344593990?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/8140617103344593990/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=8140617103344593990&amp;isPopup=true' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/8140617103344593990'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/8140617103344593990'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2009/01/while-analyzing-slow-response-or-poor.html' title='Where a DB Request Spends Time?'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Jidj7mFZ_XY/SW1eGqa31iI/AAAAAAAAAC0/mqconIhDeQ0/s72-c/Listing1.gif' height='72' width='72'/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-4459420971222510334</id><published>2008-11-30T01:00:00.009-07:00</published><updated>2008-11-30T03:52:06.499-07:00</updated><title type='text'>SQL Tips &amp; Techniques- Correlated Reference</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;Sometimes even a simple SQL query may become challenging if we don’t approach it with a right technique. Few months ago I came across one such SQL query problem that I am going to share in this post. I was writing a database monitoring routine using snapshot table function. For simplicity, let’s consider the following query:&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: left;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Jidj7mFZ_XY/STJtechAq-I/AAAAAAAAAB8/dyKRfFyIp8g/s1600-h/Listing1.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 141px;" src="http://2.bp.blogspot.com/_Jidj7mFZ_XY/STJtechAq-I/AAAAAAAAAB8/dyKRfFyIp8g/s400/Listing1.gif" alt="" id="BLOGGER_PHOTO_ID_5274398483422424034" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;The above query will give the log used and available on partition 0, because the second argument is 0 in the &lt;span style="font-style: italic;"&gt;snapshot_database&lt;/span&gt; table function. I had to collect the above info on each partition and using db2_all was not an option because the SQL was supposed to run through a JDBC connection. My first instinct was to find the list of partitions using following query and then run the query in Listing 1 in a loop for each partition&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;Listing 2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Jidj7mFZ_XY/STJuA5SglKI/AAAAAAAAACE/Y8H8_WsdG7A/s1600-h/Listing2.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 153px;" src="http://4.bp.blogspot.com/_Jidj7mFZ_XY/STJuA5SglKI/AAAAAAAAACE/Y8H8_WsdG7A/s400/Listing2.gif" alt="" id="BLOGGER_PHOTO_ID_5274399075261781154" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style=";font-family:georgia;font-size:100%;"  &gt;However, I wanted to have a single &lt;/span&gt;&lt;span style=";font-family:georgia;font-size:100%;"  &gt;SQL query to get the complete result as shown below: &lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Jidj7mFZ_XY/STJuM4A8oOI/AAAAAAAAACM/S81wr-p8fQ4/s1600-h/Listing3.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 109px;" src="http://4.bp.blogspot.com/_Jidj7mFZ_XY/STJuM4A8oOI/AAAAAAAAACM/S81wr-p8fQ4/s400/Listing3.gif" alt="" id="BLOGGER_PHOTO_ID_5274399281078116578" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;The problem appeared to be easy in the beginning, but it started becoming difficult as I thought over it and could not come up with the SQL query. Then I thought of checking the complete syntax of DB2 SQL query in &lt;span style="font-style: italic;"&gt;DB2 SQL Reference&lt;/span&gt; to make sure I am not missing any syntax that can help with this problem. And I was indeed missing something. It was &lt;span style="font-style: italic;"&gt;Correlated Reference&lt;/span&gt;, which can also be used in arguments of table function.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;&lt;br /&gt;Most likely you might already be familiar with the &lt;span style="font-style: italic;"&gt;Correlated Subquery&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;Correlation Name&lt;/span&gt;. Even if these terms do not sound familiar, I am sure you must have used them in your SQL. Let’s look at an example to make it clear&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 4&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Jidj7mFZ_XY/STJub_T-mtI/AAAAAAAAACU/SEHZxXWoYFw/s1600-h/Listing4.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 119px;" src="http://2.bp.blogspot.com/_Jidj7mFZ_XY/STJub_T-mtI/AAAAAAAAACU/SEHZxXWoYFw/s400/Listing4.gif" alt="" id="BLOGGER_PHOTO_ID_5274399540735023826" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;In the above query, notice the use of &lt;span style="font-style: italic;"&gt;x.workdept&lt;/span&gt; inside the subquery. The &lt;span style="font-style: italic;"&gt;employee&lt;/span&gt; table in the FROM clause of parent query has &lt;span style="font-style: italic;"&gt;correlation name&lt;/span&gt; x. Though x is not present in the FROM clause of subquery, still &lt;span style="font-style: italic;"&gt;x.workdept&lt;/span&gt; is used in the WHERE clause of subquery. This is called &lt;span style="font-style: italic;"&gt;correlated subquery&lt;/span&gt;. In the above example, both the parent and subquery has employee table. However, subquery may have completely different tables and still it can use the columns from the parent table. &lt;/span&gt;&lt;/span&gt;  &lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;Correlated subquery can also appear in SELECT and HAVING clause as shown below&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 5&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jidj7mFZ_XY/STJuvHSyZCI/AAAAAAAAACc/AHCr3TAtz68/s1600-h/Listing5.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 249px;" src="http://3.bp.blogspot.com/_Jidj7mFZ_XY/STJuvHSyZCI/AAAAAAAAACc/AHCr3TAtz68/s400/Listing5.gif" alt="" id="BLOGGER_PHOTO_ID_5274399869295027234" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style=";font-family:georgia;font-size:100%;"  &gt;Correlated reference can also be used in &lt;span style="font-style: italic;"&gt;nested table expression&lt;/span&gt; as shown below&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;Listing 6&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Jidj7mFZ_XY/STJu-Cdl7UI/AAAAAAAAACk/uskhx84gA6A/s1600-h/Listing6.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 130px;" src="http://2.bp.blogspot.com/_Jidj7mFZ_XY/STJu-Cdl7UI/AAAAAAAAACk/uskhx84gA6A/s400/Listing6.gif" alt="" id="BLOGGER_PHOTO_ID_5274400125696208194" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: georgia;"&gt;Above example has a nested table expression &lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-family: georgia;font-size:100%;" &gt;empinfo&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: georgia;"&gt;. Notice the use of &lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-family: georgia;font-size:100%;" &gt;d.deptno&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: georgia;"&gt; in the query of nested table expression &lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic; font-family: georgia;font-size:100%;" &gt;empinfo&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: georgia;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div  style="text-align: justify;font-family:georgia;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;As I mentioned earlier, correlated reference can also be used in the arguments of a table function and this helped me to get the solution of my SQL problem. The following SQL will give the result I wanted&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Listing 7&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_Jidj7mFZ_XY/STJvT4f3w1I/AAAAAAAAACs/q2-njEjfp-s/s1600-h/Listing7.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 201px;" src="http://3.bp.blogspot.com/_Jidj7mFZ_XY/STJvT4f3w1I/AAAAAAAAACs/q2-njEjfp-s/s400/Listing7.gif" alt="" id="BLOGGER_PHOTO_ID_5274400500978533202" border="0" /&gt;&lt;/a&gt;&lt;span style=";font-family:georgia;font-size:100%;"  &gt;In the above query, &lt;span style="font-style: italic;"&gt;x.partition_number&lt;/span&gt; is used in the argument of snapshot_database table function. Changing the order of &lt;span style="font-style: italic;"&gt;db_partitions&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;snapshot_database&lt;/span&gt; table functions in the FROM clause of above query will result in error because table references in a FROM clause are processed from left to right and &lt;span style="font-style: italic;"&gt;x.partition_number&lt;/span&gt; must be resolved before it’s used in the argument of &lt;span style="font-style: italic;"&gt;snapshot_database&lt;/span&gt; table function. The same rule applies with correlated subquery as well. The correlated reference must be from a table reference at a higher level in the hierarchy of subqueries. &lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-4459420971222510334?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/4459420971222510334/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=4459420971222510334&amp;isPopup=true' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4459420971222510334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4459420971222510334'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/11/sql-tips-techniques-correlated.html' title='SQL Tips &amp; Techniques- Correlated Reference'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Jidj7mFZ_XY/STJtechAq-I/AAAAAAAAAB8/dyKRfFyIp8g/s72-c/Listing1.gif' height='72' width='72'/><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-1370274845053047648</id><published>2008-09-30T23:31:00.003-06:00</published><updated>2008-09-30T23:59:25.862-06:00</updated><title type='text'>Don’t Ignore Naming Convention</title><content type='html'>&lt;div style="text-align: justify;"&gt;Recently I worked with an organization having hundreds of DB2 databases and still a uniform and consistent naming convention across all these databases. Naming convention started from Server Name, Instance Name and Database Name itself. Just by looking at an Instance Name, you can tell whether it’s a production, development or QA instance and the associated application for that instance. Instance home directory, database path, log path, archive log path, database backup path ..., all followed a consistent naming convention.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In the above mentioned environment, if a file system is getting full on any of the DB2 database server, you immediately know if that file system is database related and which instance/database is using that file system. If a new DBA joins the team, he can quickly get familiar with the large environment just by learning the conventions. If a database has to be backed up, he knows the backup target and if a database has to be recovered, he knows where to find the backup image and archive logs, all because of consistent naming convention.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;A good naming convention not only helps a new DBA quickly come up to speed, but it also simplifies automation of DBA tasks. Many of the decision points in automation can get benefitted by the established convention. Automation platform like &lt;a href="http://www.stratavia.com/datapalette.php"&gt;Data Palette&lt;/a&gt; has the capability to capture all the variations and weirdness in your database environment and still enable the decision making. However, more variations often lead to complexity in implementing and managing the automation.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Just having any naming convention is not enough, you should have a good naming convention. I have described below some of the qualities of a good naming convention&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1.    Make your naming convention informative&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;div style="text-align: justify;"&gt;You can name your instances like db2ins01, db2ins02 and so on. But such naming convention does not have much information except that it is a DB2 instance. Instead if your instance name can tell you whether it’s production, development or QA instance, then you get more information out of that naming convention. Also, if your instance name includes INST or your database name includes DB, it does not provide you any additional info if you already know that you are looking at an instance name or database name.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Similarly the directory structure of your instance, database and table space level paths should incorporate the corresponding instance name, database partition number, database name hierarchy. By looking at instance/database configuration and system catalog, you can figure out most of the associated paths. However, the reverse mapping i.e. you know the path and trying to figure out who is using that path is straightforward only if you have an appropriate naming convention.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Whenever a name is derived from some other base names, do not abbreviate or shorten the base names while using into derived names. For example, if your table space container path includes a directory with your database name, this directory name should have a complete database name and not abbreviated or short form. If you use the abbreviated or short name, your path name becomes less informative because now you need additional data (the mapping between full name and short name) to determine if that directory name corresponds to the database name.&lt;/div&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2.    Use fixed-width numbers in your naming convention&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;blockquote&gt;If your naming convention includes a sequence number, have a fixed width sequence number. For example, if you know that you will need max four digits for a sequence number in your naming convention, use 0001 instead of just 1. Also, it’s better to have your database partition numbers (in db2nodes.cfg) as fixed width. For example, if you have 16 partitions in your database from 0 to 15, have your partitions named as 00, 01, 02 and so on. Such partition numbers has a distinct advantage while using “##” in your db2_all command. The character sequence “##” (two hash characters) can be used to get replaced by partition number while running a command through db2_all. So if you use NODE00## in your db2_all command, it can get replaced as NODE0000, NODE0001...NODE0015 in the above example of a 16 partition database.&lt;/blockquote&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;No matter how good a naming convention is, if it’s not followed consistently, it’s not useful. I started this post with an ideal example of consistency in naming convention. On the other  extreme, I have also come across organizations where DBA’s come up with a new naming convention whenever they set up a new database. To make it even worse, within a database also the naming convention would start changing over a period of time...it all depends on the mood of DBA while coming up with the name.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In my opinion, naming conventions should be properly defined as a planned effort, it should be well documented and strictly enforced by change control board or a similar regulation authority. Though, I fully agree that there are several scenarios where we can’t expect to have a uniform naming convention across a larger organization. For example, let’s imagine a company being acquired by another company and as a result the IT department of these companies getting merged into a single organization. However, naming conventions should not get destroyed just because of ignorance or negligence of individuals in an organization.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-1370274845053047648?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/1370274845053047648/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=1370274845053047648&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/1370274845053047648'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/1370274845053047648'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/09/dont-ignore-naming-convention.html' title='Don’t Ignore Naming Convention'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-2049972353796219321</id><published>2008-09-30T22:04:00.006-06:00</published><updated>2008-09-30T23:51:09.449-06:00</updated><title type='text'>XML Superstar Contest</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;Did you hear about “Search for the XML Superstar” contest? If not yet, check out the details of this contest below (as provided by IBM). If you or your friend or colleague is a XML guru, here is a chance to win great prizes.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:times new roman;"&gt;The International DB2 User Group (IDUG) is proud to announce the launch of the “Search for the XML Superstar” contest in the United States. This worldwide initiative is aimed at highlighting the benefits of DB2 and related technologies to database developers and university students.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;The “Search for the XML Superstar” has five categories: &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:times new roman;"&gt;XML application programming &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:times new roman;"&gt;Ported applications &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:times new roman;"&gt;Database gadgets&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:times new roman;"&gt;Videos &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:times new roman;"&gt;Query challenge &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:times new roman;"&gt;Contestants will participate in a combination of education, exposure to practical applications and “tests” that will validate understanding and ability to program IBM database technologies. Entries will be judged by an independent panel of DB2 professionals. &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:times new roman;"&gt;Participants in the contest will be eligible to win one of a series of great prizes. Those who submit star-quality entries could receive an all-expense paid trip to an IDUG conference, a new laptop, an iPod, a Sony PlayStation 3 or a Nintendo Wii system. The contest will also allow students to win opportunities for interviews and lab visits, and will enhance the skills that catch employers’ eyes on a resume. Developers will be able to gain recognition from world-class consultants and be celebrated for standing out among their peers.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family:georgia;"&gt;The contest launches in U.S. tomorrow. There will be a IBM press release coming out tomorrow, and the website (xmlchallenge.com), will launch then, as well. Also, check out the &lt;a href="http://db2xmlcontest.morphexchange.com/main/about"&gt;IBM DB2 Query Console (beta)&lt;/a&gt;, an application hosted in the cloud that allows you to run SQL and XQuery statements against a DB2 database. Good luck for the contest!&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-2049972353796219321?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/2049972353796219321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=2049972353796219321&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/2049972353796219321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/2049972353796219321'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/09/xml-superstar-contest.html' title='XML Superstar Contest'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-7541530050900839918</id><published>2008-08-20T01:11:00.002-06:00</published><updated>2008-08-20T01:22:18.123-06:00</updated><title type='text'>SSV Backup</title><content type='html'>&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;As I mentioned in my previous post &lt;a href="http://radheshk.blogspot.com/2007/12/db2-partitioning.html"&gt;DB2 Partitioning&lt;/a&gt;, Database partitioning feature (DPF) of DB2 enables DB2 to provide a very scalable database solution. The applications connecting to database do not have to be aware of database partitioning. However, the DBAs managing the multi-partition database have to deal with some complexities. One of the administration complexities of multi-partition database is Backup and Restore. Each database partition has to be backed up separately. Also, the catalog partition has to be backed up before any other partition. The db2_all command is used in such scenarios to run a command against one or more than one database partitions as shown in the example below. Following example shows the offline backup of a multi-partition database “test” with catalog partition 0.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;  &lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(242, 242, 242) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 6.15in;" valign="top" width="738"&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;"&gt;&lt;span style=";font-size:85%;" lang="EN" &gt;db2_all   ‘&amp;lt;&amp;lt;+0&amp;lt; db2 BACKUP DATABASE test to /backup_path’&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;db2_all   ‘|&amp;lt;&amp;lt;-0&amp;lt; db2 BACKUP DATABASE test to /backup_path’&lt;/span&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="" lang="EN"&gt;&lt;br /&gt;The first line in the above example will backup the partition 0 and the second line will backup the remaining partitions in parallel. With the above approach, the backup timestamp of all the partitions would not be the same. Hence, we have to separately identify the backup images for each partition while restoring the database.&lt;/span&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;In DB2 9.5, you don’t have to deal with the above mentioned complexity because of Single system view (SSV) backup. SSV backup allows to backup some or all the database partitions using ON DBPARTITIONNUMS or ON ALL DBPARTITIONNUMS clause of &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admin.cmd.doc/doc/r0001933.html"&gt;BACKUP DATABASE&lt;/a&gt; command. The backup images created by SSV backup have the same timestamp for each database partition. The SSV backup has to be run from catalog partition. In the following example, all the database partitions are backed up using SSV backup. The backup image of all the database partitions has the same timestamp. Hence, all the database partitions could be restored with a single command using db2_all.  &lt;span style=""&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;span style=""&gt;&lt;/span&gt;&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(242, 242, 242) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 6.15in;" valign="top" width="738"&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;"&gt;&lt;span style=";font-size:85%;" lang="EN" &gt;db2 BACKUP DB test ON ALL DBPARTITIONNUMS ONLINE INCLUDE LOGS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;"&gt;&lt;span style=";font-size:85%;" lang="EN" &gt;db2_all “db2 RESTORE DB test TAKEN AT 2008-08-17-23.44.56.125237“&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;"&gt;&lt;span style=";font-size:85%;" lang="EN" &gt;db2 ROLLFORWARD DB test TO END OF BACKUP ON ALL DBPARTITIONNUMS&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Some more good news... In the above example, notice that the backup image would include the logs. Prior to version 9.5, logs can be included with the online backup image for single partition databases only. With SSV backup, it’s possible to include the logs with online backup image for multi-partition databases also. Finally, notice the use of TO END OF BACKUP clause with the &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admin.cmd.doc/doc/r0001978.html"&gt;ROLLFORWARD&lt;/a&gt; command. It really simplifies to rollforward all the database partitions to the minimum recovery time and saves the effort to determine minimum recovery time over all the database partitions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-7541530050900839918?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/7541530050900839918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=7541530050900839918&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/7541530050900839918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/7541530050900839918'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/08/ssv-backup.html' title='SSV Backup'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-280527236144166656</id><published>2008-08-20T01:02:00.003-06:00</published><updated>2008-08-20T01:43:05.920-06:00</updated><title type='text'>New Poll- Backup Target</title><content type='html'>&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;  &lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Thanks everyone for participating in my previous poll regarding DB2 autonomic features. Here is the final poll result&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Self-tuning memory manager – 14 (51%)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Automatic storage – 11 (40%)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Automatic maintenance – 8 (29%)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Configuration advisor – 7 (25%)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Health monitor – 9 (33%)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Other – 1 (3%)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;None – 6 (22%)&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Interestingly, the use of the above features is almost in the same order as their positions in the listing. It’s evident that the top two autonomic features, self-tuning memory manager and automatic storage are the most popular autonomic features as per the poll result.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;I have added a new poll ... No, this is not about Democratic vs. Republican &lt;/span&gt;&lt;span style="color: rgb(51, 51, 51);font-family:Wingdings;"  lang="EN"&gt;&lt;span style=""&gt;J&lt;/span&gt;&lt;/span&gt;&lt;span style="" lang="EN"&gt; This is related to your database backup target. Please indicate the backup target as you specify in your backup command. For example, if your backup target is TSM, choose TSM only even though TSM will store the backup image on tape. If you select “Other”, it would be nice if you can explicitly mention the exact target through a comment to this post. I hope there will be more participation this time and thus the poll result will be more realistic. So, please don’t forget to provide your input in this poll !!!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-280527236144166656?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/280527236144166656/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=280527236144166656&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/280527236144166656'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/280527236144166656'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/08/new-poll-backup-target.html' title='New Poll- Backup Target'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-2025964102191832212</id><published>2008-07-08T01:07:00.003-06:00</published><updated>2008-07-08T01:16:09.219-06:00</updated><title type='text'>A Peek on DB2 Log Record</title><content type='html'>&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;Every DB2 database has recovery log. Recovery log keeps track of all the changes made to a database and it is used for crash recovery or rollforward recovery. The recovery log is made up of a number of log extents, each contained in a separate file called a log file. Normally, a DBA will have to deal with only the sizing, archive method and archive destination of recovery logs. However, in some scenarios (e.g. SQL replication, HADR) you may come across a term called Log Sequence Number (LSN). In order to understand the LSN, we have to go one step further i.e. inside the log file. Here I will explain what is LSN and how can we map a LSN with a log file and vice versa.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;A log file has number of log records inside it. A log sequence number (LSN) uniquely identifies a log record inside a log file. The LSN represents a relative byte address for the first byte of the log record within the recovery log. A transaction can generate more than one log records. Each log record also has a transaction identifier. Hence, the log records written by a single transaction have a common transaction identifier, a field in log record header.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;If you have a LSN and you need to find out the log file that has the log record for that LSN, you may use &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/r0002076.htm"&gt;db2flsn&lt;/a&gt; command.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(242, 242, 242) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 6.15in;" valign="top" width="738"&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;db2flsn   –q &amp;lt;input_LSN&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;If you need to do the reverse i.e. find out the range of LSN and timestamp inside a log file, it becomes little tricky. There is a file DB2TSCHNG.HIS under database path, which contains the history of table space changes at a log file level. You can find out database path from database snapshot.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(242, 242, 242) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 6.15in;" valign="top" width="738"&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;db2 get   snapshot for db on &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&amp;lt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;DB Name&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&amp;gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt; | grep “Database path”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;For each log file, DB2TSCHG.HIS contains information that helps to identify which table spaces are affected by the log file. Though the primary purpose of the file DB2TSCHNG.HIS is to track the table space changes, this file also has the information regarding range of LSN and timestamp within a log file. This information can be displayed using &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/r0009502.htm"&gt;db2logsForRfwd&lt;/a&gt; command as shown below&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;font-size:85%;"  lang="EN" &gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;font-size:85%;"  lang="EN" &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(242, 242, 242) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 6.15in;" valign="top" width="738"&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;$ db2logsForRfwd DB2TSCHG.HIS –all&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;----------------------------------------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Log file number&lt;span style=""&gt;       &lt;/span&gt;:   S0000000.LOG&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;First New Record LSN&lt;span style=""&gt;  &lt;/span&gt;:   00000138800C&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Log Extent Tail LSN&lt;span style=""&gt;   &lt;/span&gt;:   000001770000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Backup End Time Stamp : 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Flags&lt;span style=""&gt;                 &lt;/span&gt;: 107&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;pID&lt;span style=""&gt;                   &lt;/span&gt;: 1209781597   2008-05-03-02.26.37.000000 GMT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;cID&lt;span style=""&gt;                   &lt;/span&gt;: 1215376321   2008-07-06-20.32.01.000000 GMT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Tablespace ID&lt;span style=""&gt;         &lt;/span&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;----------------------------------------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Log file number&lt;span style=""&gt;       &lt;/span&gt;:   S0000001.LOG&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;First New Record LSN&lt;span style=""&gt;  &lt;/span&gt;:   00000177000C&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Log Extent Tail LSN&lt;span style=""&gt;   &lt;/span&gt;:   000001B58000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Backup End Time Stamp : 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Flags&lt;span style=""&gt;                 &lt;/span&gt;: 107&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;pID&lt;span style=""&gt;                   &lt;/span&gt;: 1215376321   2008-07-06-20.32.01.000000 GMT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;cID&lt;span style=""&gt;                  &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;: 1215376322 2008-07-06-20.32.02.000000 GMT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Tablespace ID&lt;span style=""&gt;         &lt;/span&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;----------------------------------------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Log file number&lt;span style=""&gt;       &lt;/span&gt;:   S0000002.LOG&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;First New Record LSN&lt;span style=""&gt;  &lt;/span&gt;:   000001B5800C&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Log Extent Tail LSN&lt;span style=""&gt;   &lt;/span&gt;:   000001F40000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Backup End Time Stamp : 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Flags&lt;span style=""&gt;                 &lt;/span&gt;: 107&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;pID&lt;span style=""&gt;                   &lt;/span&gt;: 1215376322   2008-07-06-20.32.02.000000 GMT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;cID&lt;span style=""&gt;                   &lt;/span&gt;: 1215376323   2008-07-06-20.32.03.000000 GMT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-size: 8pt; font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Tablespace ID&lt;span style=""&gt;         &lt;/span&gt;: 0 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;If the DB2TSCHNG.HIS file is not in current path, you should provide the fully qualified path of this file to db2logsForRfwd command. However, note the following points regarding DB2TSCHNG.HIS file.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;  &lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;This history file is available only for databases with archive logging enabled. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;This history file will have an entry for only the archived log files and not the active log files.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;The PRUNE HISTORY command prunes this history file also.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;When the registry variable DB2_COLLECT_TS_REC_INFO is off, history records will not be written to file DB2TSCHNG.HIS.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;In the above output, “First New Record LSN” and “Log Extent Tail LSN” fields provide the range of LSN in a log file. The range of timestamp is available in pID and cID fields (second part). The pID and cID stands for previous and current LogID. Have you seen the reference of LogID anywhere else? The header record of a backup image also includes LogID. You can display the information in a backup image header using &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/r0002585.htm"&gt;db2ckbkp&lt;/a&gt; command as shown below.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(242, 242, 242) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 6.15in;" valign="top" width="738"&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;db2ckbkp   –h &lt;/span&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&amp;lt;&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;backup image filename&lt;/span&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;You might be curious about the significance of LogID and so am I. But at this point, I don’t know any more about LogID.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;If you want to dive deeper into log records, check the &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/r0001673.htm"&gt;db2ReadLog&lt;/a&gt; API. You may also check the DB2 add-on tool &lt;a href="http://www.redbooks.ibm.com/redbooks/SG246421/wwhelp/wwhimpl/java/html/wwhelp.htm"&gt;Recovery Expert&lt;/a&gt;, if you are looking for a tool for log analysis.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-2025964102191832212?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/2025964102191832212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=2025964102191832212&amp;isPopup=true' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/2025964102191832212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/2025964102191832212'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/07/peek-on-db2-log-record.html' title='A Peek on DB2 Log Record'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-1658455415201473418</id><published>2008-06-29T08:45:00.001-06:00</published><updated>2008-07-07T23:49:57.823-06:00</updated><title type='text'>Table Space Auto-resize in Real DB2 World</title><content type='html'>&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;Past few months my personal time with DB2 community was encroached by excessive customer engagements. Hence, no blog post for a long time. I am afraid that it may continue like this for a while. However, these customer engagements did bring me in direct contact with many DBAs in the DB2 community and provided opportunity to learn the problems/issues in their DB2 environment.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;My customer engagements were primarily focused on standardizing and automating several DBA tasks using &lt;a href="http://www.stratavia.com/datapalette.php"&gt;Stratavia’s Data Palette&lt;/a&gt; (a software platform for Data Center automation). It initially surprised me that in many of the customer environments, Table Space Size Management is in their top priority list of automation. But why not use the DB2’s in-built Table Space auto-resize feature? One reason could be the version of DB2 older than v8.2.2 (Table Space auto-resize was introduced in v8.2.2). However, this was not the reason. Here I will present a gap analysis between auto-resize feature and the actual requirements in the customer environments I was engaged with.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;First of all, let’s consider the typical process of table space size management. It can be a planned effort (as a result of monthly or annual table space capacity planning) or it can be ad hoc (increase the size of table spaces that are about to get 100% full). Since the auto-resize feature deals with the second scenario, I will focus on that part only. Normally, DBA’s have some form of monitoring for table space size. When the size enters into alert zone (percent used above a threshold), we plan on increasing the size. This is a proactive approach. Compare it with the scenario where table space will be increased only when it does not have enough space to satisfy a DB request (almost 100% full). That’s how Auto-resize feature works. What if there is no space available on file system for extending the table spaces or auto-resize has already reached the max size? Whatever be the reason, if the table space could not be extended by auto-resize feature, it may affect the business processes dealing with that table space. Hence a proactive approach is essential for managing the table space size.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;Secondly, there are environment specific custom requirements associated with increasing the size of table spaces. For example, send a notification whenever the table space is extended or extending the table space size should not cause the associated file system more than 95% full. Such requirements can not be fulfilled by the auto-resize feature.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;The third point is little subtle but very important for big organizations having hundreds and thousands of databases. Imagine the admin effort required for managing auto-resize on table spaces under all these databases. Such organizations need a central system to apply and manage automation rather the local solutions like auto-resize feature.&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;Let me end this posting with a clarification that I have no intention to denounce the DB2’s table space auto-resize feature. In fact, it might be used in many environments and many of you might be finding it useful. However in my experience, organizations require more comprehensive automation solution for managing table space size than the table space auto-resize feature of DB2. I would like to hear your experience with table space auto-resize feature in case you are using it in your environment.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-1658455415201473418?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/1658455415201473418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=1658455415201473418&amp;isPopup=true' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/1658455415201473418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/1658455415201473418'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/06/table-space-auto-resize-in-real-db2.html' title='Table Space Auto-resize in Real DB2 World'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-4156743620695572979</id><published>2008-03-22T15:48:00.002-06:00</published><updated>2008-03-22T15:55:09.066-06:00</updated><title type='text'>Mapping Application to Dynamic SQL</title><content type='html'>&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;  &lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;If you need to find out dynamic SQL statements in the database package cache, you can do so using &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/r0022005.htm"&gt;Dynamic SQL Snapshot&lt;/a&gt;. If you need to check the details of your application, you can use &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/r0021986.htm"&gt;Application snapshot&lt;/a&gt;.&lt;span style=""&gt;  &lt;/span&gt;If you are accessing application snapshot through table function, you have to use &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/r0021994.htm"&gt;Statement snapshot&lt;/a&gt; to find the executing statement by that application. However, as soon as the statement execution is finished, you would not find that statement text in the statement snapshot. Also, even though dynamic SQL snapshot will show you this statement, it does not have any info regarding the application that executed it. Hence, if you are trying to map an application with a dynamic SQL statement, the snapshot table functions mentioned above may not be very useful.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;I had to suffer with this limitation of DB2 for quite some time. Interestingly, other competitive vendor databases (Oracle &amp;amp; SQL Server) provided the link between SQL in Cache and their sessions. However, I recently found that in version 9, we have the mapping info between application and dynamic SQL statements available through db2pd (DB2 Problem Diagnostic) tool. &lt;span style=""&gt; &lt;/span&gt;In fact, this db2pd enhancement was made in some fixpack after v8.2. Under this enhancement, the “applications” option of db2pd provides you following new columns&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;C-AnchID&lt;span style=""&gt;      &lt;/span&gt;: Current anchor ID&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;C-StmtUID&lt;span style=""&gt;    &lt;/span&gt;: Current statement unique ID&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;L-AnchID&lt;span style=""&gt;      &lt;/span&gt;: Last anchor ID&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;L-StmtUID&lt;span style=""&gt;    &lt;/span&gt;: Last statement unique ID&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;The first pair of Anchor ID and Statement Unique ID can be used to find the current SQL statement being executed by the application and the second pair can be used to find the last SQL statement executed by that application. The “dynamic” option of db2pd includes following columns to map with the Anchor ID and Statement Unique ID pair.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;AnchID&lt;span style=""&gt;          &lt;/span&gt;: Anchor ID of the statement&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;StmtUID&lt;span style=""&gt;        &lt;/span&gt;: Statement unique ID &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;You may check the “Scenario 2” under &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.pd.doc/doc/t0020807.htm"&gt;Monitoring and troubleshooting using db2pd&lt;/a&gt; at DB2 Information Center to look at an example of mapping application to a dynamic SQL statement.&lt;span style=""&gt;  &lt;/span&gt;You may also run the following command and verify it yourself.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(242, 242, 242) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 6.15in;" valign="top" width="738"&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;db2pd   –appl –dyn –db &lt;db&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;However, the problem with db2pd is that you can’t run it through SQL. Hence, if you want to collect the above info on a regular basis and store in a table as part of your database monitoring, you need to parse the db2pd output. I wish if the above AnchID and StmtUID info could be included in Application and Dynamic SQL snapshots, so that it can be accessed through snapshot table functions using SQL. At least now we have the mapping available through db2pd, which is much better than no mapping available earlier.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-4156743620695572979?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/4156743620695572979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=4156743620695572979&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4156743620695572979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4156743620695572979'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/03/mapping-application-to-dynamic-sql.html' title='Mapping Application to Dynamic SQL'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-1225867698561413017</id><published>2008-02-29T23:08:00.004-07:00</published><updated>2008-02-29T23:28:11.934-07:00</updated><title type='text'>SQL Tips &amp; Techniques- String Aggregation(Contd.)</title><content type='html'>&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;In my last post, I showed two ways to perform string aggregation. Both of them used recursive SQL. &lt;span style=""&gt; &lt;/span&gt;I also mentioned that a built-in function to perform string aggregation would be preferred. Though, I have not found a direct function for string aggregation, one of the comments on my previous post suggested the use of XMLAGG function. In fact, Serge Rielau used the XMLAGG function for string aggregation in his presentation “SQL on Fire! Part 1”. Let’s look at the query using XMLAGG function to perform the string aggregation. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoCaption" style="line-height: 150%; page-break-after: avoid;"&gt;&lt;br /&gt;Listing 5&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(242, 242, 242) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 306.9pt;" valign="top" width="512"&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;SELECT category,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;       &lt;/span&gt;SUBSTR(names, 1,   LENGTH(names) -2) as list&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;  &lt;/span&gt;FROM&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;(SELECT&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote style="font-family: courier new;"&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;category,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;    &lt;/span&gt;REPLACE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;     &lt;/span&gt;(REPLACE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;      &lt;/span&gt;(XMLSERIALIZE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;       &lt;/span&gt;(CONTENT   XMLAGG(XMLELEMENT(NAME a, name)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;                       &lt;/span&gt;ORDER BY name)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;        &lt;/span&gt;AS VARCHAR(50)),   '&amp;lt;A&lt;/span&gt;&lt;a&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;a&gt;', ''),&lt;o:p&gt;&lt;/o:p&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=";font-size:100%;" &gt;&lt;a&gt;   &lt;/a&gt;&lt;/span&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;&lt;a&gt;      &lt;/a&gt;&lt;/span&gt;&lt;a&gt;'&lt;/a&gt;&lt;/span&gt;&lt;a&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 12pt; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;a&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;/A&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size:100%;"&gt;&lt;a&gt;&lt;span style="font-size: 12pt; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span&gt;&lt;span&gt;&lt;a&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 12pt; color: rgb(51, 51, 51);" lang="EN"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;', ', ') AS names&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;    &lt;/span&gt;FROM mytab1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;    &lt;/span&gt;GROUP BY category) AS X&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;CATEGORY&lt;span style=""&gt;    &lt;/span&gt;LIST&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;----------- -------------------------------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote style="font-family: courier new;"&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;1 abc, bcd&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;2 cde, def, efg&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;3 fgh, ghi&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;"&gt;&lt;span style=";font-size:100%;" lang="EN" &gt;&lt;span style=""&gt;  3 record(s) selected.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;In the above query, first we are converting each name into an XML expression using XMLELEMENT function. Here, XMLELEMENT function will add the tags &lt;/span&gt;&lt;a&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&amp;lt;A&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;a&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="" lang="EN"&gt;&lt;a&gt; and &lt;/a&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&amp;lt;/A&lt;/span&gt;&lt;/span&gt;&lt;a&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="" lang="EN"&gt;around each name. After the aggregation, we get rid of these tags using REPLACE function. Though, XMLAGG function is also a work around for string aggregation, I would prefer it over recursive SQL because it’s easier to understand and in my test it had lower estimated cost.&lt;span style=""&gt;  &lt;/span&gt;Ideally, what we want is a function similar to myConcat as shown below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoCaption" style="line-height: 150%; page-break-after: avoid;"&gt;Listing 6&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(242, 242, 242) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 306.9pt;" valign="top" width="512"&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;span style="font-family: courier new;font-family:courier new;font-size:100%;"  &gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;span style="font-family: courier new;font-family:courier new;font-size:100%;"  &gt;SELECT category,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="" lang="EN"&gt;&lt;span style=""&gt;       &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;myConcat(name, ‘, ’) as list&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="" lang="EN"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;span style=""&gt; &lt;/span&gt;FROM mytab1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="" lang="EN"&gt;GROUP BY category&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="" lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="" lang="EN"&gt;CATEGORY&lt;span style=""&gt;    &lt;/span&gt;LIST&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="" lang="EN"&gt;----------- -------------------------------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote style="font-family: courier new;"&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="" lang="EN"&gt;1 abc, bcd&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;2 cde, def, efg&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;3 fgh, ghi&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify; font-family: courier new;"&gt;&lt;span style=";font-size:100%;" lang="EN" &gt;&lt;span style=""&gt;&lt;span style=""&gt;  &lt;/span&gt;3 record(s) selected.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Is that something in your wish list also?&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;br /&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-1225867698561413017?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/1225867698561413017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=1225867698561413017&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/1225867698561413017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/1225867698561413017'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/02/sql-tips-techniques-string.html' title='SQL Tips &amp; Techniques- String Aggregation(Contd.)'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-4628352245442723159</id><published>2008-02-27T00:14:00.006-07:00</published><updated>2008-02-27T01:06:07.872-07:00</updated><title type='text'>SQL Tips &amp; Techniques- String Aggregation</title><content type='html'>&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;  &lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;In my experience, application or database developers will have to deal with writing SQL queries more than a DBA (specially a System DBA). However, many a times DBAs are expected to help with writing complex queries. Keeping that in mind, I have decided to post SQL tips and techniques as I encounter them. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Recently, I had a requirement of performing string aggregation by concatenating them while grouping based on another column. For example, we have a table myTab1 with CATEGORY and NAME column values as shown below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoCaption" style="line-height: 150%; page-break-after: avoid;"&gt;Listing &lt;!--[if supportFields]&gt;&lt;span style="'mso-element:field-begin'"&gt;&lt;/span&gt;&lt;span style="'mso-spacerun:yes'"&gt; &lt;/span&gt;SEQ Table \* ARABIC &lt;span style="'mso-element:"&gt;&lt;/span&gt;&lt;![endif]--&gt;&lt;span style=""&gt;1&lt;/span&gt;&lt;!--[if supportFields]&gt;&lt;span style="'mso-element:field-end'"&gt;&lt;/span&gt;&lt;![endif]--&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(242, 242, 242) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 306.9pt;" valign="top" width="512"&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;SELECT category, name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;FROM myTab1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;ORDER BY category&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;CATEGORY&lt;span style=""&gt;    &lt;/span&gt;NAME&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;----------- ----------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;1 abc&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;       &lt;/span&gt;&lt;span style=""&gt;   &lt;/span&gt;1 bcd&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;2 cde&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;2 def&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;2 efg&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;3 fgh&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;3 ghi&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;  7 record(s) selected.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;The expected result is to have one CATEGORY per row with all the NAME values for a CATEGORY concatenated with a comma and a space in between. So the result should look as shown below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoCaption" style="line-height: 150%; page-break-after: avoid;"&gt;Listing 2&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(242, 242, 242) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 306.9pt;" valign="top" width="512"&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;CATEGORY&lt;span style=""&gt;    &lt;/span&gt;LIST&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;----------- ----------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;1 abc, bcd&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;2 cde, def, efg&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;          3 fgh, ghi&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;This could have been so simple if there was an aggregate function (similar to SUM, &lt;span style=""&gt; &lt;/span&gt;AVG, COUNT) to perform this task. However, there is no built-in function for it. So either you can write a function of your own or you have to use recursive SQL. You may refer the article “&lt;a href="http://www-128.ibm.com/developerworks/db2/library/techarticle/0309stolze/0309stolze.html"&gt;User-defined Aggregate Functions in DB2 Universal Database&lt;/a&gt;”, if you want to write a function for it. Here, I will show you a query that uses recursive SQL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoCaption" style="line-height: 150%; page-break-after: avoid;"&gt;Listing 3&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(242, 242, 242) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 306.9pt;" valign="top" width="512"&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;WITH &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;t1(rowNum, category, name) AS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;    &lt;/span&gt;( SELECT rownumber()   over(partition by category), &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;             &lt;/span&gt;category, name&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;       &lt;/span&gt;FROM myTab1 ),&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;t2(category, list, cnt) AS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;   &lt;/span&gt;( SELECT category, VARCHAR(name,   50), 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;      &lt;/span&gt;FROM t1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;      &lt;/span&gt;WHERE rowNum = 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;    &lt;/span&gt;UNION ALL&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;     &lt;/span&gt;SELECT t2.category, t2.list ||   ', ' || t1.name, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;            &lt;/span&gt;t2.cnt + 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;      &lt;/span&gt;FROM t2, t1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;      &lt;/span&gt;WHERE t2.category =   t1.category AND&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;            &lt;/span&gt;t2.cnt + 1 = t1.rowNum   )&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;SELECT category, list&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt; &lt;/span&gt;FROM t2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt; &lt;/span&gt;WHERE ( category, cnt ) IN (&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;SELECT category, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;                                       &lt;/span&gt;MAX(rowNum)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;                               &lt;/span&gt;FROM   t1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;        &lt;/span&gt;&lt;span style=""&gt;                       &lt;/span&gt;GROUP BY category )&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt; &lt;/span&gt;ORDER BY 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;CATEGORY&lt;span style=""&gt;    &lt;/span&gt;LIST&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;----------- -------------------------------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;SQL0347W&lt;span style=""&gt;  &lt;/span&gt;The recursive common   table expression "RKUMAR.T2" may contain an infinite loop.&lt;span style=""&gt;  &lt;/span&gt;SQLSTATE=01605&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;1 abc, bcd&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;2 cde, def, efg&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;3 fgh, ghi&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;  &lt;/span&gt;3 record(s) selected with 1   warning messages printed.&lt;/span&gt;&lt;/span&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Notice that in the above query, the definition of table expression t2 refers itself and hence we call such queries recursive. If you first run the query used in the definition of table expression t1, then run the entire query with t1 and t2 but without the last WHERE clause, you can easily follow logic involved here.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;DB2 version 9.5 also supports the CONNECT BY syntax of Oracle for recursive queries. You may check the article &lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;span style=";font-family:&amp;quot;;"  lang="EN"&gt;“&lt;a href="http://www.ibm.com/developerworks/db2/library/techarticle/dm-0707rielau/"&gt;DB2 Viper 2 compatibility features&lt;/a&gt;”&lt;/span&gt;&lt;/span&gt;&lt;span style="" lang="EN"&gt; for details on CONNECT BY syntax. We may write the query using CONNECT BY as shown below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoCaption" style="line-height: 150%; page-break-after: avoid;"&gt;Listing 4&lt;/p&gt;  &lt;table class="MsoNormalTable" style="background: rgb(242, 242, 242) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 306.9pt;" valign="top" width="512"&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;SELECT category, list&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;FROM&lt;span style=""&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt; &lt;/span&gt;(SELECT category, level,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;      &lt;/span&gt;MAX(level) OVER(PARTITION BY   category) as maxlevel,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;      &lt;/span&gt;VARCHAR(SUBSTR(SYS_CONNECT_BY_PATH(name,',   '), 3),50) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;      &lt;/span&gt;as list&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;  &lt;/span&gt;FROM&lt;span style=""&gt;   &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;(SELECT category,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;            &lt;/span&gt;name,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;            &lt;/span&gt;ROW_NUMBER() OVER   (PARTITION BY category &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style=""&gt;                 &lt;/span&gt;&lt;span style=""&gt;        &lt;/span&gt;ORDER BY name) AS curr,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;            &lt;/span&gt;ROW_NUMBER() OVER   (PARTITION BY category &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;                               &lt;/span&gt;ORDER   BY name) -1 AS prev&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;     &lt;/span&gt;FROM&lt;span style=""&gt;   &lt;/span&gt;myTab1)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;  &lt;/span&gt;CONNECT BY prev = PRIOR curr and   category = PRIOR category)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;WHERE level = maxlevel&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;ORDER BY 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;CATEGORY&lt;span style=""&gt;    &lt;/span&gt;LIST&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;----------- -------------------------------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;1 abc, bcd&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;2 cde, def, efg&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;          &lt;/span&gt;3 fgh, ghi&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p  style="margin: 0in 0in 0.0001pt; text-align: justify;font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;  3 record(s) selected.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0in 0in 0.0001pt; text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;In addition to CONNECT BY, the above query also uses the function MAX as OLAP aggregation function. You may check DB2 SQL Reference manual or the article “&lt;a href="http://www.ibm.com/developerworks/db2/library/techarticle/lyle/0110lyle.html"&gt;OLAP Functions in DB2&lt;/a&gt;” to learn about OLAP functions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-4628352245442723159?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/4628352245442723159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=4628352245442723159&amp;isPopup=true' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4628352245442723159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4628352245442723159'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/02/sql-tips-techniques-string-aggregation.html' title='SQL Tips &amp; Techniques- String Aggregation'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-4966140139144294225</id><published>2008-02-06T08:08:00.000-07:00</published><updated>2008-02-06T08:27:54.991-07:00</updated><title type='text'>Locking issues</title><content type='html'>&lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Locking issues in a database often lead to finger-pointing between DBAs and Application developers. Application folks will complain that their application is performing poorly because of database locking issues. DBAs will respond that it’s the application design issue that’s causing the locks. In fact, the locking issues can be resolved by the combined effort of DBAs and Application folks. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;DBAs have tools to diagnose the locking issue and explain to application folks the root cause. Then DBAs and Application folks can work together to analyze the transaction logic that’s causing the locking issue and make corrections if possible. Sometimes, the locking issues can be resolved or reduced by database level changes (e.g. changing &lt;i style=""&gt;maxlocks&lt;/i&gt; and &lt;i style=""&gt;locklist&lt;/i&gt; database parameters).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Now, let’s see what are the locking issues in DB2 and how can a DBA diagnose them. DB2 can have mainly three types of locking issues&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Deadlocks&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Lock escalation&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Lock wait and lock timeout&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;As a DBA, you should periodically check the occurrences of above locking issues through Database snapshot and make sure that there are not many occurrences of these locking issues. I will briefly describe here each of the three locking issues and also provide pointers for further details.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;strong&gt;Deadlocks&lt;o:p&gt;&lt;/o:p&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;A deadlock is created when two applications are each locking data needed by the other, resulting in a situation when neither application can continue execution. DB2 deadlock detector is responsible for handling deadlocks. When a deadlock is detected, the deadlock detector will choose a victim that will be automatically rolled back and issued an SQL0911 error message with a return code of 2. By rolling back the victim, the lock conflict is removed and the application can continue processing. Database parameter ‘&lt;i style=""&gt;dlchktime&lt;/i&gt;’ controls the time interval for checking deadlocks. DB2 also creates an event monitor called db2detaildeadlock by default to capture the relevant info about the deadlock which can be used to identify the root cause of the deadlock. Check the link “&lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admin.perf.doc/doc/c0005419.html"&gt;Deadlocks&lt;/a&gt;” at Information Center for more details.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;strong&gt;Lock escalation&lt;o:p&gt;&lt;/o:p&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Lock escalation occurs when database manager will attempt to free up memory allocated to locking by obtaining table locks and releasing existing row locks. The desired effect is to make more lock memory available for additional applications. The following two database parameters have a direct effect on lock escalation:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;locklist&lt;/span&gt;&lt;/i&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;- amount of storage (in units of 4k pages) that is allocated to hold the list of all locks held by all applications concurrently connected to the database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;i style=""&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;maxlocks&lt;/span&gt;&lt;/i&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;- the allowable percentage of locklist that can be used by an application.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Both the above database parameters are automatic configurable by default in version 9. Though the above two database parameters influence the lock escalation, we should not always change them to resolve the lock escalation. Check the link “&lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admin.perf.doc/doc/t0005272.html"&gt;Correcting lock escalation problems&lt;/a&gt;” at DB2 Information Center for a step wise approach to resolve the lock escalation issue.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;strong&gt;Lock wait and lock timeout&lt;o:p&gt;&lt;/o:p&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Finally, what’s lock wait and lock timeout? An application, that makes a request for a lock that is not compatible with the existing locks on the object, will have to wait to acquire the lock and this phenomenon is called lock wait. There is a database parameter called &lt;i style=""&gt;locktimeout&lt;/i&gt; that determines how long the application in lock wait state should continue waiting before it times out. If the timeout period is exceeded, the waiting application receives an SQL0911 error message with a return code 68 and the application’s unit of work (transaction) is rolled back by the database manager.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Note that the default value of &lt;i style=""&gt;locktimeout&lt;/i&gt; parameter is -1, which causes the lock timeout to be disabled. That is, an application that is waiting for a lock will continue to wait indefinitely or until the lock is released. To avoid such a scenario, it’s recommended to set a positive value for &lt;i style=""&gt;locktimeout&lt;/i&gt; (specially in transactional environment). In transactional environment, the recommended starting value for &lt;i style=""&gt;locktimeout&lt;/i&gt; is 30 seconds. However, tuning may be necessary in order to find the more appropriate value for this parameter.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;You can find out the current lock waits in database using lock wait snapshot. Check the link &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.sql.rtn.doc/doc/r0021993.html"&gt;SNAP_GET_LOCKWAIT table function&lt;/a&gt; at DB2 Information Center for more details about lock wait snapshot.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Diagnosing the lock timeout is little involved. Through the snapshot monitors, you would not have the details of applications involved in lock contention that resulted in the lock timeout. Prior to version 9, you could capture such details using event monitors. However, the event monitors to capture the transactions and statements may cause considerable performance impact and hence that might not be an option in your environment. &lt;span style=""&gt; &lt;/span&gt;DB2 v9.1 FP4 introduced lock timeout reporting feature to help the diagnosis of lock timeouts. There is a registry variable called DB2_CAPTURE_LOCKTIMEOUT, which controls the lock timeout reporting function. When this registry variable is set to ON, it captures basic information about each lock timeout that happens within the DB2 instance and a lock timeout report is created under the instance diagnostic path (&lt;i style=""&gt;diagpath&lt;/i&gt;). Check the following links at DB2 Information Center for more details.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admin.perf.doc/doc/c0052973.html"&gt;Lock timeout reporting&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admin.perf.doc/doc/r0052974.html"&gt;Lock timeout report files&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Hope the above info will help to reduce locking issues in your environment. As mentioned in the beginning, DBAs can help to diagnose the locking issues. However in most of the cases, the locking issue has to be resolved from application side (correcting the application logic, using the proper isolation level etc.).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-4966140139144294225?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/4966140139144294225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=4966140139144294225&amp;isPopup=true' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4966140139144294225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4966140139144294225'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/02/locking-issues.html' title='Locking issues'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-5252733868960849891</id><published>2008-01-29T08:28:00.000-07:00</published><updated>2008-01-29T08:30:34.979-07:00</updated><title type='text'>Mimicking Production Database</title><content type='html'>&lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;If you are a DB2 DBA, most likely you have already used &lt;i style=""&gt;db2look&lt;/i&gt; to extract the DDL from a DB2 database. However, &lt;i style=""&gt;db2look&lt;/i&gt; can do more than just extracting the DDL. Sometimes you may want to create a test database similar to production database in order to test your applications and query access plans. If the database is small, you may create a test database by restoring the production database backup image. What if the database is not small? Creating a test database of same size as production database may be cost and time prohibitive. In that case, you may want to have only a subset of production data loaded into the test database. Or, you may even want to have dummy data loaded into your test database instead of actual production data due to security reasons. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;For the reasons explained above, you may have to create a test database which will not have exactly the same data as your production database. DB2 has a cost based optimizer and if the data is different in the test database, you may get different query access plans than the production database. This might be okay, if you are only testing the functionality of an application. But what if you have to test the performance or debug some SQL performance related issue? In that case, you would want to have the same query access plan in your test database as it will be in your production database. What’s the solution now? The solution is to give the production environment feeling to DB2 optimizer even in your test environment. How do we do that? DB2 optimizer generates access plan based on following&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Statistics&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Configuration parameters&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in; text-align: justify; text-indent: -0.25in;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;span style=""&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Registry and environment variables&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;You can capture the above from production database and apply to your test database. You can use &lt;i style=""&gt;db2look&lt;/i&gt; for this purpose. The –m option of &lt;i style=""&gt;db2look&lt;/i&gt; can be used to create UPDATE statements against the updatable catalog tables under the SYSSTAT schema as well as RUNSTATS command against all of the tables. The –f option of &lt;i style=""&gt;db2look&lt;/i&gt; can be used to generate necessary configuration updates and set statements for registry and environment variables. Check the following link at DB2 Information Center for more details &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admin.trb.doc/doc/c0020703.html"&gt;Mimicking databases using db2look&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;The above approach of mimicking database for performance testing has another advantage. Once you set up a test database, you will have to update only the statistics in the test database if the volume of data in production database changes over time. Updating the statistics only will take much less time than rebuilding the test database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-5252733868960849891?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/5252733868960849891/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=5252733868960849891&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/5252733868960849891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/5252733868960849891'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/01/mimicking-production-database.html' title='Mimicking Production Database'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-7624486915451784138</id><published>2008-01-21T00:38:00.000-07:00</published><updated>2008-01-21T01:08:00.190-07:00</updated><title type='text'>DB2 Autonomic Computing</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;One of the highlights of DB2 Version 9.5 is “Manage your business, not your database”.&lt;span style=""&gt;  &lt;/span&gt;IBM claims that the DB2 autonomic computing environment is self-configuring, self-healing, self-optimizing and self-protecting. Autonomic computing is not new in Version 9.5. Past several releases of DB2 have consistently added enhancements in this direction. Just look at the database and database manager configuration parameters in Version 8.1, 8.2, 9 and 9.5 and you can see a trend of how more and more configuration parameters have started supporting the AUTOMATIC setting. Some of the other important features under autonomic computing are Self-tuning memory manager, Automatic storage, Automatic database backup, Automatic statistics collection, Configuration advisor, Health monitor and Utility throttling.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;However, somehow I feel that not all the autonomic features in DB2 are widely used. For example, most of the DB2 DBAs are taking their database backup using scheduled scripts rather than using the Automatic database backup. &lt;span style=""&gt; &lt;/span&gt;It would be interesting to know which autonomic features are really getting embraced and which ones are not so popular. So, I have added a poll (on the right side panel of my blog) to check which DB2 autonomic features you use in your environment. You can select more than one options in this poll. Also, it would be great if you can provide comments here about why you like or dislike a particular autonomic computing feature.&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-7624486915451784138?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/7624486915451784138/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=7624486915451784138&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/7624486915451784138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/7624486915451784138'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/01/db2-autonomic-computing.html' title='DB2 Autonomic Computing'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-8380699545532414560</id><published>2008-01-12T22:44:00.000-07:00</published><updated>2008-01-12T22:47:02.251-07:00</updated><title type='text'>DB2 Installation Enhancements</title><content type='html'>&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;Prior to Version 9, the installation path of DB2 was fixed on each platform. As a result, you could not have multiple copies of DB2 on the same computer under a single OS. DB2 Version 8 introduced a patchy solution to this problem in the form of Alternate Fix Packs, which allowed coexistence of multiple Fix Pack levels of DB2 version 8 on the same computer. However, now you don’t have to deal with Alternate Fix Packs and you don’t have to get frustrated with the stiffness of DB2 Installation any more.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;"&gt;With DB2 Version 9, you can use multiple DB2 copies on the same computer. Each DB2 copy can be at the same or different code levels. We can also have DB2 Version 8 and Version 9 on the same computer. IBM has listed the following benefits of doing this (which sounds reasonable): &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul type="disc"&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;"&gt;The ability to run applications that require different      DB2 versions on the same machine at the same time.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;"&gt;The ability to run independent copies of DB2 products      for different functions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;"&gt;The ability to test on the same computer before moving      the production database to the latter version of the DB2 product.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;"&gt;For independent software vendors, the ability to embed      a DB2 server product into your product and hide the DB2 database from your      users.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;"&gt;A DB2 copy can contain one or more different DB2 products. This refers to the group of DB2 products that are installed at the same location.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;"&gt;How is this possible now? You might have already guessed: now you can choose your own path while installing DB2. &lt;span style=""&gt; &lt;/span&gt;Each DB2 Copy has its own installation path. That’s cool, but now how will you find out all the installed DB2 products? DB2 Version 9 on Linux and UNIX comes with a command &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/r0023668.htm"&gt;db2ls&lt;/a&gt;, which you can use to list:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;"&gt;Where DB2 products are installed on your system and list the DB2 product level.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;"&gt;All or specific DB2 products and features in a particular installation path.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;    &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;"&gt;Unfortunately, db2ls is not available on Windows. However, on Windows you can find all the installed DB2 copies and their installation path in Windows Registry under HKEY_LOCAL_MACHINE\SOFTWARE\IBM\DB2\InstalledCopies. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;"&gt;Another notable enhancement for DB2 Installation is non-root installation on Linux and UNIX. Non-root installation is available with DB2 Version 9.5. You can check the details of it at the link: &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.qb.server.doc/doc/c0050562.html"&gt;Non-root installation overview&lt;/a&gt;. However, there are several &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.qb.server.doc/doc/c0050568.html"&gt;limitations&lt;/a&gt; of non-root installation. Apart from limitations, there are few &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.qb.server.doc/doc/c0050566.html"&gt;differences&lt;/a&gt; between the directory structure of root and non-root installations. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;"&gt;More good news: Fix Pack post-installation tasks are automated on Linux and UNIX in DB2 Version 9.5. In previous releases, you had to update instances and bind the packages manually after installing a fix pack. Now you don’t have to run db2iupdt or dasupdt commands to update the instances after installing a fix pack, they will be performed automatically when you install the fix pack. In addition, binding occurs automatically at the first connection. As a result, once you start the database manager, the DB2 product is ready to use immediately after fix pack installation. You may check the details of &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.qb.server.doc/doc/t0006352.html"&gt;applying fix packs&lt;/a&gt; at DB2 Information Center.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-8380699545532414560?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/8380699545532414560/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=8380699545532414560&amp;isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/8380699545532414560'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/8380699545532414560'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/01/db2-installation-enhancements.html' title='DB2 Installation Enhancements'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-8644649215940045813</id><published>2008-01-06T22:48:00.000-07:00</published><updated>2008-01-08T06:16:00.859-07:00</updated><title type='text'>How to Recreate DB2 Instance</title><content type='html'>&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Can we drop and recreate a DB2 instance without restoring all the databases underneath? The answer is YES. This is not a very common requirement, but once I ended up doing this. I had few DB2 version 8.2 single partition instances of type WSE (Workgroup Server Edition). I needed to use db2_all command with these instances to have my automation scripts work with these instances (You may read my previous posting “db2_all and RAHUSER” to understand the use of db2_all even for single partition instance). However, db2_all does not work with WSE instance and hence I needed to convert these instances from WSE to ESE (Enterprise Server Edition). I found that  the installed product and license was good for allowing an ESE instance. Only problem was that the instances were created with WSE option. &lt;/span&gt;&lt;span style="font-size:78%;"&gt;&lt;span style=";font-family:&amp;quot;;font-size:12;"  lang="EN" &gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="" lang="EN"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Initially, I thought of using &lt;i style=""&gt;db2iupdt&lt;/i&gt; command for this as I remembered converting 32-bit instances to 64-bit using &lt;i style=""&gt;db2iupdt&lt;/i&gt;. &lt;span style=""&gt; &lt;/span&gt;Unfortunately, &lt;span style="font-style: italic;"&gt;db2iupdt&lt;/span&gt; did not have any option to convert a WSE instance to ESE. I could not find any other one step command to perform this task. The databases under these instances were small non-production databases. Hence, I thought even if I will have to recreate all the instances as ESE and restore all the databases underneath, I would go for this instance conversion from WSE to ESE. The next question was whether I really need to restore all the databases after recreating the instance. When we drop an instance using db2idrop command, it does not drop the databases underneath. So if we recreate the instance, we should be able to re-catalog the databases under the newly created instance and it should be good to go. Logically this sounded good, but I had never done it before. So, first I tested it using the steps listed below and it worked fine. I used the same steps to convert all my WSE instances to ESE and did not have to restore the databases underneath.&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol style="margin-top: 0in;" start="1" type="1"&gt;&lt;li class="MsoNormal" style="color: rgb(51, 51, 51); text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Capture      the details of databases cataloged under the instance (using “list db      directory”). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: rgb(51, 51, 51); text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Capture      the Database Manager configuration (using “get dbm config”) and registry      variables (using “db2set –all”).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: rgb(51, 51, 51); text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Copy      any files that you may need to refer or use with the newly created      instance (e.g. files of external routines, any script, log files etc.).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: rgb(51, 51, 51); text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Ensure      a good backup of local databases under the instance (in case something      goes wrong, backup will be your savior).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: rgb(51, 51, 51); text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Stop      the instance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: rgb(51, 51, 51); text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Drop      the instance (using db2idrop command).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: rgb(51, 51, 51); text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Recreate      the instance as per your requirement (using db2icrt command).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: rgb(51, 51, 51); text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Make      the Database Manager configuration and registry variables same as original      instance using the info captured in step-2.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: rgb(51, 51, 51); text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Copy      any required files captured in step-3 under the same path as it was with      the original instance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: rgb(51, 51, 51); text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Start      the instance.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: rgb(51, 51, 51); text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;Catalog      the databases captured in step-1 under the newly created instance (using catalog      database command).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;    &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;If for some reason, you also need to drop and recreate your instance using the above steps, I would strongly recommend you to test it first in your specific environment. You may require few additional steps in your environment that you may discover during your testing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="" lang="EN"&gt;&lt;o:p&gt; &lt;/o:p&gt;Hope you enjoyed the holidays. Wish you very happy New Year.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-8644649215940045813?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/8644649215940045813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=8644649215940045813&amp;isPopup=true' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/8644649215940045813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/8644649215940045813'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2008/01/how-to-recreate-db2-instance.html' title='How to Recreate DB2 Instance'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-4244533755435315598</id><published>2007-12-26T00:12:00.000-07:00</published><updated>2007-12-26T00:14:25.535-07:00</updated><title type='text'>Database Roles</title><content type='html'>&lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;If you are familiar with Oracle Database, you will be happy to know that DB2 9.5 has introduced few new features that you may already be familiar with in Oracle. First of all, there are several SQL related compatibility features (e.g. support for dual, decode etc.). &lt;span style=""&gt; &lt;/span&gt;Check the developerWorks article &lt;a href="http://www.ibm.com/developerworks/db2/library/techarticle/dm-0707rielau/"&gt;DB2 Viper 2 compatibility features&lt;/a&gt; for more details. These compatibility features will greatly help the migration from Oracle to DB2 database. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;Database Roles, another new feature in DB2 9.5, was also available in Oracle since long. A role has a certain set of privileges and a user who is granted membership in this role inherits those privileges. Roles are also available in Informix, SQL Server, Sybase and may be some other RDBMS’s. &lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;DB2 provided an alternative to role in the form of group based authorization. You may grant one or more privileges to user groups and all the users in that group will automatically have those privileges. &lt;span style=""&gt; &lt;/span&gt;You may add a user to that group (equivalent to granting a role to a user) or remove a user from the group (equivalent to revoking a role from a user). However, there are two major limitations with group based authorization&lt;br /&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol style="margin-top: 0in;" start="1" type="1"&gt;&lt;li class="MsoNormal" style="color: rgb(51, 51, 51); text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;" lang="EN"&gt;Privileges      and authorities granted to groups are not considered when a user is      creating views, materialized query tables (MQTs), SQL routines, triggers      and packages containing static SQL. This is because groups and users are controlled      externally from the DB2 database system, for example, by an operating      system or an LDAP server. So if a user will be removed from a group,      database may not be aware of it and would not update the validity of      created objects mentioned above.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class="MsoNormal" style="color: rgb(51, 51, 51); text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;;" lang="EN"&gt;A role      can be granted to a role and so a role hierarchy is possible, which is not      possible with group based authorization.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;    &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;span style="font-family: &amp;quot;Georgia&amp;quot;,&amp;quot;serif&amp;quot;; color: rgb(51, 51, 51);" lang="EN"&gt;&lt;o:p&gt;&lt;/o:p&gt;To overcome the above limitations, DB2 9.5 introduced roles in addition to group based authorization. In DB2, a role is a database object that groups together one or more privileges and can be assigned to users, groups, PUBLIC, or other roles by using a GRANT statement. For more details, check the &lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admin.sec.doc/doc/c0050531.html"&gt;Roles&lt;/a&gt; at DB2 Information Center.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-4244533755435315598?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/4244533755435315598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=4244533755435315598&amp;isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4244533755435315598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4244533755435315598'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2007/12/database-roles.html' title='Database Roles'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-4121272976378105765</id><published>2007-12-09T23:07:00.000-07:00</published><updated>2007-12-09T23:13:13.177-07:00</updated><title type='text'>DB2 Partitioning</title><content type='html'>&lt;p align="justify"&gt;Divide and conquer- that’s the mantra used to deal with large volume of data in data warehouses.  What are the features available in DB2 to divide or partition the data? DB2 provides following three features to partition your data.&lt;br /&gt;&lt;br /&gt;Data Partitioning Feature (DPF)&lt;br /&gt;Multi-Dimensional Clustering (MDC)&lt;br /&gt;Table Partitioning (TP)&lt;br /&gt;&lt;br /&gt;DPF allows you to partition the whole database. In fact, database partitions are defined on the instance level. Hence, all the databases under an instance are partitioned in the same way.  DPF uses a hashing algorithm to distribute the data of a table across multiple database partitions based on the values in columns of distribution key of the table. Distribution key has to be selected carefully while creating the table to ensure a balanced distribution of data among all the database partitions. Normally, the distribution key with columns of high distinct cardinality provides good distribution of data. DPF is based on shared nothing architecture, i.e. each partition has its own processes, memory and disk storage. DPF allows you to scale the size and performance of your database by adding more partitions and additional resources (CPU, Memory, Disk storage) with each additional partition. Because of shared nothing architecture DPF can achieve almost linear scalability.  Multiple partitions can be created on a single machine or it can be spread across multiple machines such that each machine can have one or more partitions.&lt;br /&gt;&lt;br /&gt;MDC allows you to cluster your data on multiple dimensions.  A common example is clustering your data warehouse fact table based on say following three columns: month of transaction date, region or state, industry of your customer. Once you cluster your table using above three dimensions, there will be a storage block (of extent size) allocated for each unique combination of values of these three dimensions.  Also, a block index will be created which will have an entry pointing to each block rather than each row of the table.  As a result, block indexes are much smaller compared to regular Row ID indexes and index scan on block indexes are much faster. Another advantage is that the data in a MDC table is self organized; you don’t have to reorg these tables. The biggest advantage of MDC table is query performance. If your query includes one or more dimensional columns in where clause, the block index will help to quickly figure out the subset of blocks that may have your result dataset. However, you should be aware that block indexes do not support index-only access. This is because a block index can point to an empty block, i.e. a block with now rows for a unique combination of dimension values.  The performance of an MDC table is greatly dependent upon the proper choice of dimensions and the block (extent) size of the tablespace for the given data and application workload.&lt;br /&gt;&lt;br /&gt;Table partitioning (TP) is a new feature in DB2 UDB V9. This feature is also known as range partitioning because using this feature you can define data partitions (not to be confused with database partitions in DPF) based on range of values of one or more than one columns.  Each data partition is a separate database object and they can be placed in different tablespaces, if desired. Also, TP supports attaching and detaching a data partition from the TP table.  A detached data partition becomes a regular table. These attach and detach features make the data roll-in and roll-out very convenient in a TP table.&lt;br /&gt;&lt;br /&gt;So far I have very briefly described three partitioning features available in DB2 UDB. Another important notion is that all the three partitioning features can be used on the same table and decision of using one type of partitioning feature does not interfere with the decision of using other type of partitioning. Listed below are few good references which describe the DB2 partitioning features and its usage in data warehousing environment in more detail.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The IBM Redbook &lt;a href="http://www.redbooks.ibm.com/abstracts/SG247274.html"&gt;Leveraging DB2 Data Warehouse Edition for Business Intelligence&lt;/a&gt; – Chapter 10 (10.4 Partitioning)&lt;br /&gt;&lt;br /&gt;IBM developerWorks article &lt;a href="http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0608mcinerney/index.html"&gt;DB2 partitioning features&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The IBM Redbook &lt;a href="http://www.redbooks.ibm.com/abstracts/sg246917.html"&gt;Up and Running with DB2 UDB ESE: Partitioning for Performance in an e-Business Intelligence World&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-4121272976378105765?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/4121272976378105765/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=4121272976378105765&amp;isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4121272976378105765'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/4121272976378105765'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2007/12/db2-partitioning.html' title='DB2 Partitioning'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-1547261260149438640</id><published>2007-07-29T13:19:00.001-06:00</published><updated>2008-05-21T10:09:49.335-06:00</updated><title type='text'>db2_all and RAHUSER</title><content type='html'>&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;If you need to run a command on all or a subset of database partitions, you can use db2_all.&lt;br /&gt;&lt;br /&gt;For example, to change the database configuration LOGFILSZ to 100 for sample database on all database partitions that are specified in node configuration file, we can use the following command:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;db2_all “UPDATE DB CFG FOR sample USING LOGFILSZ 100”&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Similarly, if you have to change the database configuration only on partition 1, you can run the following command:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;db2_all “&lt;&lt;+1&amp;lt;UPDATE DB CFG FOR sample USING LOGFILSZ 100”&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:georgia;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:georgia;"&gt;&lt;br /&gt;If you have to change the database configuration on all the database partitions except partition 0, you can run the following command:&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;db2_all “&lt;&lt;-0&amp;lt;UPDATE DB CFG FOR sample USING LOGFILSZ 100” &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family:georgia;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;p align="justify"&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;On UNIX based platforms, db2_all uses the remote shell program specified by DB2RSHCMD registry variable. Starting with DB2 v8.1 FP 9, we can chose either rsh or ssh for DB2RSHCMD registry variable. If this registry variable is not set, rsh (or remsh for HP-UX) is used.&lt;br /&gt;&lt;br /&gt;There is an environment variable RAHUSER, which can be used to specify the user ID under which the remote command is to be run on UNIX based platforms.&lt;br /&gt;&lt;br /&gt;Though the primary purpose of db2_all is to run the command on all the database partitions that you specify, it can also be used for the purpose of running the command under a different user ID with the help of RAHUSER environment variable. Thus, db2_all becomes useful even in a single-partition database. However, db2_all is available with Enterprise Server Edition (ESE) only. So, if you have a Workgroup Server Edition (WSE) instance, you would not be able to use db2_all.&lt;br /&gt;&lt;br /&gt;The above mentioned use of db2_all, which allows you to run a command under a different user ID is particularly helpful in situations where your task automation script always runs as a fixed user ID or a common user ID say ScriptUser and if you wish to run the commands inside those scripts under a different user ID say DB2CommandUser (e.g. a user with SYSDBA authorization). In such a scenario, you can use following two solutions:&lt;br /&gt;&lt;br /&gt;1. Use the ssh or rsh command directly to run the commands inside script as DB2CommandUser.&lt;br /&gt;2. Use db2_all instead to run the command inside script as DB2CommandUser. This allows you to have a generic script which can use either rsh or ssh remote shell program depending on the DB2RSHCMD registry variable.&lt;br /&gt;&lt;br /&gt;If you are using ssh as remote shell program for db2_all, ssh authentication should be configured such that ScriptUser can run the commands under the login of DB2CommandUser without prompted for any password or passphrase. This can be verified by running the following command while logged in as ScriptUser.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;ssh &lt;span&gt;DB2CommandUser@&amp;lt;HostName&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:georgia;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;hostname&gt; pwd&lt;br /&gt;&lt;/hostname&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;If the above command runs successfully without prompting for any password or passphrase, it indicates that the ssh authentication has been setup correctly. In the above command &amp;lt;HostName&amp;gt; &lt;hostname&gt;can be localhost or a remote host depending on where do you want to run the command.&lt;br /&gt;&lt;br /&gt;Similarly, if you are using rsh remote shell program for db2_all, the .rhosts file under the DB2CommandUser home directory must include the following line in order to allow ScriptUser to run command under DB2CommandUser login.&lt;br /&gt;&lt;/hostname&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;HostName&amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:georgia;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:courier new;"&gt;ScriptUser&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;hostname&gt;&lt;/hostname&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:georgia;"&gt;Where, &amp;lt;HostName&amp;gt; &lt;hostname&gt;is the host name of computer where ScriptUser exists. The permission of .rhosts file should not allow the Group or Other to write to this file. The recommended permission for .rhosts is 600, though 644 will also work.&lt;br /&gt;&lt;br /&gt;On Windows platform, db2_all uses “DB2 Remote Command Service” to run the commands on all database partitions that you specify. Also, RAHUSER should be the logon account associated with the DB2 Remote Command Service.&lt;/hostname&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-1547261260149438640?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/1547261260149438640/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=1547261260149438640&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/1547261260149438640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/1547261260149438640'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2007/07/db2all-and-rahuser.html' title='db2_all and RAHUSER'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35092861.post-5741379863859536243</id><published>2007-07-27T00:39:00.000-06:00</published><updated>2007-07-27T00:49:28.405-06:00</updated><title type='text'>Copy and Drop Schema</title><content type='html'>&lt;span style="font-family:georgia;"&gt;Do you need to make the exact copy of all the objects in a given schema? Are you planning to write a script for this task? If you are using DB2 version 9, perhaps you can avoid writing this script and still perform the same task using a single statement.&lt;br /&gt;&lt;br /&gt;DB2 version 9 provides a new stored procedure called ADMIN_COPY_SCHEMA that can be used to copy all the objects from one schema to another schema name. The syntax for this stored procedure can be found at&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/r0022035.htm"&gt;&lt;span style="font-family:georgia;"&gt;ADMIN_COPY_SCHEMA at DB2 Info Center&lt;br /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:georgia;"&gt;&lt;br /&gt;In addition to the copy schema stored procedure, DB2 9 also offers a drop schema stored procedure to drop all the objects in a schema. The stored procedure is called ADMIN_DROP_SCHEMA. The syntax of this stored procedure can be found at&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/r0022036.htm"&gt;&lt;span style="font-family:georgia;"&gt;ADMIN_DROP_SCHEMA at DB2 Info Center&lt;br /&gt;&lt;/span&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35092861-5741379863859536243?l=radheshk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://radheshk.blogspot.com/feeds/5741379863859536243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35092861&amp;postID=5741379863859536243&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/5741379863859536243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35092861/posts/default/5741379863859536243'/><link rel='alternate' type='text/html' href='http://radheshk.blogspot.com/2007/07/copy-and-drop-schema.html' title='Copy and Drop Schema'/><author><name>Radhesh Kumar</name><uri>http://www.blogger.com/profile/00945889642759528415</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp0.blogger.com/_Jidj7mFZ_XY/Rqz-SBcqYWI/AAAAAAAAAAU/OOH_glrafwg/s200/Radhesh5.jpg'/></author><thr:total>1</thr:total></entry></feed>
