20.5 Firebird Database Schema Listing

SELECT r.RDB$RELATION_NAME   AS table_name,
       r.RDB$FIELD_NAME      AS field_name,
       r.RDB$DESCRIPTION     AS field_description,
       r.RDB$DEFAULT_VALUE   AS field_default_value,
       r.RDB$NULL_FLAG       AS field_not_null_constraint,
       f.RDB$FIELD_LENGTH    AS field_length,
       f.RDB$FIELD_PRECISION AS field_precision,
       f.RDB$FIELD_SCALE     AS field_scale,
       CASE f.RDB$FIELD_TYPE
          WHEN 261 THEN 'BLOB'
          WHEN 14  THEN 'CHAR'
          WHEN 40  THEN 'CSTRING'
          WHEN 11  THEN 'D_FLOAT'
          WHEN 27  THEN 'DOUBLE'
          WHEN 10  THEN 'FLOAT'
          WHEN 16  THEN 'INT64'
          WHEN 8   THEN 'INTEGER'
          WHEN 9   THEN 'QUAD'
          WHEN 7   THEN 'SMALLINT'
          WHEN 12  THEN 'DATE'
          WHEN 13  THEN 'TIME'
          WHEN 35  THEN 'TIMESTAMP'
          WHEN 37  THEN 'VARCHAR'
          ELSE 'UNKNOWN'
       END AS field_type,
       f.RDB$FIELD_SUB_TYPE        AS field_subtype,
       coll.RDB$COLLATION_NAME     AS field_collation,
       cset.RDB$CHARACTER_SET_NAME AS field_charset
   FROM RDB$RELATION_FIELDS r
   LEFT JOIN RDB$FIELDS f            ON r.RDB$FIELD_SOURCE = f.RDB$FIELD_NAME
   LEFT JOIN RDB$COLLATIONS coll     ON f.RDB$COLLATION_ID = coll.RDB$COLLATION_ID
   LEFT JOIN RDB$CHARACTER_SETS cset ON f.RDB$CHARACTER_SET_ID = cset.RDB$CHARACTER_SET_ID;

For particular tables add before the semicolon:

   WHERE r.rdb$relation_name = 'PATIENT' OR r.rdb$relation_name='DOCTOR'


Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0