ALTER TABLE sample62 CHANGE newcol c;

This code makes me mad. I just followed the book I had.

Program said

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1.

My MySQL version is 5.7. Can you please help me?

4 Answers 4


mysql error 1064

The error that gets thrown if the syntax is wrong. You did not clearly state what you are doing.

If you are changing a column

ALTER TABLE table_name MODIFY COLUMN column_name datatype

If you are trying to change column definition

ALTER TABLE table_name CHANGE old_column_name new_column_name data_type(size)

If you are adding a new column

ALTER TABLE table_name ADD column_name datatype
  • 1
    What is "change column definition" as opposed to "changing a column"?
    – Andriy M
    Feb 10, 2016 at 12:25
  • "change column definition" - this includes renaming the column and more stuffs.
    – Vhortex
    Feb 11, 2016 at 3:24

I believe MySQL requires the ALTER TABLE ... CHANGE ... statement to restate the column definition (datatype, default value, column constraints &c.) even if it's only the column name being changed.


You can write your query like this:

ALTER TABLE database_name.sample62 CHANGE old_column_name new_column_name INT(11) DEFAULT 0 NULL;

Use this syntax:

Alter table tablename CHANGE [COLUMN] old_col_name new_col_name column_definition

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.