Subject Re: [ib-support] Querying the column names in a table.
Author Svein Erling Tysvaer
To get the name of the fields of a table:

SELECT RDB$FIELD_NAME
FROM RDB$RELATION_FIELDS
WHERE RDB$RELATION_NAME = <table name>

To get the type is a bit more tricky. Here's how you get some information
about the type as small integers:

SELECT F.RDB$FIELD_TYPE, F.RDB$FIELD_SUB_TYPE, F.RDB$FIELD_LENGTH,
F.RDB$FIELD_SCALE
FROM RDB$FIELDS F
JOIN RDB$RELATION_FIELDS RF ON RF.RDB$FIELD_SOURCE=F.RDB$FIELD_NAME
WHERE RF.RDB$FIELD_NAME = <field name>

(FIELD_SUB_TYPE is at least used for BLOBs, FIELD_LENGTH is most relevant
for text and field_scale is useful if e.g. you care to distinguish between
500 and 0.5)

If you want a name rather than a number, try

SELECT RDB$TYPE_NAME
FROM RDB$TYPES
WHERE RDB$TYPE = <FIELD_TYPE>
AND RDB$FIELDNAME = 'RDB$FIELD_TYPE' //or 'RDB$FIELD_SUB_TYPE'

I may well be wrong in some of what I write here, I'm no expert in this area.

HTH,
Set

At 14:33 20.11.2002 +0000, you wrote:
>If I know the name of a table, how would I ask Firebird the names and
>types of the columns in the table?