Creating ENUM variable type in MySQL

Viewed 115686

I am using an ENUM data type in MySQL and would like to reuse it, but not retype in the values. Is there an equivalent to the C, C++ way of defining types in MySQL?

I would like to do the following:

DEFINE ETYPE ENUM('a','b','c','d');
CREATE TABLE Table_1 (item1 ETYPE, item2 ETYPE);

Is this possible?

Thanks

2 Answers

Example given below for mysql db.

CREATE TABLE `data` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
  `gender` enum('Male','Female') DEFAULT NULL,
PRIMARY KEY (`Id`)
  ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci
Related