Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x

DB2

IBM DB2 is a family of relational database server products developed by IBM that have been extended to support object-relational features and non-relational structures like JSON and XML. There are three main products in the DB2 family: DB2 for Linux, UNIX and Windows (informally known as DB2 LUW), DB2 for z/OS (mainframe), and DB2 for i (formerly OS/400), plus a version for IBM's Virtual Storage Extended (VSE) operating system.

Share tech news, updates, or what's on your mind.

Sign up to Post

What is the best way to monitor for queries that run > xx seconds?  I would love to have a table / file that I can look at each morning to see if there are any issues.  I've read about event monitors but I did not see a way to restrict them to a certain time range and we have so many queries that run, I am afraid to capture ever SQL statement that runs.  I think that would blow out my storage pretty quickly.

What is the most common way to do this with DB2?

Thank you!

Jim
0
NEW Veeam Agent for Microsoft Windows
LVL 1
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

DB2 10.5 on Windows.

Is there a dependence between reorg tables and reorg index?  So if I do a reorg table, will that automatically reorg the indexes on that table or are the indexes completely separate?  

Same thing other way around, if I reorg the indexes of a given table, will that automatically reorg the table as well?

I want to make sure I am not doing double the work by running reorg index and reorg table on same table.

From what I have read I think they are independent of each other, but my boss disagrees.

Thanks in advance!!!

Jim
0
I have been asked to generate Reports from lots of tables in DB2.

I want to learn to solve writing queries from simple to complex through lots of problems and suggested the solution.
0
DB2 10.5 on Windows

My database is about 300-400 GB.  My full once a week backup is 370 GB.  It is growing at a moderate pace (maybe 10% per month).  Yet when I do daily Delta backups, the file sizes are huge.  Here is what I am seeing.

Sat          Full Backup     371 GB
Sun        Delta                118 GB
Mon       Delta               120 GB
Tues       Delta               122 GB

There is no way my database is growing by 100+ GB per day.  The only other thing I can think of is that there might be a process that is updating a single field on multiple tables over and over again.  Maybe a timestamp or something.

So my question is, is there something about deltas that I don't understand?  Is a delta always 20% of database + actual data changed or some such?  Nothing I have read indicates that but I can't reconcile what I am seeing with what I know so far.  Any suggestions for find the root cause?  

Thank you!

Jim
0
How can I make a the rows into a columns for just one column value .

example : id   Team    date                   comments
                   1    1020    9/11/2017          This is comment 1
                   2    1020    9/11/2017          This is comment 2
                   3    1020    9/11/2017          This is comment 3
                   4    1020    9/11/2017          This is comment 4

Result should be
 1020  9/11/2017  This is comment 1 This is comment 2 This is comment 3 This is comment 4
0
Dear
There is any way to find a reason if insert record into database file not successfully inserted in journal

Thanks
0
DB2 10.5 on Windows.  Using TOAD for DB2 GUI.

This should not be hard, I do it every day in MS SQL.  I have a table I fill with RUNSTATS command if the date of last stats is > 7 days old.

CREATE TABLE MAINT.MYRUNSTATS 
( SQLCMD	VARCHAR(500) );

Open in new window

The data in that table looks like this.

RUNSTATS ON TABLE "db1"."USR_TBL" ON ALL COLUMNS ;
RUNSTATS ON TABLE "db1"."USG_TBL" ON ALL COLUMNS ;
RUNSTATS ON TABLE "db1"."ENTRY_TBL" ON ALL COLUMNS ;


I want to loop through the table and run each of the RUNSTATS commands.  Ideally I would create a SQL job to run this code each night so that my stats are always up to date.  But trying to do this is DB2 is making me pull out my hair (and I don't have any to spare).  Why is this so hard and why are there not more examples?  I know I am whinnying but seriously.  

DB2 DBAs have to be doing this kind of stuff all the time, but I can't find a single comprehensive example.  Just bits and pieces and half of them are CLP and half are for Linux and the rest are for Windows and you can't mix and match them.

Any help would be greatly appreciated.  I will need to do the same for table reorgs and index reorgs too.

Thank you.

Jim
0
I have below requirements like, below query should run on 3 conditions, daily, weekly and monthly.

daily rows should give output everyday, weekly should give output on only Saturday. And Monthly should give output on 1st Business day but if 1st is Saturday then output will come 3rd day, if 1st is Sunday then output should come on 2nd day.

select * from Tablename is giving me below 4 rows

Status  ID   COL1  COL2  
= = = = = = = = = = = = 
Daily   12    100  150.2
Daily   17     90  120.6
Weekly  24    180  50.6
Monthly 25    150  155.2

Open in new window


Now I want to show this data as per above requirements

I got my exact output for daily and Monthly by below SQL but need help on Monthly

Select * from Tablename
where
ID in (12,17) OR --daily
(DAYNAME(CURRENT DATE) = 'Saturday' AND ID = 24) --weekly
(TO_CHAR(DATE(CURRENT DATE)) = '01' AND ID = 25 AND DAYNAME(CURRENT DATE) NOT IN ('Saturday','Sunday')) --monthly

Open in new window


But my Monthly logic not giving me expected output.
0
DB2 10.5 on Windows.

I am working on a procedure that captures a variable from a select statement and if it is null then it needs to exit.  This is the code.

CREATE VARIABLE v_OLD_ID VARCHAR(15);

SET v_OLD_ID = (
SELECT a
FROM db2.table1
WHERE KEY = 12345);

SELECT v_OLD_ID from SYSIBM.SYSDUMMY1;  -- shows null

IF v_OLD_ID IS NULL THEN GOTO exit;

-- do other stuff

exit:
DROP VARIABLE v_OLD_ID;

Open in new window


When I run this I get this error.

ERROR [42601] [IBM][DB2/NT64] SQL0104N  An unexpected token "v_OLD_ID" was found following "IF ".  Expected tokens may include:  "JOIN <joined_table>".

Not sure what I am doing wrong.  Any suggestions would be greatly appreciated.  

Thanks!

Jim
0
ODBC setup successful; however, connecting from SSIS using ODBC trigger the following error message.


Error [42968][IBM][CLI Driver] SQL1598N. An attempt to connect to the database server failed because of a licensing problem. SQLSTATE=42968.
0
Command Line Tips and Tricks
Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

DB2 10.5 on Windows.

Does it make any difference if you do this

FROM Table1 t
JOIN Table2 tt ON (t.col1, t.col2, t.col3) = (tt.col1, tt.col2, tt.col3)

Open in new window


or this

FROM Table1 t
JOIN Table2 tt on t.col1 = tt.col1 AND t.col2 = tt.col2 AND t.col3 = tt.col3

Open in new window


I tried to Google it but could not explain the question well enough.

Thanks!

Jim
0
DB2 10.5 on Windows.

Trying to reorg some indexes and keep getting

SQL0270N  Function not supported (Reason code = "89").  = REORG INDEX is only supported for nonpartitioned indexes on partitioned tables.

Here is the command I am running.

REORG INDEX DP_IDX03 FOR TABLE DH.TABLE1 ALLOW WRITE ACCESS ;

But non of my tables are partitioned so I don't understand why this is happening.  That is the only reason I can find for this reason code.  Anyone have any thoughts?

Thanks!

Jim
0
Table A is ORDERS.  In this, there is the OrderNo and other columns such as:  total cost, total tax, total discount, total shipping.
Table B is ITEMS.  In this there is order# and rows for each item on an order (1 or more per order).

The problem:
I want my output to only show the total cost, total tax, total discount, total shipping on the first row of each order (there may be multiple rows due to multiple items).

As it is today shown below, but gives "orderDate, customer#, total cost, total tax, total discount, total shipping" on every row.  I only need this once per orderNo.  I'd like those fields to be blank on subsequent rows within each order.

select  tableA.OrderNO, orderDate, customer#, total cost, total tax, total discount, total shipping
 ,tableB.Item#, ItemDescription, ItemCost, ItemSalesPrice
from tableA
   join tableB on tableA.orderno = tableB.orderno

I'm using DB2 for i, but I'm hopeful I could adapt most any SQL query regardless of specific SQL implementation.
0
Can any one help me to get the hardening/ Benchmark document for IBM WebSphere. ?
0
DB2 10.5 on Windows

I am moving some tables to a new tablespace and when I try I get an error.  The command I am using is:

CALL SYSPROC.ADMIN_MOVE_TABLE( 'Schema1', 'TableName', 'PRD_DATA','PRD_INDX','PRD_LOB','', '', '', '','','MOVE');

Open in new window


The error I get is:
Error      8/24/2017 10:09:42 AM      0:00:01.515      <link> - DB2 Database Error: ERROR [42603] [IBM][DB2/NT64] SQL0010N  The string constant beginning with "'RUNSTATS ON TABLE  ON ALL COLU " does not have an ending string delimiter.      

Any clues?  I have done a goolge search of course and have not found anything yet.  Thank you!

Jim
0
DB2 10.5 on Windows.

I have a DB2 database that I am removing a large amount of old data from.  So tables with 130,000,000 rows will be reduced to 5,000,000.  I want to do this quickly and cleanly with minimum impact to storage.  I have read several articles on how to do this but each suggest a different way.

What is the most efficient way to do this?  Should I copy the data I am going to keep to a new table and then drop and recreate the original and then copy it back in?

Or should I use a delete or truncate routine?  If I do it this way, will I need to do a reorg with truncate on the tables afterwards?

Any suggestion would be very welcomed.  Thank you!

Jim
0
DB2 10.5 on Windows

I have a query I am trying to optimize and I want to test a couple of different things.  The issue is that after I run it for the first time the data is in cache so first run is 5 minutes and next run is 15 seconds.  In MS SQL I would clear the execution plan for the query before each run to compensate for that.  Is there something similar in DB2?

Thanks!
0
I require direction. I have never had to create a script before so I have no clue how to create it and run it but essentially I need a script to automate running a query and exporting to a .txt file.

I'm working with DB2 SQL on an IBM Power 8. I need a script that will run the following query:

select vend_num, vend_name
from iasp.vendor
order by vend_num

then output the records to vendor.txt. I have a Windows Server that connects to the DB2 database via ODBC. Seems simple enough but I'm not sure where to start.
0
DB2 10.5 on Windows

Is there anyway to create an index in an online mode?  I want to create a composite index on a large production table and I don't want to lock the table.  The table has about  29,063,052 million rows and is heavily used.

Thanks!
0
How To Install Bash on Windows 10
How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Hi everyone,

I would like to list all the tables which are in production and not in test.
I tried with  
          select * from QSYS2.SYSSCHEMAS
but I can't find a way to get the attribute.

Thank You !!
0
DB2 10.5 on Windows using TOAD for DB2 6.3

I am trying to get a list of users and their permissions, especially SYSADM users.  I was told I have SYSADM but I hit an error while trying to create a stored proc so I ran this...

SELECT * FROM SYSIBMADM.PRIVILEGES 
 WHERE AUTHID = 'ME' AND AUTHIDTYPE = 'U';

Open in new window


I get this.



I would expect to see SYSADM as one of my privileges if I were SYSADM.  Am I making a bad assumption?  How can get a definitive list of users with SYSADM permissions.  My thought is no one on the server may have SYSADM level permissions because ever query I run from what I find on Google returns nothing.

Thank you!
0
DB2 10.5 on Windows

We moved some large tables to new tablespaces in production and then restarted the server.  Now we can't log into our HADR server due to reason code 4.  From what I see reason code 4 is

Reason Code 4 = Connection requests to an HADR standby database are not allowed while the replay-only window is active. The replay-only window is active when DDL or maintenance operations are being replayed on the standby.

If the primary db was rebooted before the HADR changes were complete, could it get stuck like this?  I would assume it would just start up again when the primary came back online.

Thanks!
0
I am trying to write a function in DB2 and the function will parse a certain string based on delimiter and return as seperate fields .
The string I should pass will come from another query ,

example :
CREATE FUNCTIONSPLIT_STRING (varchar string)
  RETURNS TABLE or row  ( string1 VARCHAR(100),string2 VARCHAR(100))
 
   RETURN values (tempstring,tempstring1);--
END;

Now can I call this function and pass a set of strings like select somestring from table ? or use the same query select somestring from table in the function and iterate through it ?
0
Hi,

right  now need a study on any limitation on Oracle Golengate replication and MS SQL AOG for business case that need to setup 2 x site,  active active (not multi master). Then we try to POC on which one is better to use in terms of stability.

how about DB2's active active solution? any idea?

please present your idea.
0
Running DB2 10.5 on Windows

We have a DB2 10.5 HADR server set up that I should be able to use for read only queries.  I can connect to it (using TOAD), but when I do any selects from any table I get the following.

Lookup Error - DB2 Database Error: ERROR [] [IBM][DB2/NT64] SQL1773N  The statement or command failed because it requires functionality that is not supported on a read-enabled HADR standby database. Reason code = "1".

I checked the DB2_HADR_ROS registry entry and it is set to ON as it should be.

Has anyone else run into this?

Thank you!

Jim
0

DB2

IBM DB2 is a family of relational database server products developed by IBM that have been extended to support object-relational features and non-relational structures like JSON and XML. There are three main products in the DB2 family: DB2 for Linux, UNIX and Windows (informally known as DB2 LUW), DB2 for z/OS (mainframe), and DB2 for i (formerly OS/400), plus a version for IBM's Virtual Storage Extended (VSE) operating system.

Top Experts In
DB2
<
Monthly
>