Mathieu
Mathieu

Reputation: 1677

Strict data validation with MySQL

I am working with MySQL Workbench and I noticed that my table was accepting pretty much any values without doing any data validation. Setting the sql_mode to "STRICT_ALL_TABLES" solved most of my problems.

However, when I insert a floating point value in a integer column, the value is rounded to the nearest int.

My question is: is there a way to force MySQL Workbench to throw an error instead of doing a rounding operation?

Thanks!

Upvotes: 0

Views: 541

Answers (1)

wallyk
wallyk

Reputation: 57774

It is a design dilemma between being friendly and doing what you mean, or being a pain-in-the-a@@ and making you work harder.

If such validation is valuable, add a frontend interface which performs those sorts of validations, including cross-field and cross-table validation. While you're at it, helpfully suggest field values from correlation with historical values, etc.

Upvotes: 1

Related Questions