2002-11-24 15:47:19 +02:00
drop table if exists t1;
create table t1 (a int check (a>0));
2016-06-29 09:14:22 +02:00
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
2016-11-27 19:50:10 +01:00
`a` int(11) DEFAULT NULL CHECK (`a` > 0)
2016-06-29 09:14:22 +02:00
) ENGINE=MyISAM DEFAULT CHARSET=latin1
2002-11-24 15:47:19 +02:00
insert into t1 values (1);
insert into t1 values (0);
2016-06-26 15:46:36 +02:00
ERROR 23000: CONSTRAINT `a` failed for `test`.`t1`
2002-11-24 15:47:19 +02:00
drop table t1;
2010-01-22 19:00:19 -07:00
create table t1 (a int, b int, check (a>b));
2016-06-29 09:14:22 +02:00
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
2016-11-27 19:50:10 +01:00
CONSTRAINT `CONSTRAINT_1` CHECK (`a` > `b`)
2016-06-29 09:14:22 +02:00
) ENGINE=MyISAM DEFAULT CHARSET=latin1
2002-11-24 15:47:19 +02:00
insert into t1 values (1,0);
insert into t1 values (0,1);
2016-06-26 15:46:36 +02:00
ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1`
2002-11-24 15:47:19 +02:00
drop table t1;
create table t1 (a int ,b int, constraint abc check (a>b));
2016-06-29 09:14:22 +02:00
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
2016-11-27 19:50:10 +01:00
CONSTRAINT `abc` CHECK (`a` > `b`)
2016-06-29 09:14:22 +02:00
) ENGINE=MyISAM DEFAULT CHARSET=latin1
2002-11-24 15:47:19 +02:00
insert into t1 values (1,0);
insert into t1 values (0,1);
2016-06-26 15:46:36 +02:00
ERROR 23000: CONSTRAINT `abc` failed for `test`.`t1`
2002-11-24 15:47:19 +02:00
drop table t1;
create table t1 (a int null);
2016-06-29 09:14:22 +02:00
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
2002-11-24 15:47:19 +02:00
insert into t1 values (1),(NULL);
drop table t1;
2003-12-02 19:06:24 +04:00
create table t1 (a int null);
alter table t1 add constraint constraint_1 unique (a);
alter table t1 add constraint unique key_1(a);
2013-09-20 22:30:19 +03:00
Warnings:
2016-12-29 13:23:18 +01:00
Note 1831 Duplicate index `key_1`. This is deprecated and will be disallowed in a future release
2003-12-02 19:06:24 +04:00
alter table t1 add constraint constraint_2 unique key_2(a);
2013-09-20 22:30:19 +03:00
Warnings:
2016-12-29 13:23:18 +01:00
Note 1831 Duplicate index `key_2`. This is deprecated and will be disallowed in a future release
2003-12-02 19:06:24 +04:00
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
2006-02-22 10:09:59 +01:00
`a` int(11) DEFAULT NULL,
2003-12-02 19:06:24 +04:00
UNIQUE KEY `constraint_1` (`a`),
UNIQUE KEY `key_1` (`a`),
UNIQUE KEY `key_2` (`a`)
2003-12-10 04:31:42 +00:00
) ENGINE=MyISAM DEFAULT CHARSET=latin1
2003-12-02 19:06:24 +04:00
drop table t1;
2010-01-22 19:00:19 -07:00
drop table if exists t_illegal;
create table t_illegal (a int, b int, check a>b);
2011-12-12 23:58:40 +01:00
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a>b)' at line 1
2010-01-22 19:00:19 -07:00
create table t_illegal (a int, b int, constraint abc check a>b);
2011-12-12 23:58:40 +01:00
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'a>b)' at line 1
2010-01-22 19:00:19 -07:00
create table t_illegal (a int, b int, constraint abc);
2011-12-12 23:58:40 +01:00
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1
2010-01-22 19:00:19 -07:00
drop table if exists t_11714;
create table t_11714(a int, b int);
alter table t_11714 add constraint cons1;
2011-12-12 23:58:40 +01:00
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
2010-01-22 19:00:19 -07:00
drop table t_11714;
CREATE TABLE t_illegal (col_1 INT CHECK something (whatever));
2011-12-12 23:58:40 +01:00
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'something (whatever))' at line 1
2010-01-22 19:00:19 -07:00
CREATE TABLE t_illegal (col_1 INT CHECK something);
2011-12-12 23:58:40 +01:00
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'something)' at line 1