Subject | RE: [ib-support] Extracting Table Creation declarations |
---|---|
Author | Martijn Tonies |
Post date | 2002-04-03T12:11:02Z |
Hi,
well, if you don't care using 3rd party (non-free) tools, you might want
to take a look at InterBase Workbench - as other tools, it has a
'statement
recorder' with which you can record your DDL changes.
As for a meta data extract, the IB/FB metadata tables are quite a
mess...
Sometimes IB itself doesn't know what to show (especially for IB 5.x,
IB6
is a bit better).
Then, there's the issue with, for example, triggers - they can be found
in the RDB$TRIGGERS table. But some triggers are system defined to take
care of foreign key references, check constraints and more... Claudio
changed a couple of things for FB1 so that it's easier to recognize
system
defined triggers, but this will only work if you're creating your DB
from
scratch with FB1...
Take a look at the Language Reference, chapter SYSTEM TABLES AND VIEWS.
And learn to look through the documentation errors...
RDB$RELATIONS == lists tables and views
RDB$RELATION_FIELDS== lists the columns for a table or view and the
(domain) source
RDB$FIELDS == lists the domains, either user defined or system
defined
RDB$GENERATORS == lists all generators
RDB$TRIGGERS == lists triggers
RDB$INDICES == lists indices
RDB$INDEX_SEGMENTS == lists indexed columns
RDB$RELATION_CONSTRAINTS == lists basic constraint info, together with
several other tables (RDB$CHECK_CONSTRAINTS for example) it lists the
full constraint info. For PKs, use RDB$INDEX_SEGMENTS to get what fields
are constrained. For FKs, use RDB$REF_CONSTRAINTS to know to what
constraint the FK is pointing, then, use the RDB$INDEX_SEGMENTS and
RDB$CONSTRAINTS table to get what fields are in use by that constraint.
And there are several more...
Good luck :)
Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird
http://www.interbaseworkbench.com
In fact , what i'm trying to do is life easier.
Seriusly , to mantain consistency between the central (development)
database
and the installed (production) ones , so if I alter tables in the
development database , I could do a comparation between ddl's of both
databases online and make some sort of operation that mantains
consistency
betewen the client software and the database. Is far more complicated
that
this , of course , but you could see the general idea. A sort of "poor
man
database replication"
And i really appreciate to know what's going on , so a component that
comes
without the source code to poke arround , since it could be really
usefull
(i'm taking a deep interest in IBO , but I'm open to suggestions , of
course) , is not what i really like.
Thanks for your interest.
Javi
EntreBytes S.L.
Ontenient , Spain
ERP Development.
To: <ib-support@yahoogroups.com>
Sent: Wednesday, April 03, 2002 1:43 PM
Subject: RE: [ib-support] Extracting Table Creation declarations
well, if you don't care using 3rd party (non-free) tools, you might want
to take a look at InterBase Workbench - as other tools, it has a
'statement
recorder' with which you can record your DDL changes.
As for a meta data extract, the IB/FB metadata tables are quite a
mess...
Sometimes IB itself doesn't know what to show (especially for IB 5.x,
IB6
is a bit better).
Then, there's the issue with, for example, triggers - they can be found
in the RDB$TRIGGERS table. But some triggers are system defined to take
care of foreign key references, check constraints and more... Claudio
changed a couple of things for FB1 so that it's easier to recognize
system
defined triggers, but this will only work if you're creating your DB
from
scratch with FB1...
Take a look at the Language Reference, chapter SYSTEM TABLES AND VIEWS.
And learn to look through the documentation errors...
RDB$RELATIONS == lists tables and views
RDB$RELATION_FIELDS== lists the columns for a table or view and the
(domain) source
RDB$FIELDS == lists the domains, either user defined or system
defined
RDB$GENERATORS == lists all generators
RDB$TRIGGERS == lists triggers
RDB$INDICES == lists indices
RDB$INDEX_SEGMENTS == lists indexed columns
RDB$RELATION_CONSTRAINTS == lists basic constraint info, together with
several other tables (RDB$CHECK_CONSTRAINTS for example) it lists the
full constraint info. For PKs, use RDB$INDEX_SEGMENTS to get what fields
are constrained. For FKs, use RDB$REF_CONSTRAINTS to know to what
constraint the FK is pointing, then, use the RDB$INDEX_SEGMENTS and
RDB$CONSTRAINTS table to get what fields are in use by that constraint.
And there are several more...
Good luck :)
Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird
http://www.interbaseworkbench.com
In fact , what i'm trying to do is life easier.
Seriusly , to mantain consistency between the central (development)
database
and the installed (production) ones , so if I alter tables in the
development database , I could do a comparation between ddl's of both
databases online and make some sort of operation that mantains
consistency
betewen the client software and the database. Is far more complicated
that
this , of course , but you could see the general idea. A sort of "poor
man
database replication"
And i really appreciate to know what's going on , so a component that
comes
without the source code to poke arround , since it could be really
usefull
(i'm taking a deep interest in IBO , but I'm open to suggestions , of
course) , is not what i really like.
Thanks for your interest.
Javi
EntreBytes S.L.
Ontenient , Spain
ERP Development.
To: <ib-support@yahoogroups.com>
Sent: Wednesday, April 03, 2002 1:43 PM
Subject: RE: [ib-support] Extracting Table Creation declarations
> Hi,in
>
> Almost all system tables :)
>
> It's not as easy at it looks... You might want to use one of the
> ready-made solutions. Both IBExpress and IBObjects have a meta data
> extract component, I guess FIBPlus has one too.
>
> What are you trying to do, perhaps there's another way?
>
> Martijn Tonies
> InterBase Workbench - the developer tool for InterBase and Firebird
> http://www.interbaseworkbench.com
>
>
>
> Could someone tell me what system table i should query to ascern
> the code for creation of the user tables ? Sort of a extract database
> isql , but by delphi code / sql query.
>
>
> Javi
> EntreBytes S.L.
> Ontenient , Spain
> ERP Development.