skip to Main Content

Mysql – phpmyadmin

What’s wrong with this query?

ALTER TABLE `invoices` 
CHANGE `status` `status` ENUM('paid','due','canceled','partial','cheque') 
CHARACTER SET `utf8` COLLATE `utf8_general_ci` NOT NULL DEFAULT `due`;

I am getting this error:

Missing comma before start of a new alter operation. (near "CHARACTER SET") and not able to run this query on live server. Query was generated when I changed the table structure on my localhost during development.

I also tried below query mentioned in many threads but it also give same above error:

ALTER TABLE `invoices` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

2

Answers


  1. Am not sure why. I also faced the same issue.

    Though it appears like:

    When removed both CHARACTER and COLLATE part from SQL, parser works fine.

    i.e

    Before

    ALTER TABLE `place` CHANGE COLUMN `plc_location_type` `gplc_location_type` ENUM('LOCATION') CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL;
    

    After

    ALTER TABLE `place` CHANGE COLUMN `plc_location_type` `gplc_location_type` ENUM('LOCATION') NOT NULL;
    

    REFERENCE:
    https://github.com/phpmyadmin/sql-parser/issues/229

    Good luck!

    Login or Signup to reply.
  2. ALTER TABLE table_name 
    CHANGE old_column_name1 new_col_name1 Data Type,
    CHANGE old_column_name2 new_col_name2 Data Type,
    CHANGE old_column_name3 new_col_name3 Data Type;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search