MYSQL Column contains the same value

63 Views Asked by At

In mysql I have a column (LANG) that contains the same value (EN), the number of lines exceeds the 100,000 lines at the moment

The column can take the same value among these IT, FR, DE, ES, EN is there any solution to optimizes the table? thanks

1

There are 1 best solutions below

2
On

If you have a column that contain one of a known values (from a list) you should use an ENUM column type (and not a string/varchar one, for example):

CREATE TABLE `t1` (
    `ID` INT NOT NULL AUTO_INCREMENT ,
    `LANG` ENUM('EN','IT','FR','DE','ES','EN') NOT NULL ,
    PRIMARY KEY (`ID`)
) ENGINE = InnoDB;

The ENUM storage requirements are

1 or 2 bytes, depending on the number of enumeration values (65,535 values maximum)