Questions tagged [db2]

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.

Filter by
Sorted by
Tagged with
1
vote
1answer
30 views

DB2 - Using stored procedure variable in a “CREATE TABLE as (..)” Statement

migrating from Netezza to DB2 we face the following problem: CREATE OR REPLACE PROCEDURE DoStuff() BEGIN DECLARE vStarttime TIMESTAMP; SET vStarttime = now(); CREATE TABLE foo AS ( ...
0
votes
0answers
11 views

IBM DB2 z/OS - Do not UNLOAD DECIMAL rows exceeding a certain length

I have an IBM DB2 table where I want to UNLOAD data from so that I can load it into another DB2 table. The database is running on z/OS. Both tables have the same columns (and types), except one ...
1
vote
2answers
45 views

DB2 window function - running total of X for preceding N minutes worth of rows

Very new to window functions but think I get the idea. I'm trying to get a rolling sum of one column in 10 minute intervals (determined from a separate timestamp column) A working sample might ...
0
votes
1answer
36 views

Improving performance of mapping standardized values with non equi joins - LIKE operator

I have a large-ish data warehouse staging table (~2.5 million rows) that is using a mapping table to standardize a text column. I have an update statement that works perfectly, but has terrible ...
1
vote
1answer
39 views

Distribution statistics on VARCHAR / VARGRAPHIC columns?

It appears that only the first n characters is used as colvalue for varchar/vargraphic columns. From my test below it appears to be 33/16. Is the length documented somewhere? I tried to search the ...
0
votes
2answers
57 views

Can indexes be deactivated for particular queries in DB2?

I'm trying to evaluate the impact of a new index on various queries that run against a DB2 11.1 database. It would be convenient to be able to force the optimizer to ignore the new index on a query-...
0
votes
1answer
40 views

Linked server to DB2 table locks

I have a problem with a SQL linked server connected to a DB2 database on an AS400 IBM iSeries. I configured an ODBC connection from the ODBC Data Source utility. Once configured the ODBC, i created ...
0
votes
1answer
19 views

Difference between DataLinks and External tables

There was a feature called DataLinks that allowed to access data in files from SQL. This was introduced in Db2 V5.2 and removed in V9.7. However, in v11.5 there is a "new" feature called external ...
0
votes
1answer
41 views

Unable to alter table - reason code is 10

I'm trying to run this: ALTER TABLE AMMLIBT.SAGRPPF ADD UNIQUE (ID) ADD CHECK ( IS_BUDGETABLE IN ( 0 , 1 )) ; Which gives me this: SQL State: 55019 Vendor Code: -7008 Message: [SQL7008] ...
0
votes
2answers
62 views

Archive old data in a large table in DB2

I have a very large non-partitioned table with ~4,500,000,000 records: ODS.LARGE_TABLE. The table has stored 3 months of data with ~50,000,000 rows per day, therefore resulting total of ~4,500,000,...
0
votes
1answer
29 views

DB2: how to export data file and own by db2inst1 via ADMIN_CMD

There is some requirement that I need to run the export command in Java via JDBC. Hence below is the command I execute CALL SYSPROC.ADMIN_CMD('EXPORT TO /tmp/header.csv OF DEL SELECT * FROM MYTABLE');...
-1
votes
2answers
158 views

db2 select statement from a table name where the table name is a variable [closed]

I need to select all the table row count from a db2 database. I have a query to select all the schema and table name: select rtrim(tabschema)||'.'||rtrim(tabname) as tableName from syscat.tables ...
1
vote
0answers
20 views

Support for JDBC 4.2?

As far as I can tell, the jcc driver shipped with 11.5 (https://www.ibm.com/support/pages/db2-jdbc-driver-versions-and-downloads) still uses JDBC 4.1. Any rumours of, if a later fixpak will switch to ...
0
votes
2answers
30 views

Errors in DB2 8.0 db2diag.log

We have a very old PeopleSoft HR system running on DB2 8.x. Numerous times a day we get the following errors in the db2diag.log file. 2019-11-04-01.22.24.012784-300 E16054C794 LEVEL: Error (...
0
votes
0answers
35 views

DB2 iseries query without cache

Is it possibile to perform a query without using cached data? I need to test many similar queries and I need to compare process time. To make the measures comparable, I need to run each query without ...
0
votes
1answer
29 views

How to ensure database is cataloged

I am planing to upgrade my database. I am referring to this website: https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.qb.upgrade.doc/doc/t0007193.html On the Before you begin ...
0
votes
0answers
19 views

Commvault DB2 Agent Archive issue

We are facing issue with Archive deletion from the last 45 days. Scenario: We have installed the Commvault DB2 agent on a Unix server and we have provided the path during the installation as ...
1
vote
1answer
48 views

Any impact of upgrade db2 from V10.5 to V11.5?

Good day, Due to the DB2 v10.5 will end of support on next year April. I would like to change my application database version to v11.5. Before apply this to production, I do it in my local VM first....
1
vote
1answer
50 views

Disable autocommit for DB2 connection in Oracle SQL Developer

I am connecting to the DB2 database using oracle SQL developer, but automatically it is committing, i checked in the advanced menu the auto commit feature is turned off. I am confused now, can someone ...
0
votes
1answer
30 views

Recursion only if a criteria is met

I'm using DB2 V7 and I have a two table PARTLIST and PARTTYPE as follow : CREATE TABLE PARTLIST (PART VARCHAR(16), SUBPART VARCHAR(16), QUANTITY INT, ...
-1
votes
1answer
28 views

Product part Query (BOM) [closed]

I'm using DB2 V7 and i have a product table like below : select * from product; Product |Component|Quantity |Line number| --------+---------+---------+------------ Product1|Part1 |1 |1 ...
0
votes
1answer
193 views

db2 expired password but cannot reset

Has anybody encountered this problem with a db2 server? I'm running a development database and connecting to the database gives me a password expired error. Trying to reset it will give me an invalid ...
-3
votes
1answer
34 views

Create a trigger that will prevent any one from updating personal information of others [closed]

I'm trying to create a trigger in DB2 that will prevent any one from updating any personal information that does not belong to them I.E. FIRST_NAME, LAST_NAME, EMAIL , PHONE_NUMBER columns. I'm trying ...
0
votes
1answer
23 views

Switching context between two instances from one account

I have a server with two instances running on it (a dev environment) where we use one login to access either instance. I wanted to be able to switch context from one instance to the other without ...
0
votes
1answer
16 views

What's a way/ways to return Identity element (that is auto-generated) in a table from a stored procedure?

I have tables in my db with auto generated primary keys that I want to get a hold of when inserting new rows from my Java calling code. I'm trying to create stored procedures that handle the insertion ...
0
votes
2answers
64 views

How to change default db2 database admin username to something else in Linux?

I have a DB2 database version 11.1 on Linux - rhel 7.7 in my test environment. I need help on how to change the default db2 admin username to something else, ie. db2inst1 to dbroot. And the new db2 ...
0
votes
1answer
37 views

Conditional Join in DB2

2 tables are given Table T_PRICE P_Price P_Type P_Route 15 red long 10 long 5 small Table T_ROUTE R_Type R_Route blue long red ...
0
votes
1answer
336 views

Connection Error while connecting SQL Developer with DB2

I am trying to connect Oracle SQL Developer with DB2 Database. I have added db2jcc4.jar, db2jcc.jar and db2jcc_license_cu.jar Libraries in "Third Party JDBC Driver" DB2 tabs appears Entered Username ...
0
votes
2answers
71 views

How to journal tables in SQL?

Say I have a C# script that creates 50 tables in MYLIB. Currently, after running the script, I have to go into System i Navigator and manually attach the MYLIB/USRJRN to each of the tables' ...
1
vote
2answers
63 views

Differences between EDU and thread

In DB2, there is this command that shows active EDUs (engine dispatchable units): db2pd -edus There are two fields in the respective output: EDU ID and TID. According to this db2pd page from the ...
0
votes
2answers
35 views

Pending changes from a finished job

I'm getting the following error: Uncommitted changes pending for file MYTABLE in library MYLIB. CPF325E Cause . . . . . : Uncommitted changes are pending for file MYTABLE in library ...
0
votes
1answer
65 views

How to access Multiple DB2 Relational Databases In A Single Query

I need a solution for below: There are Two DB2 instances with two authorization ID on the same server and can be access using same user User1. Example: To access Inst1DB, I use the following ...
0
votes
1answer
39 views

adding 2nd catalog for linked server to DB2

I am unable to figure out how to add multiple catalogs for a DB2 linked server. I have an initial Linked server setup and working properly, but I am struggling to figure out how to add multiple ...
1
vote
2answers
96 views

DB2 Load Utility Primary Key vs. Unique Index

In short, does the Primary Key double as a Unique Index? Some background: I am trying to load a bunch of data into two tables using the DB2 Load utility loading in IXF file types. The data is ...
0
votes
2answers
34 views

How to I get a list of non subscribed users from this database?

I have 2 tables. 1) subscription_types | type | 'type1' 'type2' 2) subscriptions | user | sub_type | subscribed | 'U1' 'type1' 'Y' 'U1' 'type2' 'Y' 'U2' 'type1' 'Y' ...
1
vote
2answers
181 views

Db2 REORGCHK returns the SQL2310N (Error “-668”) message

I have a Db2 database on my Linux laptop. The database is not heavily loaded. I access it from time to time for the development purposes. I removed a column: db2 "alter table SCHEMA.TABLE drop ...
0
votes
2answers
679 views

CHARINDEX equivalent in DB2

I am trying to select the domain from the column where I have email addresses. For example, I have a table email_table and a column email with email addresses as below. johndoe@gmail.com jhefid@...
1
vote
1answer
152 views

DB2 SUM of MAX values, single table

I have looked through many of the questions asked and answered but can't seem to find my answer, even kludging the provided answers into my queries - most usually fail, the remainder provide garbage ...
0
votes
1answer
23 views

DB2 Audit Policy not producing EXECUTE data

I'm trying to set up an Audit facility on a DB2 AWSE V10.5 FP5 database running on Red Hat Linux Server 6.8. The definition for the policy is : ALTER AUDIT POLICY Failures CATEGORIES ...
0
votes
1answer
49 views

Insert values with leading zeros

How do I insert values with leading zeros in it? Example. db2 "insert into db2inst1.asd_currency (currency_code, currency_name, currency_decimal_count, currency_code_desc) values ('007', 'afghani'...
-1
votes
2answers
56 views

Get longest strings in DB2 column

I'm trying to get the longest strings in a given DB2 table. I know the max length of the columns from the schema, but I want to generate a report showing the longest actual values. For example, if ...
0
votes
2answers
28 views

How to set column text when creating a view in SQL?

By default, when creating a view, for the Text of each column, if the column is a direct selection from a table/physical file then it will use the Text of that table/physical file's column. If it's ...
0
votes
1answer
51 views

Dropping a table/column automatically drops views using it - how to warn instead?

If I have a view that uses a column, and I remove that column/table, the view is dropped automatically. Is there a setting I can change such that it instead prevents the removal of the column/table, ...
2
votes
3answers
275 views

In DB2 LUW, When should I use a 4K, 8K, or 16K tablespace rather than just creating a 32K tablespace and being done with it?

We're using DB2 LUW 10.5 & 11.1 on Windows & Linux systems, in case it's relevant to he answers. Question: Is there a time where it would be correct to use 4K rather than 32K? If so, why? (...
0
votes
1answer
56 views

Error trying a manual's example in DB2 11.1.4.4

When trying this example from the DB2 11.1 manual: VALUES (JSON_VALUE('{"id":"987"}', 'strict $.id' RETURNING INTEGER)); I get this error: SQL0171N The statement was not processed because the ...
0
votes
2answers
167 views

Is it possible to compress CLOB columns in DB2 10.5

I have a table with a CLOB(1M). If I enable compression (compression yes adaptive) on the the table the CLOB is not compressed. Is there a way to make this work in DB2 10.5?
1
vote
1answer
60 views

db2 cross platform function/variable?

Is there a db2 function/procedure/variable that can be used to determine what platform a data source origins from? sysibm.sysdummy1 exists, so I assume that this is Db2, but some of the SQL does not ...
0
votes
1answer
79 views

How to stop a db2 instance properly?

I have a db2 instance, and I need to stop it properly, clean, without any db2stop force. I need this in order to restart it fast in a batch process. I am completly sure there are not connections or ...
0
votes
0answers
44 views

drop_cache effects on database

I have several machines with: databse: db2 10.5 OS: CentOS 6.9 on some of machines cached memory is high and i need to run this command to free some memory: echo 3 > /proc/sys/vm/drop_caches ...
0
votes
2answers
38 views

Is it worth duplicating a table for different types of an entity when one should be unique?

In my database, I have a CUSTOMER table. I'm migrating an OPPORTUNITIES table, which contains two different types of opportunity, each having identical columns (e.g. status, reason lost, probability ...