<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DBMSguy.com</title>
	<atom:link href="http://dbmsguy.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://dbmsguy.com/blog</link>
	<description>Practical advice for the practical DBA</description>
	<lastBuildDate>Wed, 21 Dec 2011 18:36:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>DB2 LUW V9.7 CUR_COMMIT database configuration option &#8211; buyer beware</title>
		<link>http://dbmsguy.com/blog/2011/01/cur_commit_db_option/</link>
		<comments>http://dbmsguy.com/blog/2011/01/cur_commit_db_option/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 23:58:46 +0000</pubDate>
		<dc:creator>Paul Mayhew</dc:creator>
				<category><![CDATA[db2]]></category>
		<category><![CDATA[db config]]></category>
		<category><![CDATA[logbufsz]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[tuning]]></category>

		<guid isPermaLink="false">http://dbmsguy.com/blog/?p=309</guid>
		<description><![CDATA[<p>While working on a deadlocking problem, I came across the cur_commit optoin that is now available in version 9.7.  This option is part of the ongoing efforts to make DB2 more Oracle compliant. </p> <p>After reading about the cur_commit database option, it seemed to be a fair solution to the problem.  We installed/upgraded our databases to [...]]]></description>
			<content:encoded><![CDATA[<p>While working on a deadlocking problem, I came across the cur_commit optoin that is now available in version 9.7.  This option is part of the ongoing efforts to make DB2 more Oracle compliant. </p>
<p>After reading about the cur_commit database option, it seemed to be a fair solution to the problem.  We installed/upgraded our databases to v9.7 and enabled the option - our deadlocking problems were over.  Case closed.</p>
<p>Well, maybe not.  Here&#8217;s the rub.  If you read about what little information there is about cur_commit, you will find that the option works by reading logs to get the currently committed value if an update has been done.  This works great in theory and even in practice, but I found that during our performance tests, we suffered greatly.  Reading the logs does not seem to be especially efficient for these cases and our system suffered greatly. </p>
<p>In analyzing system counters, I noted that &#8216;Log pages read&#8217; (db snapshot) values were very high.  In response to this, I increased LOGBUFSZ value to something very large.  I started off at 4096 and this make no difference what-so-ever.  I am up to 20480 which is 80Mb  and things have mostly stabilized, but I am still seeing a lot of &#8216;log pages read&#8217; from time to time and when that value goes up, our performance goes down.</p>
<p>So the use of &#8216;CUR_COMMIT&#8217; option in 9.7 is not a cure-all for deadlocks and should be used with care.  I don&#8217;t think it should be turned on without some forethought and a good amount of performance testing.  The CUR_COMMIT option is really a bandaid option.  Most deadlocking problems are caused by bad application design and should be fix from that end if possible.</p>
<p><a title="cur_commit db config option" href="http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=/com.ibm.db2.luw.admin.config.doc/doc/r0053556.html" target="_blank">http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=/com.ibm.db2.luw.admin.config.doc/doc/r0053556.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dbmsguy.com/blog/2011/01/cur_commit_db_option/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>db2pd command &#8211; get info about db2</title>
		<link>http://dbmsguy.com/blog/2010/09/db2pd-command/</link>
		<comments>http://dbmsguy.com/blog/2010/09/db2pd-command/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 15:42:08 +0000</pubDate>
		<dc:creator>Paul Mayhew</dc:creator>
				<category><![CDATA[db2]]></category>
		<category><![CDATA[commands]]></category>

		<guid isPermaLink="false">http://dbmsguy.com/blog/?p=296</guid>
		<description><![CDATA[<p>The db2pd command is a relatively new command (released with version 8.2) that will tell you a huge amount of information about your db2 system.  I first made myself familiar with it when looking for a way to get the status of HADR without going through a snapshot output.</p> <p>db2pd -db sample -hadr - will tell you all you need [...]]]></description>
			<content:encoded><![CDATA[<p>The db2pd command is a relatively new command (released with version 8.2) that will tell you a huge amount of information about your db2 system.  I first made myself familiar with it when looking for a way to get the status of HADR without going through a snapshot output.</p>
<p><strong>db2pd -db sample -hadr</strong> - will tell you all you need to know about  your  hadr configuration status</p>
<p>The db2pd command can be run in two ways; you can run it interactively by entering db2pd and then whatever commands you want or you can simply enter the db2pd command with whatever parameters you want.  I&#8217;m not sure what the advantage of running it interactively is, but it&#8217;s there for you.</p>
<p>I find the output from some of the parameters very heavy indeed (some are just memory dumps for the most part).  You will find useful intormation however.</p>
<p>a few of the handier commands in my opinion are:<br />
<strong>db2pd -db sample -logs<br />
db2pd -db sample -locks<br />
db2pd -db sample -dbcfg<br />
db2pd -db sample -hadr</strong></p>
<p>here is a really <a href="http://gilroygonsalves.blogspot.com/2010/05/db2-v95-locking.html" target="_blank">good tutorial</a> on how to use db2pd for locks and the <a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp" target="_blank">entire manual</a> can be found in the command reference.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbmsguy.com/blog/2010/09/db2pd-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sql for sampling data from tables</title>
		<link>http://dbmsguy.com/blog/2010/09/sql-for-sampling/</link>
		<comments>http://dbmsguy.com/blog/2010/09/sql-for-sampling/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 16:15:23 +0000</pubDate>
		<dc:creator>Paul Mayhew</dc:creator>
				<category><![CDATA[db2]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[data sample]]></category>
		<category><![CDATA[data sampling]]></category>
		<category><![CDATA[dynamic]]></category>

		<guid isPermaLink="false">http://dbmsguy.com/blog/?p=197</guid>
		<description><![CDATA[<p>Some time ago, I had the requirement to sample data from a table to do validation work.  Basically, we wanted to validate syncronized data with a base table, but could not afford to compare every row.  We had to come up with a way to &#8216;sample&#8217; the data.  Each table we had to sample had [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago, I had the requirement to sample data from a table to do validation work.  Basically, we wanted to validate syncronized data with a base table, but could not afford to compare every row.  We had to come up with a way to &#8216;sample&#8217; the data.  Each table we had to sample had a different number of rows and in addition to that were growing.  The mechanizm had to be simple, yet take into account table size.  I did not want to do a custom query for every table.  I wanted something somewhat generic &#8211; something that I could say check &#8216;x&#8217; rows from this table, not check every &#8216;nth&#8217; row which would mean that the result would grow over time.</p>
<p>The obvious first consideration was to number the rows and do it from that, but considering we were doing this in a program, I needed something a little more elegant.  Here is the sql I came up with.<span id="more-197"></span></p>
<p>SELECT E.* FROM<br />
(SELECT ROWNUMBER() OVER (ORDER BY EMPNO) AS ROWNBR, EMPNO FROM EMPLOYEE ) TEMP,<br />
(SELECT INTEGER(ROUND((COUNT(*)/23.0),0)) AS HOWMANY FROM EMPLOYEE) TEMP2,<br />
EMPLOYEE E<br />
WHERE MOD(ROWNBR,HOWMANY)=0 AND E.EMPNO=TEMP.EMPNO</p>
<p>So here is what we do,<br />
TEMP is an ordered list of the table key &#8211; we number each row and order by the empno (or whatever key)<br />
TEMP2 is a cartesian join of the count of the table and how many rows you want.  In this case it is 23 rows<br />
E is the table we want and join to the above<br />
The where clause is the key &#8211; we only take rows that have a modulus of 0 when you devide the rownumber by how many rows you want</p>
<p>Notes:</p>
<ol>
<li>This was written for the sample database employee table, however I did have to modify it to have more than 42 rows</li>
<li>Small tables will have inaccurate results just because of the math so this works best on larger tables</li>
<li>The number of rows returned is not exactly what was requested.  Once again because of the math, but it is usally close.  I found the larger the table, the more accurate the result.  You can add a &#8216;FETCH FIRST n ROWS ONLY&#8217; (where &#8216;n&#8217; is your value) so you don&#8217;t get more than you want.</li>
<li>How often do you find a legitimate use for a cartesian join?</li>
<li>Don&#8217;t ask for more rows than are in the table &#8211; this can cause errors with the mod function</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://dbmsguy.com/blog/2010/09/sql-for-sampling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inline database shell scripts using awk</title>
		<link>http://dbmsguy.com/blog/2010/09/inline-database-shell-scripts/</link>
		<comments>http://dbmsguy.com/blog/2010/09/inline-database-shell-scripts/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 21:01:37 +0000</pubDate>
		<dc:creator>Paul Mayhew</dc:creator>
				<category><![CDATA[scripts]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[db2]]></category>
		<category><![CDATA[dba]]></category>
		<category><![CDATA[dbmsguy]]></category>
		<category><![CDATA[korn]]></category>
		<category><![CDATA[paul mayhew]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://dbmsguy.com/blog/?p=181</guid>
		<description><![CDATA[<p>One of the things I find very powerful in my day to day work as a DBA, is the use of inline shell/awk scripts.  I use this technique when I need to do the same thing to many objects.  I often use it when I want something quick and dirty or create a base script [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things I find very powerful in my day to day work as a DBA, is the use of inline shell/awk scripts.  I use this technique when I need to do the same thing to many objects.  I often use it when I want something quick and dirty or create a base script to work from.</p>
<p>An example might be when I want to do row counts on every table, or maybe set up a reorg on all the tables in a database.</p>
<p>Here is the command string you can use to do such a thing:</p>
<p><strong>db2 connect to sample</strong></p>
<p><strong>db2 -x &#8220;select tabschema, tabname from syscat.tables where tabschema=&#8217;DB2INST1&#8242; and type=&#8217;T'&#8221; | awk &#8216;BEGIN{print &#8220;db2 connect to sample&#8221;} {print &#8220;db2 -v \&#8221; select count(*) from &#8220;$1&#8243;.&#8221;$2&#8243;\&#8221;"}&#8217; | ksh</strong></p>
<p>The above inline script will select all the tables and return tablenames, then piping that into awk, we first print a connect statement and then print all the count statements.  All of this is then piped into a ksh.  The connect must be put there because a new instance of ksh is generated.</p>
<p>The base query can, of course, be customize to whatever suits your needs.</p>
<p>The pipe in to ksh is optional as you could just direct it to an output file and use it later and or make further modifications.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbmsguy.com/blog/2010/09/inline-database-shell-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>db2 batch scripts &#8211; tips and tricks &#8211; part 2</title>
		<link>http://dbmsguy.com/blog/2010/08/db2-batch-scripts-tips-and-tricks-part-2/</link>
		<comments>http://dbmsguy.com/blog/2010/08/db2-batch-scripts-tips-and-tricks-part-2/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 00:18:42 +0000</pubDate>
		<dc:creator>Paul Mayhew</dc:creator>
				<category><![CDATA[db2]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://dbmsguy.com/blog/?p=155</guid>
		<description><![CDATA[<p>I&#8217;ve always been a little frustrated with db2 when running scripts and command lines with fact that when a command would run like insert, update or delete, you never knew how many rows you affected.  Some GUI products will tell you, but with command line it would just come back as being successful (or not) and it [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always been a little frustrated with db2 when running scripts and command lines with fact that when a command would run like insert, update or delete, you never knew how many rows you affected.  Some GUI products will tell you, but with command line it would just come back as being successful (or not) and it was up to you to validate what you really did with a subsequent query.</p>
<p>Being a DBA, I always feel the need to validate what I do especially with ad hoc statements to ensure that I have done what I expected.</p>
<p>Enter the <strong>m </strong>option on the db2 command line.  This is a relatively new switch that will cause db2 to return to you how many rows were affected. The m option was introduced with verison 9.</p>
<p>To do this from the command line:</p>
<p><strong>db2 -m &#8220;delete from test&#8221;</strong> will return</p>
<p><strong>  Number of rows affected : 18<br />
DB20000I  The SQL command completed sucessfully.</strong></p>
<p>To do this from a script:</p>
<p><strong>db2 -tvmf test.db2</strong></p>
<p>By doing this, you will have the number of rows affected at your finger tips, not more hoping or assuming or doing count before/count after!</p>
<p>Happy DBAing</p>
]]></content:encoded>
			<wfw:commentRss>http://dbmsguy.com/blog/2010/08/db2-batch-scripts-tips-and-tricks-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>db2 batch scripts &#8211; tips and tricks &#8211; part 1</title>
		<link>http://dbmsguy.com/blog/2010/07/db2-batch-scripts-tips-and-tricks-part-1/</link>
		<comments>http://dbmsguy.com/blog/2010/07/db2-batch-scripts-tips-and-tricks-part-1/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 14:18:15 +0000</pubDate>
		<dc:creator>Paul Mayhew</dc:creator>
				<category><![CDATA[db2]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://dbmsguy.com/blog/?p=148</guid>
		<description><![CDATA[<p>There are a lot of things you can do with db2 batch scripts that can make your life easy.  In this set of posts I will talk about just a few things that might make your life easier.</p> <p> -s switch- I find the -s switch the handiest of all.  This will allow you to stop [...]]]></description>
			<content:encoded><![CDATA[<p>There are a lot of things you can do with db2 batch scripts that can make your life easy.  In this set of posts I will talk about just a few things that might make your life easier.</p>
<p><span id="more-148"></span><strong> -s switch</strong>- I find the -s switch the handiest of all.  This will allow you to stop the script execution if there is an error in the script. To do this execute your scripts with &#8220;db2 -stvf filename&#8221;.  By doing this, you will ensure the successful execution of your script.  If the script encounters an error, it will just stop at that point.  Checking becomes a little easier because you need only go to the bottom of the script for basic checking.</p>
<p>One additional trick &#8211; you can turn off the -s off and on in the script stream.  This allows you to disable checking for certain parts of your script you might expect to fail.  Things such as dropping a table that might or might not exist.  To do this your script would look like this:</p>
<p>update table &#8230;&#8230;;<br />
<strong>update command options using s off;<br />
</strong>drop table test.table;<br />
<strong>update command options using s on;</strong><br />
update table &#8230;&#8230;;</p>
<p>you would then execute with db2 -stvf filename</p>
<p>I guess of course you could just leave out the -s and use the &#8220;update command options&#8221; at the top of the script to turn it on, but I usually don&#8217;t do that because I want it on more than off.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbmsguy.com/blog/2010/07/db2-batch-scripts-tips-and-tricks-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 7 &#8212; First Impressions</title>
		<link>http://dbmsguy.com/blog/2010/01/windows-7-first-impressions/</link>
		<comments>http://dbmsguy.com/blog/2010/01/windows-7-first-impressions/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 18:43:57 +0000</pubDate>
		<dc:creator>Paul Mayhew</dc:creator>
				<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[opinions]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://dbmsguy.com/blog/?p=138</guid>
		<description><![CDATA[<p>A long time XP user, I was very nervous about getting a new system with windows 7.  Would anything work?  Would it be slower?  All kinds of things ran through my head.  I read all the reviews and for the most part, it seemed like a sucessful release, but then?&#8230;&#8230;..</p> <p></p> <p>I finally bought a [...]]]></description>
			<content:encoded><![CDATA[<p>A long time XP user, I was very nervous about getting a new system with windows 7.  Would anything work?  Would it be slower?  All kinds of things ran through my head.  I read all the reviews and for the most part, it seemed like a sucessful release, but then?&#8230;&#8230;..</p>
<p><span id="more-138"></span></p>
<p>I finally bought a new system which had Windows 7&#8230;. I got myself a HP P6240F with</p>
<ul>
<li>8 Gb of memory &#8212; can&#8217;t have too much memory can you?</li>
<li>Intel Q8300 quad core 2.5 GHz</li>
<li>Windows 7 &#8211; 64bit</li>
<li>5200 rpm, 750Gb SATA hard drive</li>
</ul>
<p>I&#8217;m no gamer, so the graphics is no biggy for me, pretty much us it for business.  I do us DB2, so the extra memory will come in handy.</p>
<p>This is a replacement system, not an upgrade, so I didn&#8217;t have to worry about data much as it still resides on the old system.  Same with my applications, if it didn&#8217;t work on W7, then I could always leave it.</p>
<p><strong>First Impressions -</strong>Happy, I think.  Got the system home, plugged it in and it went through a little setup process to install Windows 7.  HP seems to do it nicely, although there are some minor annoyances like bloatware type stuff.  It&#8217;s fast, but nothing is installed, so no big surprise there.  The &#8216;areo&#8217; stuff is kinda kool.</p>
<p><strong>Installing my software &#8211; </strong>Next step is to install all of my varous software.  Here is where the problems start.  My printer is fairly new &#8211; HP C6380 and that auto installed fine.</p>
<p>One of the things about Windows 7 is that it does not come with a mail client.  No more outlook express.  At first I could not find my windows office 2003 disk, so I installed my old office 2000 apps.  Outlook did not work from office 2000.  I tried a few others &#8211; Thunderbird and Windows live mail.  Didn&#8217;t like the very much but they worked fine.  I finally found my windows office 2003 and installed that and outlook was fine.</p>
<p>My biggest problem was with my video/photo editing software.<br />
-Ulead Video Studio would not even install.  That was disappointing as I really like it.<br />
-Photo Exposion Deluxe 3 does not work very well either.  You can install it, but it has problems finding libraries, so in the end does not work.</p>
<p>Those are the two most notable.</p>
<p>My other problem was my accounting software (MYOB 11) does not work as well.  Had to leave that installed on XP.  Pretty small annoyance, but notable if you do not have a backup system.</p>
<p>My other big problem is that my backup software does not work.  Acronis True Image Home works somewhat, but hangs when I am doing backups&#8230; it has been relegated to the useless pile now.  The restore function seems to work ok, but there are occasional corruptions.</p>
<p>Sometimes my printer gets &#8216;forgotten&#8217; &#8212; I go to print something and the printer is gone.  Only way to get it back is to reboot.  An annoyance, but not that big a deal &#8211; it doesn&#8217;t happen that often.</p>
<p>I have not had any problems with bluescreen crashes or freezing issues.  It has run nicely since I got it.  With all my software installed I run at about 1.5 Gb in use minimum.  Goes up from there, so my advice is to get at least 4Gb of memory &#8211; stay away from those 2Gb bargan machines.</p>
<p><strong>Last Impressions &#8211; </strong>In the end, I&#8217;m pretty hapy with my new Windows 7 machine.  I like that it is 64Bit as that is the way of the new world.  As more software is upgraded to 64bit, I&#8217;ll be better positioned to take advantage of it.  The boot/shutdown times are good.  Boots up much quicker than XP as well as recovery from sleep.  Other than the photo/video software problems, I think I&#8217;ll be happy with my investment.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbmsguy.com/blog/2010/01/windows-7-first-impressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting records based on the first and last days of a month</title>
		<link>http://dbmsguy.com/blog/2009/12/getting-records-based-on-the-first-and-last-days-of-a-month/</link>
		<comments>http://dbmsguy.com/blog/2009/12/getting-records-based-on-the-first-and-last-days-of-a-month/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 01:06:50 +0000</pubDate>
		<dc:creator>Ivan Beg</dc:creator>
				<category><![CDATA[db2]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[DATE]]></category>
		<category><![CDATA[Timestamp]]></category>

		<guid isPermaLink="false">http://dbmsguy.com/blog/?p=132</guid>
		<description><![CDATA[<p>Have you ever had a situation where you needed to select rows from a table for a specific month?   This example demonstrates how to retrieve all of the records belonging to the previous month by setting the first and last days in the WHERE clause of a SELECT statement.   But with some tweaking, you can [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever had a situation where you needed to select rows from a table for a specific month?   This example demonstrates how to retrieve all of the records belonging to the previous month by setting the first and last days in the WHERE clause of a SELECT statement.   But with some tweaking, you can make this query retrieve data from any month you wish.</p>
<p><span id="more-132"></span></p>
<p>For this example, we&#8217;ll assume that we have a table in a data warehouse called DW.TRANSACTION with two columns (TRANSACTION_ID and EFFECTIVE_TS) that is populated and up to date.</p>
<p>To retrieve the previous month&#8217;s records, we would create a query of the form:</p>
<blockquote>
<pre>SELECT
       TRANSACTION_ID
      ,EFFECTIVE_TS
FROM
       DW.TRANSACTION
WHERE
       EFFECTIVE_TS &gt;= TIMESTAMP_ISO(DATE(CURRENT DATE) - (DAY(CURRENT DATE)-1) DAYS - 1 MONTH)
AND    EFFECTIVE_TS &lt;= TIMESTAMP_ISO(DATE(CURRENT DATE) - (DAY(CURRENT DATE)-1) DAYS) - 1 MICROSECOND
;</pre>
</blockquote>
<p>If you would like to retrieve data from two months ago, the WHERE clause would be changed to:</p>
<blockquote>
<pre>       EFFECTIVE_TS &gt;= TIMESTAMP_ISO(DATE(CURRENT DATE) - (DAY(CURRENT DATE)-1) DAYS - 2 MONTHS)
AND    EFFECTIVE_TS &lt;= TIMESTAMP_ISO(DATE(CURRENT DATE) - (DAY(CURRENT DATE)-1) DAYS - 1 MONTH) - 1 MICROSECOND</pre>
</blockquote>
<p>At this point, you can keep increasing the values for the MONTHS to keep going into the past.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbmsguy.com/blog/2009/12/getting-records-based-on-the-first-and-last-days-of-a-month/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DB2 HADR for dummies &#8211; Part 3</title>
		<link>http://dbmsguy.com/blog/2009/12/db2-hadr-for-dummies-part-3/</link>
		<comments>http://dbmsguy.com/blog/2009/12/db2-hadr-for-dummies-part-3/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 19:47:47 +0000</pubDate>
		<dc:creator>Paul Mayhew</dc:creator>
				<category><![CDATA[db2]]></category>
		<category><![CDATA[hadr]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://dbmsguy.com/blog/?p=124</guid>
		<description><![CDATA[<p>This is the last post about HADR, I think I covered most of the basics of HADR finishing off with how it switches primary and standby.  What I have gone over is the basics of HADR.  There are many other topics within HADR.  One important thing to remember is to NEVER do unlogged operations (careful [...]]]></description>
			<content:encoded><![CDATA[<p>This is the last post about HADR, I think I covered most of the basics of HADR finishing off with how it switches primary and standby.  What I have gone over is the basics of HADR.  There are many other topics within HADR.  One important thing to remember is to NEVER do unlogged operations (careful with the load command).  Not only will it &#8216;break&#8217; HADR standby, but it will not tell you &#8212; you&#8217;ll not find out until you switch over to the standby to find it unusable.  I believe that in version 9.7, we are being allowed access to the standby.  This will allow you to validate the usability of the standby as well as other things like reporting.</p>
<p><span id="more-124"></span></p>
<p>This entry is about how to use HADR.  Once again, just the basics.</p>
<p>The command to switch the primary/standby pair is:</p>
<p>from the standby database:<br />
<strong>db2 takeover hadr on database sample</strong></p>
<p>simple as that, the standby is now the primary and the old primary is now the standby.</p>
<p>There is also a feature &#8211; ACR (automatic client re-route) which can automatically automatically re-route your client to the new primary database when it can not access the current primary.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbmsguy.com/blog/2009/12/db2-hadr-for-dummies-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DB2 HADR for dummies &#8211; Part 2</title>
		<link>http://dbmsguy.com/blog/2009/11/hadr-for-dummies-part-2/</link>
		<comments>http://dbmsguy.com/blog/2009/11/hadr-for-dummies-part-2/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 22:54:06 +0000</pubDate>
		<dc:creator>Paul Mayhew</dc:creator>
				<category><![CDATA[db2]]></category>
		<category><![CDATA[hadr]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://dbmsguy.com/blog/?p=91</guid>
		<description><![CDATA[<p>Okay, so here we go &#8230;. setting up an hadr environment&#8230;.  HADR in it&#8217;s lowest form is very straight forward to set up.  Here are the steps to start HADR</p> <p></p> You need to have either a second machine with DB2 installed, or alternately you can use a second instance.  I&#8217;m sure I don&#8217;t have [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so here we go &#8230;. setting up an hadr environment&#8230;.  HADR in it&#8217;s lowest form is very straight forward to set up.  Here are the steps to start HADR</p>
<p><span id="more-91"></span></p>
<ol>
<li>You need to have either a second machine with DB2 installed, or alternately you can use a second instance.  I&#8217;m sure I don&#8217;t have to tell you that using a second instance of DB2 on the same machine defeats the whole purpose of this, but it is fine for testing</li>
<li>Make sure you have Log Retain set on either explicitly or implicitly</li>
<li>Make sure you have db cfg <strong>LOGINDEXBUILD</strong> set to On<br />
you need to set the following db config parameters &#8211;<br />
<strong>HADR_LOCAL_HOST</strong> set to the IP address or host name of the local host<br />
<strong>HADR_LOCAL_SVC</strong> set to the port you are going to assign<br />
<strong>HADR_REMOTE_HOST</strong> set to the IP address of standby instance &#8211; same as LOCAL if using an alternate instance<br />
<strong>HADR_REMOTE_SVC</strong> set to the standby port should be at least LOCAL +2<br />
<strong>HADR_REMOTE_INST</strong> set to standby instance name</li>
<li>Make a backup of your database &#8211; can be either online or offline</li>
<li>Send the backup to the standby machine.  If you are using two instances, then you can skip this</li>
<li>restore from the backup on the standby instance  &#8212; I&#8217;m assuming you are using the IBM SAMPLE database for this excerise.</li>
<li>On the standby database, you need to set the same db config values except you need to flip them around so they are correct &#8211; LOCAL values become REMOTE values.</li>
<li>On the standby machine/instance &#8220;db2 start hadr on database sample as standby&#8221;</li>
<li>On the primary machine/instance &#8220;db2 start hadr on database sample as primary&#8221;</li>
<li>Check if HADR is working &#8211; Do &#8220;db2 get snapshot for database on sample&#8221; &#8212; in the output look for:<br />
<strong>HADR Status<br />
  Role                   = Primary<br />
  State                  = Peer<br />
  Synchronization mode   = Nearsync<br />
  Connection status      = Connected , 11/26/2009 17:47:40.447523<br />
  Heartbeats missed      = 0<br />
  Local host             = 192.168.0.105<br />
  Local service          = 10000<br />
  Remote host            = 192.168.0.101<br />
  Remote service         = 11000<br />
  Remote instance        = DB2<br />
  timeout(seconds)       = 120<br />
  Primary log position(file, page, LSN) = S0000036.LOG, 0, 000000000B3B0000<br />
  Standby log position(file, page, LSN) = S0000036.LOG, 0, 000000000B3B0000<br />
  Log gap running average(bytes) = 0</p>
<p></strong>if it says anything other than &#8216;peer&#8217; then there is a problem. One common problem is a firewall&#8230; if you are doing this on a windows box with a firewall, then you will have to open up the HADR ports both ways.</li>
</ol>
<p> </p>
<p>You now have a HADR pair up and running &#8212; anything you do on the primary will be done on the standby as well.  Be sure to review things that don&#8217;t work. </p>
<p> </p>
<p>Standby for Part 3 where we will go over how to switch back and forth from primary to standby.</p>
]]></content:encoded>
			<wfw:commentRss>http://dbmsguy.com/blog/2009/11/hadr-for-dummies-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

