Questions tagged [db2]

DB2 is a family of database servers developed by IBM. Supported platforms for DB2 servers are z/OS (formerly OS/390), Linux, UNIX, and Windows (referred to collectively as DB2 for LUW), and IBM i (formerly OS/400 or i5/OS). Originally designed as a relational engine, IBM has expanded DB2's capabilities on some platforms to include native XML support and an RDF-compliant graph store. When posting DB2 questions, please specify the platform and version.

DB2 is a family of database servers developed by IBM. The supported platforms for DB2 servers are z/OS (formerly OS/390), Linux, UNIX, and Windows (referred to collectively as DB2 for LUW), and IBM i (formerly OS/400 or i5/OS). Originally designed as a relational engine, IBM has expanded DB2's capabilities on some platforms to include native XML database features and an RDF-compliant graph store. On the IBM i platform, DB2 for i is tightly integrated into the operating system in a variety of ways, including a unique file system layer that allows database tables to be treated as structured files and vice versa.

DB2 for LUW has different editions: Express-C, Express Edition, Workgroup Server Edition, Enterprise Server Edition and Advanced Enterprise Server Edition. Each of these editions has different engine capabilities and different limits on the amount of RAM and the number of CPU cores that DB2 can use. DB2 for LUW offers a smooth upgrade path for databases that were created in a lower edition of the product (e.g., going from Workgroup Server Edition to Enterprise Server Edition).

DB2 Express-C is a no-cost DB2 engine that runs on Linux and Windows and is authorized for production use and redistribution. As part of the DB2 10.5 release in June 2013, IBM extended the system resource limits for DB2 Express-C to allow the database engine to use up to 16GB RAM and two CPU cores and set a maximum size of 15 terabytes per database.

In October 2009, IBM introduced DB2 pureScale, a database cluster solution for AIX on System p, suitable for online transaction processing (OLTP) workloads. Linux x86_64 support for DB2 pureScale on IBM System x hardware was added in August 2010. IBM based the design of DB2 pureScale on the Parallel Sysplex implementation of DB2 data sharing on z/OS. DB2 pureScale provides a fault-tolerant, clustered database engine that uses low-latency RDMA messaging and GPFS shared storage to present the appearance of a single, monolithic database to the application layer.

To handle large data volumes and complex queries that are common to online analytical processing (OLAP), DB2 for LUW provides a shared-nothing clustering implementation known as the database partitioning feature (DPF), which uses hash key partitioning to evenly distribute a single copy of the database across multiple servers. Incoming queries are automatically multiplexed to access multiple partitions in parallel. DPF was introduced in 1994, as was at times rebranded as DB2 Parallel Edition, DB2 Extended Enterprise Edition, or InfoSphere Warehouse.

The 10.5 version includes the BLU acceleration that consists in storing the data in columnar format. It allows us to store data in rows or columns, and that improves analytics performance.

Free DB2 Books

12687 questions
36
votes
5 answers

insert multiple rows into DB2 database

I want to insert multiple rows into a DB2 table. I have a query that looks like this insert into tableName (col1, col2, col3, col4, col5) values (val1, val2, val3, val4, val5), (val1, val2, val3, val4, val5), (val1, val2, val3, val4,…
Frantumn
  • 1,725
  • 7
  • 36
  • 61
35
votes
4 answers

How does one escape an apostrophe in db2 sql

I'm looking for the db2 equivalent of T-SQL's: INSERT INTO People (Surname) VALUES ('O''Hara');
grenade
  • 31,451
  • 23
  • 97
  • 126
34
votes
2 answers

Declare a variable in DB2 SQL

Does anyone know how to run the following SQL Server code in DB2? I am converting SQL Server scripts so that they will run on a DB2 system and am having some problems wrapping my head around the use of variables in DB2. T-SQL code This is…
I_AM_JARROD
  • 685
  • 2
  • 7
  • 20
34
votes
2 answers

DB2: Won't Allow "NULL" column?

Part of a complex query that our app is running contains the lines: ...(inner query) SELECT ... NULL as column_A, NULL as column_B, ... FROM ... This syntax of creating columns with null values is not allowed in DB2 altough it is totally OK in…
GyRo
  • 2,586
  • 5
  • 30
  • 38
32
votes
3 answers

SqlException: DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: null

What does sqlcode -302 means? Where do i get the sqlcode definitions? Please advice Thanks,
beetri
  • 1,039
  • 11
  • 24
  • 40
32
votes
3 answers

Adding a static value to the results of an SQL query

I'm wondering if there is a way to accomplish this with an SQL query. I have a table, lets call it "LISTOFTHINGS" that has two fields of interest "ID" and "NAMEOFTHING" What I want to do is construct a query such that what gets returned is the…
Zeke Hansell
  • 665
  • 2
  • 6
  • 11
31
votes
5 answers

db2 SQLCODE -668 when inserting

While I was inserting data into a table (db2), I got this error: Message: Operation not allowed for reason code "7" on table "ELSAG.ICGR1106".. SQLCODE=-668, SQLSTATE=57016, DRIVER=3.50.152,... when I googled it, I found that the previous ALTER…
user438159
  • 497
  • 4
  • 7
  • 9
31
votes
7 answers

DB2 Comma Separated Output by Groups

Is there a built in function for comma separated column values in DB2 SQL? Example: If there are columns with an ID and it has 3 rows with the same ID but have three different roles, the data should be concatenated with a comma. ID |…
gaurav
  • 2,886
  • 6
  • 24
  • 26
31
votes
3 answers

How do you get values from all columns using ResultSet.getBinaryStream() in jdbc?

How do I to write an entire table to a flat file (text file) using jdbc? So far I've attempted the following: Statement statement = connection.createStatement(); ResultSet result = statement.executeQuery("SELECT * FROM tablename"); …
Harish Vangavolu
  • 965
  • 2
  • 12
  • 27
30
votes
7 answers

show all tables in DB2 using the LIST command

This is embarrassing, but I can't seem to find a way to list the names of the tables in our DB2 database. Here is what I tried: root@VO11555:~# su - db2inst1 root@VO11555:~# . ~db2inst1/sqllib/db2profile root@VO11555:~# LIST ACTIVE DATABASES We…
Lightbeard
  • 4,011
  • 10
  • 49
  • 59
29
votes
8 answers

Description of columns in a DB2 table

How can we know the description of every column in a table(DB2) through SQL? My data base is DB2.
deepu
27
votes
6 answers

Exporting result of select statement to CSV format in DB2

Is there any way by which we can export the result of a select statment to CSV file, just like in MySQL. MySQL Command; SELECT col1,col2,coln into OUTFILE 'result.csv' FIELDS TERMINATED BY ',' FROM testtable t;
Rakesh Juyal
  • 35,919
  • 68
  • 173
  • 214
26
votes
1 answer

Simple DB2 Query for connection validation

I'm looking for a simple DB2 query that can be used to test if a database connection in pool is still valid. It needs to be a generic query that would execute regardless of which databases exist. For other database servers, I've used something like…
Eric Tuttleman
  • 1,320
  • 1
  • 9
  • 16
26
votes
4 answers

How do I use DB2 Explain?

How do I use DB2's Explain function? -- both to run it, and to use it to optimize queries. Is there a better tool available for DB2? I've built queries before, but the only way I've had to tell how long they'd take is to run them and time them --…
Trevel
  • 801
  • 1
  • 7
  • 13
25
votes
6 answers

How to update multiple columns in single update statement in DB2

I want to update multiple columns of a table in DB2 with single Update statement. Any hint or idea will be appreciable. Thanks.
Superman
  • 871
  • 2
  • 13
  • 31