Subject Re: [firebird-support] Table ID limit
Author Ann W. Harrison
Leyne, Sean wrote:
>
>> How do I tell when I have run out of new table IDs? And if I have,
>> will a backup and restore fix the problem?
>
> - you can execute the following SQL to find out the last ID value:
> SELECT MAX( rdb$relation_id) FROM rdb$relations
> - if you have reached the limit,
> a backup/restore will not solve the problem.

In fact, a backup and restore will solve the problem if you have
dropped tables. At one point we considered scavenging old table
ids ... it might have happened ... but it got more complicated
the more we looked at it. RDB$RELATION_ID is a short, probably
a signed short, and so you'll get int trouble if the value is
more than 32767.

If you get there by creating and dropping tables on a regular
basis, then backup and restore will fix it. If you've actually
got 32139 tables (the first 128 are reserved for system tables)
then you've got a really complex database.

> I don't know where the next Table ID value is stored (I thought a system
> defined Generator, but can't find it).

I think it's stored in RDB$DATABASE.

>> A backup/restore will not reset
> the ID, and trying to manually set the ID will get you into other
> problems.

Lots of other problems. The RDB$RELATION_ID value is stored in
the indexes, on pointer pages, on data pages, and generally will
turn to ... an unpleasant mess ... if you try to change it.

Good luck,

Ann