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;
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;
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;
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;
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;
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;
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;
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;
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:
-
systablescontains both system objects and user-created objects. -
tabid > 99filters for objects above the traditional system-object boundary. -
ownerandtabnameshould 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)