firebird icon indicating copy to clipboard operation
firebird copied to clipboard

Disable constraint [CORE1924]

Open firebird-automations opened this issue 17 years ago • 7 comments

Submitted by: @cincuranet

Votes: 14

Temporaly disabling constraints (FK, check, ...) using: ALTER TABLE <table> DISABLE <constraint> and ALTER TABLE <table> ENABLE <constraint>

This more or less similar to CORE1084, but with wider application.

firebird-automations avatar Jun 06 '08 13:06 firebird-automations

Commented by: Mark Stein (mark stein)

It would be great to have such a functionality!

I'm looking for a way do achieve that, but can't find anything.

This article: http://www.firebirdfaq.org/faq20/

says "[...]Alternatively, you can disable the constraints during the import and turn them back on later.[...]"

so it seems to be possible. I would like to know how.

Can anyone help me with this please?

If this is not possible yet, then please consider it for one of the next releases.

Thanks, Mark

firebird-automations avatar Mar 02 '10 16:03 firebird-automations

If standard-compliant ALTER TABLE ALTER CONSTRAINT [NOT] ENFORCED is implemented for PK/UK/FK, should equivalent ALTER TRIGGER INACTIVE to be allowed too? The same question for activation/deactivation of triggers for CHECK constraints.

aafemt avatar Apr 05 '24 16:04 aafemt

If standard-compliant ALTER TABLE ALTER CONSTRAINT [NOT] ENFORCED is implemented for PK/UK/FK, should equivalent ALTER INDEX INACTIVE to be allowed too? The same question for activation/deactivation of triggers for CHECK constraints.

I'd prefer it raising an error and suggesting to use ALTER CONSTRAINT instead, but it will break backward compatibility.

If it's allowed, I'd expect the change to be propagated to the constraint using the altered index/trigger, as the state should be stored at the constraint level too and both states should be in sync.

dyemanov avatar Apr 08 '24 11:04 dyemanov

Why to duplicate the state? As any other denormalization it is just a source of troubles.

aafemt avatar Apr 08 '24 11:04 aafemt

We're going to support FKs without indices, so the state should be stored at the constraint level.

dyemanov avatar Apr 08 '24 11:04 dyemanov

Not every kind of constraints requires index ever

hvlad avatar Apr 08 '24 11:04 hvlad

Ok, but let's wait until FKs without indices are implemented to see implementation details and if they don't have a place for "active" flag.

PS: Check constraints require triggers which also have own "inactive" flag. NULL constraints have corresponding flags in record format IIRC.

aafemt avatar Apr 08 '24 11:04 aafemt