I am writing my own Firebird database browser using the ibpp library. Is there a way I can get the table definition using an SQL statement?
Advertisement
Answer
Firebird does not support schemas, so there is no way you can get that information.
The closest thing might be the owner, which you can get by querying RDB$RELATIONS
Edit
A “schema” is a namespace inside a database. Apparently you are looking for the table definition, not the schema.
You can retrieve the colums of a table and their datatypes by querying RDB$FIELDS and RDB$RELATION_FIELDS:
select rf.rdb$relation_name as table_name, rf.rdb$field_name as column_name, case f.rdb$field_type when 14 then 'CHAR' when 37 then 'VARCHAR' when 8 then 'INTEGER' ... end as data_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$relation_name = 'FOOBAR'
The datatype is stored as an integer in the column RDB$FIELD. The full list of values in that column is documented in the Interbase Reference Guide: http://www.ibphoenix.com/files/60LangRef.zip (as are all other columns in that system table and all other system tables as well). You might need to go through all the update guides to check if there were any changes to the system tables since IB 6.0 (The Firebird manualy are a **reall* mess)