Subject Re: [firebird-support] Re: Running a query to find table constraints
Author Alexandre Benson Smith
tractaylor wrote:

>I thought about disabling foreign keys, but I was trying to avoid
>that. I know you can get alot of information from the system tables,
>but I have yet to figure out a query that would give me what I want.
>List of tables is easy, but trying to find the table constraints is
>getting me.

Maybe this is what you are after:
I_C.rdb$Relation_Name as Child, I_P.rdb$Relation_Name as Parent
rdb$Ref_Constraints R join
rdb$Indices I_C on (I_C.rdb$Index_Name = R.rdb$Constraint_Name) join
rdb$Indices I_P on (I_P.rdb$Index_Name = rdb$Const_Name_UQ)
I_C.rdb$Relation_Name = 'YOUR_TABLE_NAME'

the above query will list all tables 'YOUR_TABLE_NAME' are dependent on.

>I know about the datapump, but what I am trying to do, is backing up
>specific records. Kinda like a archive, that I can un-archive at
>anytime. I can just look through our database and figure it out, but
>we have over 200 tables to look through. That is why I was looking
>for a programmatic solution.
>I am guessing that the datapump somehow knows what order to put in
>the records, or does it disable the foreign constraints?
I think the both ! :-) There is an option to disable the FK constraints

I don't know how to insert data even if you know the order of tables if
you have a self-referencing table, in this case, you will need to know
the order of the records to be inserted too, not impossible, but a bit
of work for sure.



Alexandre Benson Smith
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil

No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.12/77 - Release Date: 18/08/2005