0

I am creating table as follows:

CREATE TABLE `work` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `WORKDONE` varchar(50) DEFAULT NULL,
  `INSTALLATIONDATE` datetime NOT NULL,
  `LASTUPDATEDDATE` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `CREATEDBY` varchar(50) NOT NULL DEFAULT 'SYSTEM',
  `LASTUPDATEDBY` varchar(50) NOT NULL DEFAULT 'SYSTEM',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

I want add CHECK constraint on WORKDONE column above such that it takes either of the three values only ('YES','NO','MAYBE') and does not accept any other values.

Arshanvit
  • 417
  • 1
  • 7
  • 28
  • MySQL does not support `check` – juergen d Dec 05 '18 at 13:06
  • Believe it or not MySQL does not execute `CHECK` it only parses `CHECK` clauses in `CREATE TABLE` statements like @juergend says you need to simulate it with a [trigger](https://stackoverflow.com/questions/2115497/check-constraint-in-mysql-is-not-working) (also marked as duplicated) – Raymond Nijland Dec 05 '18 at 13:07

0 Answers0