Re: Finding dbspace from system catalog tables
Posted in 1998
James Richardson wrote:
>
> I am currently attempting to write a dbschema-alike program, which analyses the information contained in the sys* tables, which
> will compare differences between two different database schemas, and , later, will generate the SQL to convert one database to be
> the same as another.
>
> Things are going fairly well so far, however I have found no information about how to determine which dbspace a table is in from
> the system catalog.
>
> If anybody could tell me where the information is, that would be great.
>
> TIA
>
> James Richardson
>
> PS: The next step is determining how to reconstruct fragmentation information, so if you have any tips......
The quick answer is that the first three hex digits in the partnum
column from systables (or sysfragments) is the dbspace number
containing the table's tablespace tablespace entry.
The long answer is get utils2_ak from the IIUG Software Repository. It
contains the source to my dbschema clone (myschema.sql) which does
everything you need as far as parsing system information. Feel free to
copy its methods or code to your database cloning program or to start
with my code or whatever. The version currently in the library did not
support all kinds of constraints, stored procedures, or triggers. I
have uploaded a new version just this AM that is a complete replacement
for dbschema but it will not be available from the web site for a week
or so.
Art S. Kagel