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

228
Views
¿Cómo eliminar CHECK en MySQL?

Quiero DROP cheque de mi mesa. Cuando uso esta consulta en MySQL, no obtengo ningún nombre de restricción de verificación.

 SHOW CREATE TABLE test CREATE TABLE `test (``ID` int(11) NOT NULL AUTO_INCREMENT, `price` int(11) DEFAULT NULL CHECK (`price` > 20), PRIMARY KEY (`ID`) )`
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

En MySQL 8.0.16, probé tu tabla:

 mysql> CREATE TABLE test (ID int(11) NOT NULL AUTO_INCREMENT, price int(11) DEFAULT NULL CHECK (price > 20), PRIMARY KEY (ID) ); mysql> SHOW CREATE TABLE test\G *************************** 1. row *************************** Table: test Create Table: CREATE TABLE `test` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `price` int(11) DEFAULT NULL, PRIMARY KEY (`ID`), CONSTRAINT `test_chk_1` CHECK ((`price` > 20)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Ahora vemos el nombre de la restricción CHECK que MySQL ha generado automáticamente.

 mysql> ALTER TABLE test DROP CHECK test_chk_1;

Esto está documentado en https://dev.mysql.com/doc/refman/8.0/en/alter-table.html

| DROP {CHECK | CONSTRAINT} symbol

Una vez que elimino la restricción CHECK, ya no aparece:

 mysql> SHOW CREATE TABLE test\G *************************** 1. row *************************** Table: test Create Table: CREATE TABLE `test` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `price` int(11) DEFAULT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

Si usa una versión de MySQL anterior a la 8.0.16, no necesita hacer nada de esto, porque las versiones anteriores de MySQL no admiten las restricciones CHECK. No hay nada que descartar, porque no guarda la restricción cuando crea la tabla.

over 4 years ago · Santiago Trujillo Report
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!