Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8980681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:08:54+00:00 2026-06-15T20:08:54+00:00

I was quite surprised when MySQL allowed me to insert a NULL into a

  • 0

I was quite surprised when MySQL allowed me to insert a NULL into a field that was created with NOT NULL. I did some research and discovered how to enable strict mode. However, I am not quite sure what validation MySQL does when STRICT_ALL_TABLES is enabled.

The manual says:

Strict mode controls how MySQL handles input values that are invalid or missing. A value can be invalid for several reasons. (emphasis mine) For example, it might have the wrong data type for the column, or it might be out of range.

I understand what it considers missing and how it handles that. I am unclear what it considers invalid. I’ve done some testing and discovered the following:

  • strings that are too long are invalid
  • numbers that are out of range are invalid
  • NULLs for a non-NULL column are invalid
  • TRUE and FALSE always seem to be valid (they become 1 and 0 respectively)
  • invalid dates are invalid
  • zero dates are valid (additional modes can be enabled to change this behaviour)
  • floats in an integer field are valid (they get rounded)
  • letters in a number field are invalid

Does MySQL do any other validation checks other than what is mentioned above?

The manual says ‘wrong data type for the column’, but the only situation I see where this actually comes into play is letters in a number field. Are there other examples of data type errors?

Is there a list somewhere of exactly what checks MySQL performs?

EDIT: For the record, my application already does extensive validation. I am using strict mode as a last-chance, just-in-case check. If I forget to check something, I want it to fail fast rather than ‘silently mangle my data’.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:08:55+00:00Added an answer on June 15, 2026 at 8:08 pm

    A good resource is to check the MySQL source, and read mysql-test/t/strict.test to see all the cases they test for after setting STRICT mode or TRADITIONAL mode (which is a superset of STRICT).

    You did excellent research and testing, but there are a few more cases, such as:

    • Trying to insert an undefined ENUM value.
    • Trying to insert a default value for a NOT NULL column with no DEFAULT defined.
    • Trying to use CAST() to convert strings to integers, etc.
    • Conversion of VARCHAR to MEDIUMTEXT or LONGTEXT if you give a length greater than 65536.
    • Truncation of COMMENT strings for tables and columns.
    • Conversion of string to YEAR type.
    • Defining a SET or ENUM column with duplicate entries.

    Also mysql-test/include/strict_autoinc.inc, because it tests for overflow when an auto-inc value grows too large.

    There are a few other test files that use STRICT mode for specific tests, but I didn’t examine them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was quite surprised that Mathematica does not provide built-in operators to determine whether
I was quite surprised when I found out that for x <- array(0, c(5,3,1))
After years of ASP.NET development I'm actually quite surprised that I can't seem to
I'm new to JScript coming from a C++ world. I'm quite surprised that expressions
I was quite surprised to find inconsistent results today from the following MySQL query:
I've been looking around and am quite surprised that there seems to be no
I installed debian lenny, but I was quite surprised that I can't get man
I'm trying out PostSharp AOP and am surprised that OnMethodBoundaryAspect is not thread safe.
I'm actually quite surprised that I'm having so much trouble finding as answer for
I was quite surprised to find that the keys function happily works with arrays:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.