MySQL ALTER TABLE add column: error at another column

后端 未结 2 704
南旧
南旧 2021-01-25 22:36

ok, i have people table and try run sql-script with the next command:

ALTER TABLE `people`
    ADD COLUMN `name_spelling`
    VARCHAR(255) NULL DEFA         


        
相关标签:
2条回答
  • 2021-01-25 23:11

    I ran into this issue once and the fix i had was to to edit mysql.cnf file Replace : sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

    with this : sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

    Notice i removed the No_ZEROs in that options.

    0 讨论(0)
  • 2021-01-25 23:17

    Maybe your MySQL has some option such as the NO_ZERO_DATE SQL mode (I think it's not the only mysql config that prevents 0000-00-00 dates). This would prevent you from using 0000-00-00 as a value. It happened to me before that I had a table already created violating that condition. It will not be editable until you change the value or disable what's preventing you to set 0 dates.

    For reference :http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html

    0 讨论(0)
提交回复
热议问题