Search code examples
firebird

How do you get a list of tables name that contains a specific column name on Firebird?


I have to find a table (or more than one) that contains a column named 'idRec' on a Firebird database.


Solution

  • You can query the RDB$RELATION_FIELDS table for this:

    select RDB$RELATION_NAME
    from RDB$RELATION_FIELDS
    where RDB$FIELD_NAME = 'idRec'
    

    This will only match columns that are actually called idRec (and thus are required to be quoted when used in SQL statements). If you are actually looking for a column called IDREC (unquoted object names are stored in uppercase), use where RDB$FIELD_NAME = 'IDREC'