In this August Embarcadero announces the new version of the well-known Interbase report database: Interbase 2019. Interbase is widely used by Delphi developers since in the multi-platform environment (iOS, Android, Windows, Mac OSX, Linux) I believe it is the only relational database that can be distributed even on iOS / Android platforms, the inter-base versions…
Read more
Synaptica has always adopted Firebird as its main database environment for the realization of many solutions from embedded iot products to Web solutions with thousands of daily accesses. Firebird proved to be a great tool, flexible and easy to manage. For this reason we could not miss the appointment to meet the creators (Dmitry…
Read more
1 2 3 4 |
select PK_ID from USERS start with FK_USER_PARENT = PK_USER connect by prior PK_ID = FK_USER_PARENT; |
To enable and disable all triggers of a database i do two procedure : Enabling all database trigger:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
create procedure SP_ENABLE_ALL_TRIGGER as begin /* Procedure Text */ update RDB$TRIGGERS set RDB$TRIGGER_INACTIVE=0 where RDB$TRIGGER_NAME in( select A.RDB$TRIGGER_NAME from RDB$TRIGGERS A left join RDB$CHECK_CONSTRAINTS B ON B.RDB$TRIGGER_NAME = A.RDB$TRIGGER_NAME where ((A.RDB$SYSTEM_FLAG = 0) or (A.RDB$SYSTEM_FLAG is null)) and (b.rdb$trigger_name is null) AND (NOT(A.RDB$TRIGGER_NAME LIKE 'RDB$%')) ); suspend; end |
Disabling all database trigger:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
create procedure SP_DISABLE_ALL_TRIGGER as begin update RDB$TRIGGERS set RDB$TRIGGER_INACTIVE=1 where RDB$TRIGGER_NAME in( select A.RDB$TRIGGER_NAME from RDB$TRIGGERS A left join RDB$CHECK_CONSTRAINTS B ON B.RDB$TRIGGER_NAME = A.RDB$TRIGGER_NAME where ((A.RDB$SYSTEM_FLAG = 0) or (A.RDB$SYSTEM_FLAG is null)) and (b.rdb$trigger_name is null) AND (NOT(A.RDB$TRIGGER_NAME LIKE 'RDB$%')) ); suspend; end |
With that simple peace of code you can retrive the full list of all “FK” Foreign Key of an Interbase or Firebird DB.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
SELECT rc.RDB$CONSTRAINT_NAME AS constraint_name, i.RDB$RELATION_NAME AS table_name, s.RDB$FIELD_NAME AS field_name, i.RDB$DESCRIPTION AS description, rc.RDB$DEFERRABLE AS is_deferrable, rc.RDB$INITIALLY_DEFERRED AS is_deferred, refc.RDB$UPDATE_RULE AS on_update, refc.RDB$DELETE_RULE AS on_delete, refc.RDB$MATCH_OPTION AS match_type, i2.RDB$RELATION_NAME AS references_table, s2.RDB$FIELD_NAME AS references_field, (s.RDB$FIELD_POSITION + 1) AS field_position FROM RDB$INDEX_SEGMENTS s LEFT JOIN RDB$INDICES i ON i.RDB$INDEX_NAME = s.RDB$INDEX_NAME LEFT JOIN RDB$RELATION_CONSTRAINTS rc ON rc.RDB$INDEX_NAME = s.RDB$INDEX_NAME LEFT JOIN RDB$REF_CONSTRAINTS refc ON rc.RDB$CONSTRAINT_NAME = refc.RDB$CONSTRAINT_NAME LEFT JOIN RDB$RELATION_CONSTRAINTS rc2 ON rc2.RDB$CONSTRAINT_NAME = refc.RDB$CONST_NAME_UQ LEFT JOIN RDB$INDICES i2 ON i2.RDB$INDEX_NAME = rc2.RDB$INDEX_NAME LEFT JOIN RDB$INDEX_SEGMENTS s2 ON i2.RDB$INDEX_NAME = s2.RDB$INDEX_NAME WHERE rc.RDB$CONSTRAINT_TYPE = 'FOREIGN KEY' ORDER BY s.RDB$FIELD_POSITION |
Users/ivanrevelli/Downloads/Firebird.app/Contents/MacOS/firebird/ cd Users/ivanrevelli/Downloads/Firebird.app/Contents/MacOS/ Users/ivanrevelli/Downloads/Firebird.app/Contents/MacOS/firebird/libfbembed.dylib