Monday, February 24, 2025

Db2 catalog: Updated documentation links to database metadata

New Db2 metadata created
In 2017 I wrote the post "Db2 Catalog - A guided tour", a title which I also use for some of my talks at user group meetings and conferences. It contains some now outdated links to the Db2 documentation. Time for an update, so that I can find that important information quicker again. And maybe you too...

Db2 catalog documentation

Metadata, that is data about how the actual data is stored, including the table and view definitions, is stored in the Db2 catalog, sometimes called the data dictionary. Db2 has internal tables and objects to hold the metadata, exposed in so-called catalog views. They are documented:

  • Catalog views and Road map to catalog views provide an overview how the metadata is organized, including which object names are used across all views, and where to find the information. Interestingly, external tables are part of the regular catalog, but datalake tables are not. They have special DATALAKE table catalog views with data managed by the Db2 Big SQL Hive metastore.
  • Many object types and their names have restrictions. They are documented in SQL and XML limits.
  • When creating objects in a database and working with data, it is good to know about Reserved schema names and reserved words.
  • As mentioned, the catalog can also be called data dictionary which is the case in the Oracle world. Because Db2 has an Oracle compatibility mode, there are also Oracle data dictionary-compatible views. They are based on the same Db2 catalog tables and views.
  • When working with data, it is always good to keep security in mind. Catalog data (metadata) is a way for attackers to obtain information about the stored data, possibly to even retrieve some data. The topic Gaining access to data through indirect means is highly recommended for an introduction and overview.
  • Tools like db2cat (catalog analysis), db2look (extraction of statistics and DDL), and db2dart (database analysis) allow access to database metadata and even data.

The above links help to get you started with the Db2 catalog or to quickly find the needed information again. But there is far more to learn. 

Did you know that the new Db2 feature of multi-tenant support requires some "tricks" to the catalog? The SET TENANT statement is the same as SET CATALOG, basically to activate a user or tenant-specific catalog. Something for a future blog post...

If you have feedback, suggestions, or questions about this post, please reach out to me on Mastodon (@data_henrik@mastodon.social) or LinkedIn.