Tag Archives: STRICT_TRANS_TABLES

SQL error – Out of range value adjusted for column OR Duplicate entry xxx for key 1

Senario:
CREATE TABLE test_table (test_id TINYINT, test_text VARCHAR(20));
INSERT INTO test_table (test_id, test_text) VALUES ('', 'This is a test');

Errors:
SQL error “Out of range value adjusted for column…”

if you have removed STRICT_TRANS_TABLES from my.ini (Windows) or my.cnf (Linux)
Server SQL Modes

You will get this error…
Duplicate entry xxx for key 1

ATTENTION:
If you want to remove STRICT_TRANS_TABLES
1. You need to have access and restart MySQL Server! A production server !?!?
2. Not everybody has root access or admin rights to change the sql mode.
3. Maybe, you need the server to run in strict mode for some reason.
4. NOT RECOMMENDED!

Solution:
Check the field type (e.g test_id TINYINT -128 to 127 )
So if you are trying to insert into a table value 128 it won’t insert !

MySQL 5.1 Reference Manual :: 10 Data Types :: 10.2 Numeric Types

😉

1 Star2 Stars (+3 rating, 2 votes)
Loading...