---
title: "DB2 SQL Global variables top usage"
description: "Global variables in DB2 v11. Read all the features here."
url: https://srinimf.com/2015/10/07/db2-global-variables-in-version-11/
date: 2015-10-07
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2015/10/pexels-photo-5668851.jpeg?fit=1880%2C1253&ssl=1
categories: ["DB2"]
tags: ["DB2 Global Variable", "DB2 Tips and Solutions", "Global Variables in DB2 V11"]
type: post
lang: en
---

# DB2 SQL Global variables top usage

Traditionally within a relational database system, most interactions between an application and the DBMS are in the form of [SQL statements](https://www.brainbench.com/testcenter/taketest/SQL-%28ANSI%29-2011-Fundamentals/3301) within a connection.

- ## Using SQL you can communicate – then, why you need Global Variables

**To share information between SQL statements** within the same application context, the application that issued the SQL statements has to do this work by copying the values from the output arguments, such as [host variables](https://srinimf.com/2018/05/10/4-top-db2-host-variable-points/), of one statement to the input host variables of another.

Similarly, when…

*Applications issue host-language calls to another application, [host variable](https://srinimf.com/2011/12/11/db2hostvariable/)s need to be passed among applications as input or output parameters for the applications to share common variable. Furthermore, SQL statements that are defined and contained within the DBMS, such as the SQL statements in the trigger bodies, cannot access this shared information.*

Related[How to Write SQL to Create Global Variables](https://srinimf.com/2015/05/22/1-more-addition-of-global-variables-in-db2-v11/)

- ## Global Variables Introduced in DB2 version 11

**To overcome this restriction and to maximize the flexibility of a DBMS, global variables are introduced in DB2 11 for z/OS.**

Related[Hierarchical Database Vs. Relational](https://srinimf.com/2014/07/13/hierarchical-vs-rdbms/)

**Creation of Sample Global variables:**

```
CREATE VARIABLE BATCH_START_TS TIMESTAMP
DEFAULT CURRENT TIMESTAMP;
```

**Catalog Tables**

- The new SYSIBM.SYSVARIABLES table includes one row for each global variable that is created.
- The new SYSIBM.SYSVARIABLEAUTH table includes one row for each privilege [of each](https://srinimf.com/2014/08/12/oracle-plsql-step-by-step-guide/) authorization ID that has privileges on a global variable.
- The SYSIBM.SYSVARIABLES_TEXT table is an auxiliary table for the DEFAULTTEXT column of the SYSIBM.SYSVARIABLES table.

*Ref IBM Db2 v11*

**Read more..**

- [Free SQL test](https://www.brainbench.com/testcenter/taketest/SQL-%28ANSI%29-2011-Fundamentals/3301)

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2015%2F10%2F07%2Fdb2-global-variables-in-version-11%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2015%2F10%2Fpexels-photo-5668851.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=DB2%20SQL%20Global%20variables%20top%20usage)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2015/10/07/db2-global-variables-in-version-11/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2015/10/07/db2-global-variables-in-version-11/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2015/10/07/db2-global-variables-in-version-11/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2015/10/07/db2-global-variables-in-version-11/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20DB2%20SQL%20Global%20variables%20top%20usage&body=https%3A%2F%2Fsrinimf.com%2F2015%2F10%2F07%2Fdb2-global-variables-in-version-11%2F&share=email)
-

### Like this:

Like Loading…
