MariaDB [test]> CREATE TABLE t0 (c1 INT CHECK ( c1 > 0 ));
|
Query OK, 0 rows affected (0,054 sec)
|
|
MariaDB [test]> show create table t0;
|
+-------+-----------------------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+-----------------------------------------------------------------------------------------------------------------------------------+
|
| t0 | CREATE TABLE `t0` (
|
`c1` int(11) DEFAULT NULL CHECK (`c1` > 0)
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs |
|
+-------+-----------------------------------------------------------------------------------------------------------------------------------+
|
1 row in set (0,001 sec)
|
|
MariaDB [test]> ALTER TABLE t0 MODIFY COLUMN c1 INT ;
|
Query OK, 0 rows affected (0,037 sec)
|
Records: 0 Duplicates: 0 Warnings: 0
|
|
MariaDB [test]> show create table t0;
|
+-------+------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+------------------------------------------------------------------------------------------------------------------+
|
| t0 | CREATE TABLE `t0` (
|
`c1` int(11) DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs |
|
+-------+------------------------------------------------------------------------------------------------------------------+
|
1 row in set (0,003 sec)
|
|
MariaDB [test]> CREATE or replace TABLE t0 (c1 INT, CHECK ( c1 > 0 ));
|
Query OK, 0 rows affected (0,059 sec)
|
|
MariaDB [test]> show create table t0;
|
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
| t0 | CREATE TABLE `t0` (
|
`c1` int(11) DEFAULT NULL,
|
CONSTRAINT `CONSTRAINT_1` CHECK (`c1` > 0)
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs |
|
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
1 row in set (0,001 sec)
|
|
MariaDB [test]> ALTER TABLE t0 DROP CONSTRAINT CONSTRAINT_1;
|
Query OK, 0 rows affected (0,031 sec)
|
Records: 0 Duplicates: 0 Warnings: 0
|
|
MariaDB [test]> show create table t0;
|
+-------+------------------------------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+------------------------------------------------------------------------------------------------------------------+
|
| t0 | CREATE TABLE `t0` (
|
`c1` int(11) DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs |
|
+-------+------------------------------------------------------------------------------------------------------------------+
|
1 row in set (0,001 sec)
|
Thanks for the report, it should be fixed.
Currently it works like this - there are 2 ways to define a constraint:
CHECK(expression) given as part of a column definition – to drop it one should use ALTER TABLE ..MODIFY COLUMN.
CONSTRAINT constraint_name CHECK (expression) – here ALTER TABLE .. DROP CONSTRAINT ;
MariaDB [test]> CREATE TABLE t0 (c1 INT CHECK ( c1 > 0 ));
Query OK, 0 rows affected (0,054 sec)
MariaDB [test]> show create table t0;
+-------+-----------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+-----------------------------------------------------------------------------------------------------------------------------------+
| t0 | CREATE TABLE `t0` (
`c1` int(11) DEFAULT NULL CHECK (`c1` > 0)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs |
+-------+-----------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0,001 sec)
MariaDB [test]> ALTER TABLE t0 MODIFY COLUMN c1 INT ;
Query OK, 0 rows affected (0,037 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [test]> show create table t0;
+-------+------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+------------------------------------------------------------------------------------------------------------------+
| t0 | CREATE TABLE `t0` (
`c1` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs |
+-------+------------------------------------------------------------------------------------------------------------------+
1 row in set (0,003 sec)
MariaDB [test]> CREATE or replace TABLE t0 (c1 INT, CHECK ( c1 > 0 ));
Query OK, 0 rows affected (0,059 sec)
MariaDB [test]> show create table t0;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t0 | CREATE TABLE `t0` (
`c1` int(11) DEFAULT NULL,
CONSTRAINT `CONSTRAINT_1` CHECK (`c1` > 0)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0,001 sec)
MariaDB [test]> ALTER TABLE t0 DROP CONSTRAINT CONSTRAINT_1;
Query OK, 0 rows affected (0,031 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [test]> show create table t0;
+-------+------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+------------------------------------------------------------------------------------------------------------------+
| t0 | CREATE TABLE `t0` (
`c1` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs |
+-------+------------------------------------------------------------------------------------------------------------------+
1 row in set (0,001 sec)