kanenas.net

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

by kanenas.net on May.23, 2009, under MySQL, SQL

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 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
  • Share/Bookmark

read also...

:, , , , ,

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!