db2

DB2 CLI result output

When running command-line queries in MySQL you can optionally use '\G' as a statement terminator, and instead of the result set coulmns being listed horizontally across the screen, it will list each column vertically, wich the corresponding data to the right. Is there a way to the same or a similar thing with the DB2 command line utility...

DB2 Online Database Backup

I have currently 200+ GB database that is using the DB2 built in backup to do a daily backup (and hopefully not restore - lol) But since that backup now takes more than 2.5 hours to complete I am looking into a Third party Backup and Restore utility. The version is 8.2 FP 14 But I will be moving soon to 9.1 and I also have some 9.5 data...

Select Poorly Used Start and End Dates From Facility Table

I'm using DB2, although a solution using any flavor of SQL would likely be easy enough for me to convert. I didn't design this database, or the application that uses the database. I haven't the power to change this application, how it works, or the data. Because it defies what I consider to be conventional use of a start and an end da...

Oracle or DB2 - who is the market leader in business sector?

Which of the two databases is most popular in business/industry? I ask this because in terms of straight revenue or market share, I suspect they're about 50-50, because US government is big on DB2. So, discounting government, military, and academia, which database vendor has the greatest share of the business segment? ...

Group by when joining the same table twice

I'm writing a query to summarize some data. I have a flag in the table that is basically boolean, so I need some sums and counts based on one value of it, and then the same thing for the other value, like so: select location ,count(*) ,sum(duration) from my.table where type = 'X' and location = @location and date(some_tstamp...

Is there a 'greatest' function in db2?

I found in MYSQL and apparently other database engines that there is a "greatest" function that can be used like: greatest(1, 2, 3, 4), and it would return 4. I need this, but I am using IBM's DB2. Does anybody know of such an equivalent function, even if it only accepts 2 parameters? I found somewhere that MAX should do it, but it do...

Why can you have a column named ORDER in DB2?

In DB2, you can name a column ORDER and write SQL like SELECT ORDER FROM tblWHATEVER ORDER BY ORDER without even needing to put any special characters around the column name. This is causing me pain that I won't get into, but my question is: why do databases allow the use of SQL keywords for object names? Surely it would make more ...

Tuning/Best Practices Inetsoft Style Report BI Tool ?

Is anyone using the business intelligence tool Inetsoft Style Report ? I'm stuck with it and was wondering if anyone has advice on tuning and/or best practices for server admin? We are running on a fast Solaris box using Tomcat with a db2 database. ...

DB2 Query Output - Different Behavior

I've two tables TAB_A and TAB_B. TAB_A is master table and TAB_B is child / transaction table. TAB_A is having COL_A (Primary key) and TAB_B is having COL_B (Primary key) and also COL_A. For some business reason, Foreign key is not defined between TAB_A and TAB_B on column COL_A. I've four records in TAB_B with some values say 1, 2, 3 ...

Exporting UTF8 data from db2

I have a db2 table that contains values in many languages (including right-to-left languages.) When I export this table on a linux box using cli's ''export'' command, I get a good looking comma delimited text file (DEL file,) but when I try it on aix, it replaces all characters that are not in ascii with 0x1a. I tried playing around wi...

How to find all open/active connections in DB2 (8.x)

I'm currently working with Db2 Enterprise Server V 8.2 with FixPak 10 And I want to retrieve list of all the open active connections with an instance. In Oracle there is a utility program called "Top Session" which does the similar task. Is there any equivalent in DB2? Thanks in advance, Kamal ...

How to query range of data in DB2 with highest performance?

Usually, I need to retrieve data from a table in some range; for example, a separate page for each search result. In MySQL I use LIMIT keyword but in DB2 I don't know. Now I use this query for retrieve range of data. SELECT * FROM( SELECT SMALLINT(RANK() OVER(ORDER BY NAME DESC)) AS RUNNING_NO , DATA_KEY_VALUE , ...

How to revoke permission of Windows Administrator user from DB2?

On IBM DB2 v.9 windows, when someone connect to database by Server\Administrator user DB2 database will automatic accept and grant all permission to this user right? But, some environment Administrator of server no need to see every data in database. So how to prevent Administrator use connect to database? ...

Connecting to DB2 via .NET DbConnection

Our current DB Connection provider model relies on database connectivity to use DbConnection (System.Data) based objects. We can connect to DB2 (*Nix * Windows) via OdbcConnection, but we would like to allow the use of native DB2 Drivers. Is there any way to do so (either .Net framework, OpenSource or (last choice) vendor) without bre...

Create DB2 History Table Trigger

Hi, I want to create a history table to track field changes across a number of tables in DB2. I know history is usually done with copying an entire table's structure and giving it a suffixed name (e.g. user --> user_history). Then you can use a pretty simple trigger to copy the old record into the history table on an UPDATE. However, ...

IBM DB2 LPAD/RPAD

I use db2 v.9.1 on windows 2003 server so it can not use LPAD or RPAD functions scalar. because that functions support only z/OS right? Now, I use this way for pad zero when COLUMN1 type is VARCHAR RIGHT('0000' || COLUMN1 ,4) AS RPAD LEFT('0000' || COLUMN1 ,4) AS LPAD Have better way for replace LPAD or RPAD function? ...

Left outer join (join between three tables)?

I have a main table that I must get data from. I have a left outer join where the fields will match 40% of the time. And then I have another join where I need to match the data from table A with. This is the SQL in pseudo code. This query won't work. -- This is the part I want to do but doesn't work. AND H.COL3 = A.STATE???? I am ...

How do we do a DBMS OUTPUT line in db2 (like you can in oracle)

In oracle we can print output by dbms_output.put_line() but DB2 I don't know. Now, I use 'signal' for print some message when I debug. ...

embedded sql in C

I've been attempting to write embedded SQL statements for DB2 that ultimately gets compiled in C. I couldn't find a tutorial or manual on the embedded SQL syntax for C for reference. One case I would like to do is to insert data into a table. I know most embedded sql statements need the initalizer EXEC SQL, but thats the extent of my k...

What is a "query parameter" in C++?

Hi, We were using stringstream to prepare select queries in C++. But we were strongly advised to use QUERY PARAMETERS to submit db2 sql queries to avoid using of stringstream. Can anyone share what exactly meant by query parameter in C++? Also, share some practical sample code snippets. Appreciate the help in advance. Edit: It is stri...