How to disable a Constraint in ORACLE?

Asked

Viewed 5,423 times

0

I have a table where two specific fields together cannot have the same values.

I BELIEVE who are they:

  • NUM_PERIODO_LANCAMENTO
  • COD_INDICADOR

Assuming I have that data:

NUM_PERIODO_LANCAMENTO = 1 , COD_INDICADOR = 1 , COD_CR_PERIODO = 1

NUM_PERIODO_LANCAMENTO = 2 , COD_INDICADOR = 1 , COD_CR_PERIODO = 1

NUM_PERIODO_LANCAMENTO = 3 , COD_INDICADOR = 1 , COD_CR_PERIODO = 1

When I try to register this data

NUM_PERIODO_LANCAMENTO = 1 , COD_INDICADOR = 1 , COD_CR_PERIODO = 2

Constraint error is displayed.

I’d like to release this record, how to do that?

  • Do these columns come from a foreign key? Try to check how this Constraint is built, you may have to change it

1 answer

5


You can disable the Constraint check via a ALTER TABLE :

ALTER TABLE tabela
DISABLE CONSTRAINT nome_da_constraint;

But be aware that this can lead to duplicity issues in your table if you don’t fix the Constraint.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.