Subject | Re: [firebird-support] How to get DDL for a database table? |
---|---|
Author | Ann W. Harrison |
Post date | 2010-01-14T21:09:27Z |
rael_bauer wrote:
so, Firebird doesn't store it. Instead, it represents tables
definitions in normalized system tables. Start with RDB$RELATIONS
which describes the core of tables and views. The look at
RDB$RELATION_FIELDS, which describes the intersection of tables
and the domains that define the columns in the table. Add
RDB$FIELDS to find the specifics of the domain definitions.
RDB$TYPES translates the numeric data type values into SQL
type names.
You can tell if an entry in RDB$RELATIONS represents a view
or a base table by looking at the column RDB$VIEW_BLR. If
it exists, then the table is a view. Firebird also stores
the original text of the "select" part of the view definition
because it can not be recreated from the blr exactly. Tools
like isql that extract database definitions from system tables
use the source form, if available, to produce an exact replica
of the original definition. More information about views can
be found in RDB$VIEW_RELATIONS.
Constraints are stored in separate system tables - browse
around. All the information is in the RDB$ tables.
Good luck
Ann
> I've wondered for a long time how to do this.Err, are you looking for the "CREATE TABLE" statement? If
>
> Can someone enlighten me?
so, Firebird doesn't store it. Instead, it represents tables
definitions in normalized system tables. Start with RDB$RELATIONS
which describes the core of tables and views. The look at
RDB$RELATION_FIELDS, which describes the intersection of tables
and the domains that define the columns in the table. Add
RDB$FIELDS to find the specifics of the domain definitions.
RDB$TYPES translates the numeric data type values into SQL
type names.
You can tell if an entry in RDB$RELATIONS represents a view
or a base table by looking at the column RDB$VIEW_BLR. If
it exists, then the table is a view. Firebird also stores
the original text of the "select" part of the view definition
because it can not be recreated from the blr exactly. Tools
like isql that extract database definitions from system tables
use the source form, if available, to produce an exact replica
of the original definition. More information about views can
be found in RDB$VIEW_RELATIONS.
Constraints are stored in separate system tables - browse
around. All the information is in the RDB$ tables.
Good luck
Ann