Search code examples
mysqlsqlmysql-error-1064

MySQL error message


I have imported my Access to MySQL through a program. I now want to change some of the columns from null to not null but it won't let me. An error 1265 comes up saying "data truncated for column" and the other error is error 1046, "no database selected".

What should I do?


Solution

  • First, select a database

    mysql> use myDatabase;
    

    Then, update all rows to a not null value

    mysql> UPDATE myTable SET myColumn = '' WHERE myColumn IS NULL;
    

    Then, alter your table

    mysql> ALTER TABLE myTable MODIFY COLUMN myColumn text NOT NULL;