


Why Am I Getting an 'Invalid Default Value' Error When Adding a Text Column to My Table?
Dec 02, 2024 pm 04:57 PMInvalid Default Value Error in Table Alteration
When attempting to modify your table by adding a new column, you encountered an error: "ERROR 1067 (42000): Invalid default value for 'created_at'". Despite googling, you discovered that this error typically arises during timestamp alteration. However, your situation involves adding a new text column named "bank."
To resolve this issue, you must verify your sql_modes. Use the following command:
show variables like 'sql_mode' ;
If you notice the presence of "NO_ZERO_IN_DATE,NO_ZERO_DATE" in your sql_modes, this is causing the problem. Disable these modes to allow your query to succeed.
To globally modify the sql_mode as a root user, execute the following command:
set global sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
Once you have disabled the problematic sql_modes, you should be able to successfully add the "bank" column to your investments table.
The above is the detailed content of Why Am I Getting an 'Invalid Default Value' Error When Adding a Text Column to My Table?. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Reduce the use of MySQL memory in Docker

How do you alter a table in MySQL using the ALTER TABLE statement?

How to solve the problem of mysql cannot open shared library

What is SQLite? Comprehensive overview

Run MySQl in Linux (with/without podman container with phpmyadmin)

Running multiple MySQL versions on MacOS: A step-by-step guide

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?

How do I configure SSL/TLS encryption for MySQL connections?
