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
23
votes
3 answers

Is Null Greater Than Any Date Data Type?

I have this query in DB2 SELECT * FROM SOMESCHEMA.SOMETABLE WHERE SYSDATE > @A If the SYSDATE is NULL, would it be greater than any value of @A, assuming that @A and SOMESCHEMA.SOMETABLE.SYSDATE is a Date data type? Please help. Thanks in advance.
John Isaiah Carmona
  • 5,260
  • 10
  • 45
  • 79
23
votes
4 answers

Query validation using C#

I am looking for a query validator in C#, which allows me to parse the SQL text from a textbox and verify whether it's correct or not before sending it for execution (MS SQL or DB2 queries).
Cannon
  • 2,725
  • 10
  • 45
  • 86
23
votes
1 answer

How to find table and column in DB2 with tbspaceid tableid specified in error message

I get following error message when trying to insert an object in the database: com.ibm.db2.jcc.am.SqlIntegrityConstraintViolationException: DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=TBSPACEID=2, TABLEID=19, COLNO=0,…
Mathias G.
  • 4,875
  • 3
  • 39
  • 60
23
votes
4 answers

How to get the last insert ID from a table

I want to get the value of the last ID insert in a table. How I can do this?
Enrique San Martín
  • 2,202
  • 7
  • 30
  • 51
23
votes
7 answers

Cycle detection with recursive subquery factoring

Oracle SQL can do hierarchical queries since v2, using their proprietary CONNECT BY syntax. In their latest 11g release 2, they added recursive subquery factoring, also known as the recursive with clause. This is the ANSI standard, and if I…
Rob van Wijk
  • 17,555
  • 5
  • 39
  • 55
22
votes
6 answers

How do I connect to a Websphere Datasource with a given JNDI name?

I'm using Websphere Portal 7.0 and creating a portlet with RAD 8.0. My portlet is trying to make a db2 connection to a remote server. I wrote a java program locally to do a basic JDBC connection to the server and get records from a table. The code…
jason
  • 2,219
  • 5
  • 33
  • 66
22
votes
11 answers

In DB2 Display a table's definition

Hello everybody I am learning DB2 and would like to know how to see a table's characteristics after I create one. Similar to the EXPLAIN TABLE command in MySQL. Thank you.
Gladys
22
votes
2 answers

Cannot use group by and over(partition by) in the same query?

I have a table myTable with 3 columns. col_1 is an INTEGER and the other 2 columns are DOUBLE. For example, col_1={1, 2}, col_2={0.1, 0.2, 0.3}. Each element in col_1 is composed of all the values of col_2 and col_2 has repeated values for each…
user3557405
  • 567
  • 1
  • 3
  • 19
22
votes
5 answers

DB2 Date format

I just want to format current date into yyyymmdd in DB2. I see the date formats available, but how can I use…
zod
  • 12,092
  • 24
  • 70
  • 106
21
votes
5 answers

How to identify DB2 port number

I have to make DB2 connection in java using port number. Is there any command in DB2 or any way that can get the DB2 port number? I have not used the default port 50000 while making DB2 connection as this port can be changed during DB2…
user628083
  • 353
  • 1
  • 5
  • 15
21
votes
2 answers

decimal(s,p) or number(s,p)?

recently, while working on a db2 -> oracle migration project, we came across this situation. the developers were inadvertently creating new table structures using decimal(s,p) columns. I didn't remember Oracle supporting this, but then some digging…
Raghav
  • 2,128
  • 5
  • 27
  • 46
20
votes
3 answers

Make a column nullable in DB2 when Data Capture is enabled

I'm using db2 version 9.7* and it seems impossible to make a NOT NULL column nullable in any straightforward way. Unfortunately the solution of using a more developer friendly database is not available. Basically, in MySQL speak, I want to do…
lukewm
  • 21,433
  • 6
  • 26
  • 28
20
votes
8 answers

IsNull function in DB2 SQL?

Is there a performant equivalent to the isnull function for DB2? Imagine some of our products are internal, so they don't have names: Select product.id, isnull(product.name, "Internal) From product Might return: 1 Socks 2 Shoes 3 Internal 4…
Dave
  • 917
  • 1
  • 8
  • 20
20
votes
3 answers

determine DB2 text string length

I am trying to find out how to write an SQL statement that will grab fields where the string is not 12 characters long. I only want to grab the string if they are 10 characters. What function can do this in DB2? I figured it would be something like…
Frantumn
  • 1,725
  • 7
  • 36
  • 61
20
votes
3 answers

DB2 database in Oracle SQL developer

I've heard it's possible to connect to a mainframe DB2 database with a client like Oracle SQL developer. I've looked on-line and can't seem to find the connector files needed to do this in SQL developer. Can anyone direct me to a link to make this…
Frantumn
  • 1,725
  • 7
  • 36
  • 61