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?
Firebird is a relational database offering many ANSI SQL standard features that runs on Linux, Windows, and a variety of Unix platforms. Firebird offers excellent concurrency, high performance, and powerful language support for stored procedures and triggers.
Firebird is an open-source SQL relational database management system that support Linux, Microsoft Windows, macOS and other Unix platforms.
The first example creates a primary key constraint PK_CUST using an index named IX_CUSTNO: create table customers ( custno int not null constraint pk_cust primary key using index ix_custno, ... This, however: create table customers ( custno int not null primary key using index ix_custno, ...
Firebird is a free, open-source database management system, but “free” does not mean that everything is permitted. The use of Firebird is governed by two licenses: the IPL (InterBase Public License) and the IDPL (Initial Developer's Public License).
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With