Skip to content

SQL Bits

You're here to find quick SQL recipes.

  • Home
  • Topics
    • Generic SQL
    • PostgreSQL
    • MariaDB
    • MySQL
    • Oracle
    • SQL Server
    • Db2
    • Informix
    • SQLite
  • Advertising
  • Write
  • About

Category: Db2

Db2: Loop over an array

We saw in another article how to build an array from an SQL query (from each row, or from a column). This article shows how to loop over an array items.

Continue reading Db2: Loop over an array
Published January 29, 2022
Categorized as Db2 Tagged level-beginner

Db2: How to create an array from a query

Db2 ordinary arrays can be constructed and populated from an SQL query. Let’s see how to do it.

Continue reading Db2: How to create an array from a query
Published December 12, 2021
Categorized as Db2 Tagged level-intermediate

Db2: How to create IDENTITY columns

Db2 supports the IDENTITY keyword to create autoincremental columns. Several options are available.

Continue reading Db2: How to create IDENTITY columns
Published November 7, 2021
Categorized as Db2 Tagged level-intermediate

Db2: Stored procedures examples in SQL

Simple examples of SQL stored procedures in Db2.

Continue reading Db2: Stored procedures examples in SQL
Published October 17, 2021
Categorized as Db2 Tagged level-expert

Db2 hash functions: HASH(), HASH4(), HASH8()

Db2 supports three different hash functions, and each of them can use different algorithms. Let’s shred some light on them to understand their use cases.

Continue reading Db2 hash functions: HASH(), HASH4(), HASH8()
Published October 2, 2021
Categorized as Db2 Tagged level-intermediate

Db2 temporary tables: ON COMMIT and ON ROLLBACK

Let’s see how to preserve, empty or drop temporary tables when a transaction succeeds (COMMIT) or fails (ROLLBACK).

Continue reading Db2 temporary tables: ON COMMIT and ON ROLLBACK
Published September 12, 2021
Categorized as Db2 Tagged level-expert

Db2: Working with aliases

Let’s see how to create, modify and use an alias in Db2. An alias can refer to a table, a sequence or a module. Aliases exist in several databases, but we’re focusing on Db2 syntax here.

Continue reading Db2: Working with aliases
Published August 23, 2021
Categorized as Db2 Tagged level-expert

Comments on database objects

Why and how to write comments on database, tables, and other objects on most DBMSs. How to read comments.

Continue reading Comments on database objects
Published August 9, 2021
Categorized as Db2, Generic SQL, Oracle, PostgreSQL Tagged level-intermediate

Db2: Copying a table

How to create a copy of a table. The copy can contain data, a selective portion of the data, or it can be empty.

Continue reading Db2: Copying a table
Published July 27, 2021
Categorized as Db2 Tagged level-intermediate

Db2 triggers: FOR EACH ROW, FOR EACH STATEMENT, DB2ROW, DB2SQL

There is some confusion about the FOR EACH, the MODE, and the BEFORE / AFTER clauses of Db2 CREATE TRIGGER. While other clauses are common to most DBMSs, MODE is a Db2 unique feature. Their meaning is simpler than it seems.

Continue reading Db2 triggers: FOR EACH ROW, FOR EACH STATEMENT, DB2ROW, DB2SQL
Published July 26, 2021
Categorized as Db2 Tagged level-expert

Posts navigation

Page 1 Page 2 Older posts
  • Twitter
  • Email
SQL Bits
Proudly sponsored by Vettabase.