Question

So i have created this table in MySQL Workbench called iOwe. It has a column called Pass(Y/N) on which i'd like to have a check constrain incorporated, which takes only the values "Y" or "N". I understand that check constrains don't work on MySQL, and that is why there are triggers (please correct me if I am wrong). Could you please help me to create one, if that is the case, or tell me how to go about creating a check constrain, if possible. i Googled the same question, but nothing helped me so far.

Your help is greatly appreciated.

Thanks in advance :)

Was it helpful?

Solution

You can use an ENUM datatype for the Y/N column to only accept "Y" and "N". MySQL will not accept any other value for this column then. See the MySQL documentation for ENUM for details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top