Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

309
Visualizações
MySQL disable table check constraints

Is there a way to disable custom table checks in MySQL?

Table checks were previously silently ignored by MySQL, since version 8.0.16 they are implemented and enforced, but it seems that there is no way to turn them globaly.

MySQL has only FOREIGN_KEY_CHECKS and UNIQUE_CHECKS variables, which are specific, there is nothing for check constraints.

My principal issue is that I need to add a check on big table. If this happens with a foreign key check, one can use the FOREIGN_KEY_CHECK variable together with ALTER_TABLE and INPLACE algorihtm:

SET FOREIGN_KEY_CHECKS = 0;
ALTER TABLE my_table
ADD CONSTRAINT my_table_constraint FOREIGN KEY (...) REFERENCES other_table, ALGORITHM=INPLACE
SET FOREIGN_KEY_CHECKS = 1;

Now because it seems that there is nothing to turn off checks globaly, there is no way to use the INPLACE algorithm with check constraint, the following will fail:

ALTER TABLE my_big_table
ADD CONSTRAINT only_some_numbers
CHECK (column_one >= 100 AND column_one <= 300), ALGORITHM=INPLACE;

It seems that MariaDB has a variable to allow this: https://mariadb.com/kb/en/server-system-variables/#check_constraint_checks

I did not find anything in MySQL documentation. Is there a different way to achieve such inplace addition of new check constraint?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda