Why phpmyadmin does not create values for enum type?

大城市里の小女人 提交于 2021-02-07 21:01:53

问题


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')?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/39874215/why-phpmyadmin-does-not-create-values-for-enum-type

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!