I can't figure out why I can't change a column's data type from TEXT to INT. Here is the script I'm using.
ALTER TABLE covidworlddata.coviddeaths
ALTER COLUMN total_deaths INT;
Error 1366: Incorrect integer value: '' for column 'total_deaths' at row 1 SQL Statement: ALTER TABLE covidworlddata.coviddeaths CHANGE COLUMN total_deaths total_deaths INT(255) NULL DEFAULT NULL
Error Code: 1064. 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 'INT' at line 2
Is it because the first row of the csv is the column names (e.g. total_deaths) as seen below? Source data csv
You have a syntax error, so check the syntax. As a minimum you need this
That's old column name, new column name (which is the same here) and then the rest of the column definition.
Reference: https://dev.mysql.com/doc/refman/8.0/en/alter-table.html