Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

308
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!