List of all unused domains for the Firebird database

Is there a quick list of all Firebird domains defined for the database that are not actually used by any field? I have a large database with many tables and many domains, and it seems that many of them are no longer in use, so I think it's time to clean up!

I think this is possible by querying system tables RDB$..., but I'm not sure how to do this.

+4
source share
1 answer
SELECT
  f.rdb$field_name
FROM
  rdb$fields f
  LEFT JOIN rdb$relation_fields rf
    ON rf.rdb$field_source = f.rdb$field_name
WHERE
  rf.rdb$field_name IS NULL
  AND
  COALESCE(f.rdb$system_flag, 0) = 0
+4
source

Source: https://habr.com/ru/post/1628974/


All Articles