Subject | Re: [firebird-support] Unable to drop tables and fields |
---|---|
Author | Helen Borrie |
Post date | 2011-05-07T22:34:45Z |
At 10:07 AM 8/05/2011, you wrote:
Try this query:
SELECT * FROM RDB$DEPENDENCIES
WHERE RDB$DEPENDED_ON_NAME IN (
'TABLE JET_TSK_CND',
'PAR_GUID',
'"TABLE JET_TSK_CND"',
'"PAR_GUID"')
Note that I included double-quoted versions of those names, for the reason that you seem to have used some tool to maintain metadata interactively (FlameRobin, my guess). Maybe you also have colleagues using various tools to maintain metadata interactively without a strong change control policy. That's a scenario where there is at least the risk that someone has used a tool setting and has created objects with double-quoted identifiers.
./heLen
>Out of a database (.fdb) of about 200 tables, I am unable to drop 3 of the tables. I have dropped all the fields, triggers, indexes, foreign keys, checked the dependancies tab (which says there are none) on the 3 offending tables and yet I keep getting this error:Don't forget that SQL permissions on objects are dependencies...
>
>Starting transaction...
>Preparing query: ALTER TABLE JET_TSK_CND DROP PAR_GUID
>Prepare time: 0.016s
>Plan not available.
>
>
>Executing...
>Done.
>168 fetches, 11 marks, 1 reads, 1 writes.
>0 inserts, 1 updates, 1 deletes, 33 index, 0 seq.
>Delta memory: 43684 bytes.
>RDB$RELATION_FIELDS: 1 deletes.
>RDB$RELATIONS: 1 updates.
>Commiting transaction...
>*** IBPP::SQLException ***
>Context: Transaction::Commit
>
>SQL Message : -607
>This operation is not defined for system tables.
>
>Engine Code : 335544351
>Engine Message :
>unsuccessful metadata update
>cannot delete
>COLUMN JET_TSK_CND.PAR_GUID
>there are 2 dependencies
>
>Total execution time: 0.016s
>I have run gix to check and fix errors, and I have done a backup and restore. Nothing I do will allow me to drop these fields/tables.No, you should never perform DML on system tables directly. Tools should not, either. You don't mention what tools you are using, though.
>
>Is there something I can do in the system tables to remove any identifiers that is telling Firebird that these fields/tables have depenancies when actually they don't.
>OR is there a system table I can go into to at least *look up* what is supposidly depending on these fields/tables ?This you can do and clearly need to.
Try this query:
SELECT * FROM RDB$DEPENDENCIES
WHERE RDB$DEPENDED_ON_NAME IN (
'TABLE JET_TSK_CND',
'PAR_GUID',
'"TABLE JET_TSK_CND"',
'"PAR_GUID"')
Note that I included double-quoted versions of those names, for the reason that you seem to have used some tool to maintain metadata interactively (FlameRobin, my guess). Maybe you also have colleagues using various tools to maintain metadata interactively without a strong change control policy. That's a scenario where there is at least the risk that someone has used a tool setting and has created objects with double-quoted identifiers.
>And then change it so I can drop them?No, you must not do that. You do need to find out what those dependencies are and deal with them in the proper way (using DDL statements). The system objects have all sorts of underlying, hidden objects and dependencies that are dealt with when you perform CREATE, ALTER and DROP actions. The table definitions won't tell you much about what these things are or do. In future Firebird versions, the system tables will be read-only but, for now, they are vulnerable to desperate people! ;-) Don't meddle with them unless you are willing to break your database and spend a lot of time and $$$ to make your database usable again.
./heLen