Subject Re: [ib-support] Unwanted Domains
Author Lucas Franzen
Todd Brasseur schrieb:
>
> Is there a quick way of getting rid of all domains in a database that
> aren't used by anything?

Todd,

To get a list of all unused domains you could do:

SELECT F.RDB$FIELD_NAME FROM RDB$FIELDS F
WHERE
F.RDB$SYSTEM_FLAG = '0'
AND F.RDB$FIELD_NAME NOT STARTING WITH 'RDB$'
AND NOT EXISTS (
SELECT RDB$FIELD_SOURCE FROM RDB$RELATION_FIELDS R
WHERE R.RDB$FIELD_SOURCE = F.RDB$FIELD_NAME )



I tested on a database:
DELETE FROM RDB$FIELDS F
WHERE
F.RDB$SYSTEM_FLAG = '0'
AND F.RDB$FIELD_NAME NOT STARTING WITH 'RDB$'
AND NOT EXISTS (
SELECT RDB$FIELD_SOURCE FROM RDB$RELATION_FIELDS R
WHERE R.RDB$FIELD_SOURCE = F.RDB$FIELD_NAME )

and all the unused domains were gone afterwards.

But I don't guarantee for any side-effects.


Regards
Luic.-