DEV Community

mmllllzcn
mmllllzcn

Posted on

GBase Database: What Does `tabid > 99` Actually Filter Out?

If you have worked with GBase Database(GBase 8s), you have probably seen this SQL statement in database administration scripts:

SELECT tabname
FROM systables
WHERE tabid > 99;
Enter fullscreen mode Exit fullscreen mode

It looks like a simple filter, but why use 99? What exactly does it exclude?

The answer lies in how GBase Database organizes its system catalog. Understanding this boundary helps DBAs distinguish user-created tables from system objects and avoid incorrect table counts during database migration and reconciliation.

1. Why Is the Boundary 99?

The systables system catalog does not contain only business tables. It also registers system tables, system views, and other database objects.

The tabid column identifies these objects. In the traditional GBase 8s catalog convention, the first 99 identifiers are reserved for system objects, while user-created tables start at 100.

That is why:

SELECT tabname
FROM systables
WHERE tabid > 99;
Enter fullscreen mode Exit fullscreen mode

returns user-created tables rather than the entire system catalog.

To see the difference, compare these two queries:

SELECT COUNT(*)
FROM systables;

SELECT COUNT(*)
FROM systables
WHERE tabid > 99;
Enter fullscreen mode Exit fullscreen mode

The first counts all registered objects in systables. The second counts objects above the system-object boundary.

The difference represents the objects excluded by the filter.

2. Why Does This Matter for Database Migration?

The distinction becomes important when comparing database objects across environments.

For example, imagine reconciling table counts between a source database and a target GBase Database instance.

If you count every row in systables, the results may differ because different database versions or configurations can contain different system objects.

A more consistent comparison starts by defining what you actually want to count: user-created tables.

Using tabid > 99 establishes that boundary.

The same principle applies when checking database names:

SELECT name
FROM sysdatabases;
Enter fullscreen mode Exit fullscreen mode

sysdatabases can include system databases as well as business databases. Do not assume that every returned name represents an application database.

Always distinguish system objects from user-created objects when preparing migration reports.

3. Why Does a Newly Created Database Return Zero Tables?

Consider this example:

CREATE DATABASE gbase8s WITH LOG;

SELECT tabname
FROM systables
WHERE tabid > 99;
Enter fullscreen mode Exit fullscreen mode

If the query returns zero rows, that does not mean database creation failed.

It simply means no user-created tables exist yet.

Database creation and table creation are two separate operations.

To verify database creation, check the SQL execution result and query the database catalog:

SELECT name
FROM sysdatabases;
Enter fullscreen mode Exit fullscreen mode

The database can exist successfully even when its user table count is zero.

4. A Better Query for Daily Reconciliation

Instead of running separate queries and manually calculating the difference, group objects by category:

SELECT
    CASE
        WHEN tabid > 99 THEN 'user'
        ELSE 'system'
    END AS kind,
    COUNT(*) AS cnt
FROM systables
GROUP BY 1;
Enter fullscreen mode Exit fullscreen mode

This returns both categories in one result:

  • system: Objects within the reserved system-object range.
  • user: Objects above the system-object boundary.

It is easier to read, compare, and include in database acceptance records.

5. Do Not Forget the owner Column

There is another detail worth checking: owner.

Two tables can have the same tabname but belong to different owners.

For example, filtering or counting by table name alone may lead to duplicate-looking results or incorrect reconciliation.

For a more reliable inventory, include both owner and tabname:

SELECT
    owner,
    tabname,
    tabid
FROM systables
WHERE tabid > 99
ORDER BY owner, tabname;
Enter fullscreen mode Exit fullscreen mode

This gives you a clearer picture of user-created objects and their ownership.

When comparing source and target databases, the owner should be part of the comparison criteria rather than relying on table names alone.

6. The Takeaway: Understand the Boundary, Not Just the Number

In GBase Database(GBase 8s), tabid > 99 is a practical way to exclude system objects when querying the traditional systables catalog.

Remember three things:

  1. systables contains both system objects and user-created objects.
  2. tabid > 99 filters for objects above the traditional system-object boundary.
  3. owner and tabname should be considered together when reconciling database objects.

The goal is not to memorize the number 99. It is to understand what the filter represents.

For DBAs working with GBase Database, a small catalog query can prevent misleading table counts, unnecessary migration investigations, and avoidable acceptance delays.

The next time a table-count comparison does not match, check the filtering criteria before assuming that objects are missing.

Top comments (0)