开发者

MySql constraints don't work on mysql Ubuntu

I've installed mysql in my ubuntu using the classic command:

     apt-get install mysql-server

And to my surprise it is a mysql which doesnt respect any constraint i write with "check". Could you tell me is it a bug or I don't know how to use constraints in mysql? (i mostly wrote commands in sql simple)

For example these commands:

CREATE TABLE Employee (
Name    VARCHAR(50) PRIMARY KEY NOT NULL, 
Phone VARCHAR(15) DEFAULT 'Unknown Phone',
Age     INT CHECK (Age BETWEEN 20 and 30));

INSERT INTO Employee (Name, PhoneNo, Age) VALUES ('Joe Wang', '666 2323', 26);
INSERT INTO Employee (Name, Age) VALUES ('John Doe', 31);

And now the table looks like this:

| Name     | PhoneNo       | Age  |
| Joe Wang | 666 2323      |   26 |
| John Doe | Unknown Phone |   31 |

2 ro开发者_开发问答ws in set (0.01 sec)

How can it be possible?


Sorry to say this, but....

The CHECK clause is parsed but ignored by all storage engines.

http://dev.mysql.com/doc/refman/5.5/en/create-table.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜