Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

311
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda