check约束好像不起作用啊?!情况如下:mysql> create table t (c1 integer check (c1 < 50));
Query OK, 0 rows affected (0.03 sec)mysql> insert into t values(20);
Query OK, 1 row affected (0.00 sec)mysql> insert into t values(60);
Query OK, 1 row affected (0.00 sec)mysql> select * from t;
+------+
| c1 |
+------+
| 20 |
| 60 |
+------+
2 rows in set (0.00 sec)怎么回事?谢谢!
Query OK, 0 rows affected (0.03 sec)mysql> insert into t values(20);
Query OK, 1 row affected (0.00 sec)mysql> insert into t values(60);
Query OK, 1 row affected (0.00 sec)mysql> select * from t;
+------+
| c1 |
+------+
| 20 |
| 60 |
+------+
2 rows in set (0.00 sec)怎么回事?谢谢!
[/align]
For other storage engines, the clauses are parsed but ignored. The CHECK clause is parsed but ignored by all storage engines.
The reason for accepting but ignoring syntax clauses is for compatibility, to make it easier to port code from other SQL servers, and to run applications that create tables with references.[align=center]==== 思想重于技巧 ====
[/align]
MYSQL加了这个只是为了对移植到其他数据库提供方便。
难道不能添加了吗??????
[/align]
那我要建个 范围在100-200的int型数据 别人输入201就会报错
岂不是不可能?
2. 换数据库[align=center]==== 思想重于技巧 ====
[/align]