hi i am trying to use CHECK
constraint form MySQL
, i got an example from w3 schools.
MySQL:
CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
CHECK (P_Id>0)
)
http://www.w3schools.com/sql/sql_check.asp
but it is not working as expected , the validation is ignored , after searching some time i found that The CHECK clause is parsed but ignored by all storage engines.
refrence :- CHECK constraint in MySQL is not working
then i searched for an answer , then i got this
it says that you can use a trigger when insert an update the record , alternatively to the check constraint .
i have 2 questions .
1.what is the best alternative for CHECK
constraint in MySQL
?
2.what is the purpose of only parsing CHECK
constraint with out using it . why is that exist if it is no use ??