1

Sql keeps throwing me a syntax error and I can't seem to figure out whats wrong.

ALTER TABLE `productList` ALTER COLUMN `ASIN` VARCHAR(32);

The error is the normal sql syntax error

ERROR 1064 (42000): 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 'VARCHAR(32)' at line 1

3 Answers 3

3

Try this:

 ALTER TABLE `productList` MODIFY COLUMN `ASIN` VARCHAR(32);

The syntax to change the column name is

ALTER TABLE tablename MODIFY COLUMN new-column-definition

Sign up to request clarification or add additional context in comments.

2 Comments

This was correct. Thanks, it was driving me crazy. All the answers online said I could use ALTER COLUMN. I'll mark this correct in 10 minutes.
@RyanWeinstein:- Added the manual link also . You can refer that as well!
0

You need to use MODIFY COLUMN instead of ALTER COLUMN if you want to change the column definition.

https://dev.mysql.com/doc/refman/5.1/en/alter-table.html

Comments

0

It's modify, not alter column.

ALTER TABLE table_name MODIFY column_name column_definition [ FIRST | AFTER column_name ];

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.