The IBM DB2 Enterprise Server Edition is a relational model database server developed by IBM. It primarily runs on Unix (namely AIX), Linux, IBM i (formerly OS/400), z/OS and Windows servers.

learn more… | top users | synonyms

3
votes
1answer
465 views

Help with DB2 Procedure

I have the following query: CREATE PROCEDURE MYPROC( IN @TABLES VARCHAR(500)) DYNAMIC RESULT SETS 1 LANGUAGE SQL SPECIFIC MYPROC NOT DETERMINISTIC MODIFIES SQL DATA CALLED ON NULL INPUT BEGIN ...
3
votes
1answer
1k views

Filtering on a virtual column from a UNION ALL with LEFT OUTER join causes a table scan?

I asked this question on SO but havn't got many bites and even a vote to close for being "Off Topic." So, I thought this stack exchange might be better suited. Consider the following SQL... SELECT ...
3
votes
1answer
2k views

How to find out what caused the database(DB2) in a locking state

I know how to check the DB is in a lock state or not, but my question is how to find out which query caused the lock on table /db. IS there any log file getting created if something unexpected ...
3
votes
2answers
2k views

DB2 to require password each time

I am using db2inst1 to connect to a database in DB2 which I have installed on my machine. Therefore, db2inst1 user does not require username/password authentication (borrows them from the OS). I would ...
3
votes
1answer
1k views

DB2 Defining remote database alias

I'm using DB2 9.7.0.3 for AIX. I want to select data from a remote database, also running DB2 9.7.0.3 for AIX, and insert it into the local database I'm connected to. I believe the query for this ...
3
votes
2answers
1k views

Problem installing DB2Express

I installed DB2 Express 10.1 on my Windows 7 (64bit) notebook. Now after the installation finished I cannot connect to the database. During the installation I specified "C:\Daten\db\db2" as the ...
2
votes
2answers
538 views

Generalisation in databases

I am working on a Hospital Management project in DB2. I have one table for staff with a primary key of staff_id. The hospital has to have different staff... e.g doctors,nurses,e.t.c. Is it better to ...
2
votes
3answers
189 views

UPDATE … FROM … syntax for iSeries for a MS SQL Server developer

When I wanted to update a table to the values from another table in SQL Server I would use following syntax: UPDATE t1 SET t1.a = t2.a FROM t1 INNER JOIN t2 ON t2.b = t1.b What would be iSeries 7 ...
2
votes
2answers
971 views

CREATE INDEX for long columns

I am looking for alternative to create index on long column: create table line ( field_key integer not null, value varchar(4000), ... ); create index key_value_idx on line ...
2
votes
4answers
156 views

Is there any rule of thumb to optimize sql queries like this

this is my first question here. Although I've been helped out from this forum over a hundred times. I was having difficulties in optimizing sql query. It takes hours to execute. Record set is also ...
2
votes
3answers
950 views

How do I join two tables on two different instances of DB2?

There are two instances of DB2 running on the same machine. One has a table aliased to the a table in the other one. Is there a way to do this in DB2 or does it have to be done via an external tool? ...
2
votes
3answers
425 views

Not getting a result set in SSRS 2008r2 from an iSeries DB2 SQL stored procedure

After reading 'Defining an SQL procedure' section of DB2 UDB for iSeries SQL Programming Concepts V5R2 and 'Returning result sets from stored procedures' section of i5/OS Information Center, Version 5 ...
2
votes
2answers
1k views

DB2 will not INSERT into Created Temp Table that I created

I normally use SQL Server but for this project I'm having to learn DB2. If I can get the below code to work I'm set for the whole project. Below is a elementary example of what I cannot get to work. ...
2
votes
2answers
2k views

DB2 Trigger: only update current row

I've created following trigger : CREATE TRIGGER probeer2 AFTER INSERT ON libtn01leb.kofax_release FOR EACH ROW UPDATE libtn01leb.kofax_release SET RRNR='bleh' This trigger will update EVERY ...
2
votes
2answers
260 views

db2 (LUW) equivalent for oracle drop user cascade

This question is related to creating and initialising test and development databases for an application that has the database running on LUW (linux-unix-windows) On oracle, we have an os user (on ...
2
votes
1answer
466 views

DB2 equivalent to T-SQL's REPLICATE?

In T-SQL there is a method, REPLICATE(char,N), which will make a string with N values of a certain character. This is very helpful when querying into JDE. Does anyone know if there is a DB2 ...
2
votes
2answers
813 views

altering a db2 table with huge amount of data

I have a table in DB2 which is having 99 columns and 900,000 records of data. I want to alter the table with one extra column as below: ALTER TABLE MYSCHEMA.PRODUCT ADD UPDATE_DT DATE However, the ...
2
votes
1answer
28 views

DB2 SUM / INNER JOIN question

I have a query that is the following: SELECT CMSTKY AS Customer, CMNAME AS BusinessName, WKMDL# As Model WKSLD# AS Sales FROM GPCMP INNER JOIN GPCM1P ON GPCMP.CMSTKY = ...
2
votes
2answers
201 views

When is it appropriate database design to use a separate schema?

I am developing a database which has data sourced from many different applications. In my first pass at design, I placed the staging tables each in a schema named for their source application. As ...
2
votes
1answer
683 views

How to loop through AS400 table with cursor

I have a AS400 table that contains multiple rows per person. Each row contains data concerning a transaction by the person including points assigned to each transaction. I read through all rows for ...
2
votes
1answer
192 views

How to restore from a backup of a very old version of DB2 (version 6.1 backup)?

I am helping a client with some legacy application that is still running DB2 6.1 on Windows 2000! I am helping them migrate to newer software/hardware infrastructure. I have a backup of the DB2 6.1 ...
2
votes
1answer
1k views

query to find closest lesser date

I have a table with rates. each rate has an effective starting date. (the ending date of any rate is implied by the existence of a record with a newer effective starting date.) I also have a table ...
2
votes
1answer
183 views

How to choose working database in DB2?

In SQL server I can use the USE statement to switch between working databases. Is there a similar command for DB2?
2
votes
2answers
645 views

In DB2, how can I disable NLJOIN?

I want to indicate to the optimizer, via SET or optimization profiles, that NLJOIN shouldn't be used at all when optimizing a query. I've been looking for this for a while without any success. I ...
2
votes
1answer
844 views

How to restore IBM DB2 database from AIX to Windows?

I had made backup from remote IBM DB2 server in AIX using this command: ./db2 backup database DBEMP to /home/dbemp/backup Then I grab the backup file using FTP Client from my Windows. I run this ...
2
votes
2answers
238 views

SQL3550W: … target column has been defined as GENERATED ALWAYS

I am trying to export + import data from a table in a db2 database to another. But while running the export command I am getting the following error. SQL3550W The field value in row "26" and column ...
2
votes
2answers
227 views

How can I automate copying DB2 table data between remote Servers?

I have two IBM DB2 servers at separate remote locations. I need to copy data from several tables on one database on the first server to another database in the second server. Previously I've used ...
2
votes
2answers
2k views

Do I need to RUNSTATS after a REORG in DB2?

The REORG documentation says: BUILD Builds indexes. Updates index statistics. But I have always heard REORG/RUNSTATS as if they should be paired. Can anyone verify that "Updates index ...
2
votes
2answers
2k views

Parallel inserts cause deadlock on DB2

The scenario is the following: The application attempts to insert into the same table from two parallel threads making 4000 insertions in each thread (separate transaction per thread). It causes the ...
2
votes
3answers
918 views

db2 range partitioning attach and detach issue

We have a table which is used in many select Queries, as it is be accessed by customers to fetch their information. Also they can change their information too whenever they want. We had to retrieve ...
2
votes
1answer
1k views

DROP SCHEMA in db2

How do I drop a schema in db2 if it has got some objects in it? db2 DROP SCHEMA SCHEMA_NAME For some reason I am not able to drop the tables in the schema, so how can I force to drop the ...
2
votes
1answer
819 views

DB2: database hangs while trying to execute simple select query on specific table

No errors or warnings, database just hangs while trying to execute simple select query on specific table. Other tables are accessible until I trying to query specific (faulty) table. This should not ...
2
votes
1answer
242 views

In DB2, what are the alternative ways of evaluating an index's (or several indexes) benefit?

I'm trying to evaluate different approaches to analyzing the benefit of changing the set of indexes that are available. If I pick some representative queries from my workload, I can run EXPLAIN and ...
2
votes
1answer
669 views

What are the best practices for ETL of data from one OLTP system to another?

First off, I want to post that I am a developer and not a DBA, so I am trying to approach this from the standpoint of what is the best thing to do, rather than just assuming I can do everything ...
2
votes
1answer
1k views

Migration from DB2 to MySQL

Does any one have experience on migration from DB2 to MySQL ? Please share with me. I tried googling, but I have not received much information on this.
2
votes
1answer
60 views

creating PKs for existing tables - altering column constraints

I am quite new to DB2, so I googled around how to ask questions correctly and so I hope I can provide all necessary information. I have an existing table A1230922.CALSONW with several (195) columns ...
2
votes
1answer
34 views

DB2 MQT not rewriting role playing columns

If in a MQT, if I have 2 referential constraints to the same table (role playing) , usage of one of the constraints doesnt allow the query to be optimized Example FACT_SALES DIM_BILL_TO_ID --> ...
2
votes
2answers
132 views

How to transfer database from SQL Server to DB2?

I have a database file on disk called project.mdf. I want to import this into IBM DB2. How do I import this database?
2
votes
1answer
86 views

How efficiently does iSeries DB2 use index with WHERE <>?

MS SQL dev here, this is my first attempt to optimize a DB2 query on iSeries. I was asked to help improve a huge query which consists entirely of dozens of joined subselects. Some of those subselects ...
2
votes
1answer
418 views

DB2 Communication link failure issue

I would like to get your valuable suggestions for the below problem. My Perl application connects to a DB2 database and keeps inserting data into a table. The application successfully inserts data ...
2
votes
2answers
344 views

DB2 UPDATE TRIGGER

I am trying to create a trigger in a DB2 database that runs on the update of a column in one table, and then fills in another table with certain values. For example, there is a power unit table with ...
2
votes
1answer
558 views

DB2 Server Table Space Locked

At work we keep receiving the following DataException seemingly at random when one of our processes tries to write/access a table for one of our clients: com.ibm.db.DataException: A database manager ...
2
votes
1answer
344 views

How to create Buffer Pool in Database dedicated only for ONE BIG table?

I have table TICKET with 400K records in database (DB2). I wish to create one huge buffer pool which will be dedicated only to this one big table for faster response. What are the steps to do it? ...
2
votes
3answers
1k views

How do i subtract a number of days from a prepared statement parameter in db2?

I have a C# application using OLEDB to connect to a DB2 database. Basically, I want to do this: SELECT CALC.WEEK, COUNT(CALC.ID) AS TRANSACTIONS , SUM(CALC.SUBTOTAL) AS REVENUE FROM ( ...
2
votes
1answer
2k views

DB2 Express on Windows 7 - Disable security?

I'm trying to install DB2 Express-C on my PC (Windows 7 pro), but no matter how I've installed or configured it, I can't grant the ability to create databases to my windows domain account. No matter ...
2
votes
1answer
165 views

DB2 Count problem

We have a query that returns over 20,000 rows on some occasions but times out due to the large amount of data. We have written a COUNT(*) query to throw an error if the record count is more than ...
2
votes
1answer
178 views

DB2: Is it good to create the LONG table space to use 32 KB data page

Our DB2 database(V9.7) has only defined one table space to store all the big object like xml. And xml size could be different. Some are about 2kb average. And some are 7kb average. So does it make ...
2
votes
2answers
1k views

DB2 LOAD data into table - Interpreting the error messages

I encountered some constraint issues when loading data from file into table ** SQL3109N The utility is beginning to load data from file "xag". SQL3500W The utility is beginning the "LOAD" phase at ...
2
votes
2answers
587 views

Syntax changes between DB2 for i (DB2/400) v5r4 and v6r1

Does anyone know where can I find list of syntax changes between DB2 for i v5r4 and v6r1? We are currently migrating a backing database for an application from DB2 for i v5r4 to v6r1 and found out ...
2
votes
1answer
476 views

Does DB2 have equivalents for Oracle's UTL_ENCODE and UTL_RAW modules?

I'm looking for something similar to: utl_smtp.command(conn, utl_encode.base64_encode(utl_raw.cast_to_raw(<username>))); I couldn't find any reference among the DB2's system-defined modules ...