Search code examples
mysqldefault

MySQL Best practice setting default value or not?


Good day,

I have a question. Recently moved my project to a new host where MySQL strict mode had been enabled.

Now I got hundreds of messages that no default value had been set for the database field.

But now the following. I can disable strict mode. And have it to work without issues. My question remains, what's the benefit?

Does it improve database speed to have a default value set for every field? Or reliability?

To my simple logic no value simply means NULL.


Solution

  • Neither. Strict mode in this case forces you to explicitly set your default values, which is a good practice. Otherwise you will rely on mysql's internal logic to derive the default value. What happens if that logic changes and you don't notice it?