Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all unused domains for a Firebird database

Tags:

firebird

Is there a quick way to list all Firebird domains defined for a database that are actually not used by any field ? I have a large database with many tables and many domains and it seems that a lot of them are not anymore used, so I guess it's time for a cleanup !

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

like image 342
Adrien Reboisson Avatar asked Feb 16 '16 12:02

Adrien Reboisson


1 Answers

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
like image 134
Andrej Kirejeŭ Avatar answered Jan 03 '23 22:01

Andrej Kirejeŭ