Kārlis Janisels
Kārlis Janisels

Reputation: 1295

Why phpmyadmin does not create values for enum type?

I am new to mysql so I am using phpmyadmin to create table in database. I have field Manufacturer of enum type with possible values "manufacturer1", "manufacturer2", ...

I chose ENUM type and clicked on "Edit ENUM/SET values" and a window pop up asking for desired values. I fallow the instructions, press "go" and 'Manufacturer1','Manufacturer2','Manufacturer3','Manufacturer4' is no written in Length/Values.

When I try to create table I get 1064 syntax error. When I click on "Preview SQL" I get this:

CREATE TABLE `test4_db`.`product` ( `product_id` INT(11) NOT NULL AUTO_INCREMENT , `image_url` VARCHAR(255) NOT NULL , `manufacturer` ENUM(0) NOT NULL DEFAULT 'Manufacturer1' , `health` ENUM(0) NOT NULL , `missing` INT(11) NOT NULL , `statuss` ENUM(0) NOT NULL DEFAULT 'available' , `owner_id` INT(11) NOT NULL , `holder_id` INT(11) NOT NULL , PRIMARY KEY (`puzzle_id`)) ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_bin;

Why does phpmyadmin writes ENUM(0) instead of ENUM('Manufacturer1','Manufacturer2','Manufacturer3','Manufacturer4')?

Upvotes: 3

Views: 4773

Answers (2)

Nuno
Nuno

Reputation: 3622

This is a bug with phpMyAdmin 4.6.4.

See this - https://github.com/phpmyadmin/phpmyadmin/issues/12480

This will be fixed in 4.6.5.

In the meanwhile, you can simply do "Preview SQL", copy the SQL generated, and replace ENUM(0) with the values you want.

Alternatively, use a previous version of phpMyAdmin.

Upvotes: 7

khalid
khalid

Reputation: 175

Use this but remember to edit enum of health and statuss column. I have just added for example.

CREATE TABLE `test4_db`.`puzzles` ( 
    `puzzle_id` INT(11) NOT NULL AUTO_INCREMENT ,
    `image_url` VARCHAR(255) NOT NULL ,
    `manufacturer` ENUM('Manufacturer1', 'Manufacturer2', 'Manufacturer3') NOT NULL DEFAULT 'Manufacturer1' ,
    `health` ENUM('y', 'n') NOT NULL ,
    `missing` INT(11) NOT NULL ,
    `statuss` ENUM('y', 'n') NOT NULL DEFAULT 'available' ,
    `owner_id` INT(11) NOT NULL ,
    `holder_id` INT(11) NOT NULL ,
PRIMARY KEY (`puzzle_id`))
ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_bin;

Its better to use query instead of UI as mentioned by @Abhrapratim Nag

Upvotes: 0

Related Questions