Error Code: 1406. Data too long for column
CREATE TABLE `TEST`
(
`idTEST` INT NOT NULL ,
`TESTcol` VARCHAR(45) NULL ,
PRIMARY KEY (`idTEST`)
);
Now Insert
some values
INSERT INTO TEST
VALUES
(
1,
'Vikas'
)
select
SELECT * FROM TEST;
Inserting record more than the length
INSERT INTO TEST
VALUES
(
2,
'Vikas Kumar Gupta Kratika Shukla Kritika Shukla'
)
If we select
the length
SELECT LENGTH('Vikas Kumar Gupta Kratika Shukla Kritika Shukla')
'47'
And it is showing the error message
Error Code: 1406. Data too long for column
But what is my expectation is, I want to insert at least first 45 characters in Table
please let me know if the question is not clear.
I know the cause of this error. I am trying to insert values more than the length of datatype.
I want solution in MySQL as It is possible in MS SQL
. So I hope it would also be in MySQL.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…