html tool

2014年7月2日星期三

mysql的check约束不起作用

在mysql中测试如下
My SQL:
CREATE TABLE Persons
(
Id_P int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
CHECK (Id_P>0)
)
但添加id_P为0时可以成功的,why?
[go]了一下http://stackoverflow.com/questions/14247655/mysql-check-constraint 中解释mysql应该是不支持,其中如下:
CHECK constraints are ignored by MySQL as explained in a miniscule comment in the docs: CREATE TABLE
The CHECK clause is parsed but ignored by all storage engines.
这里引用http://dev.mysql.com/doc/refman/5.5/en/create-table.html 中的






For other storage engines, MySQL Server parses and ignores the FOREIGN KEY and REFERENCES syntax inCREATE TABLE statements. The CHECK clause is parsed but ignored by all storage engines

没有评论:

发表评论