“Data too long for column” - why?

前端 未结 12 676
Happy的楠姐
Happy的楠姐 2020-12-12 19:47

I\'ve written a MySQL script to create a database for hypothetical hospital records and populate it with data. One of the tables, Department, has a column named Description,

相关标签:
12条回答
  • 2020-12-12 19:57

    For me, I defined column type as BIT (e.g. "boolean")

    When I tried to set column value "1" via UI (Workbench), I was getting a "Data too long for column" error.

    Turns out that there is a special syntax for setting BIT values, which is:

    b'1'
    
    0 讨论(0)
  • 2020-12-12 20:00

    Very old question, but I tried everything suggested above and still could not get it resolved.

    Turns out that, I had after insert/update trigger for the main table which tracked the changes by inserting the record in history table having similar structure. I increased the size in the main table column but forgot to change the size of history table column and that created the problem.

    I did similar changes in the other table and error is gone.

    0 讨论(0)
  • 2020-12-12 20:04

    Change column type to LONGTEXT

    0 讨论(0)
  • 2020-12-12 20:07

    I try to create a table with a field as 200 characters and I've added two rows with early 160 characters and it's OK. Are you sure your rows are less than 200 characters?

    Show SqlFiddle

    0 讨论(0)
  • 2020-12-12 20:08

    in mysql if you take VARCHAR then change it to TEXT bcoz its size is 65,535 and if you can already take TEXT the change it with LONGTEXT only if u need more then 65,535.

    total size of LONGTEXT is 4,294,967,295 characters

    0 讨论(0)
  • 2020-12-12 20:10

    Varchar has its own limits. Maybe try changing datatype to text.!

    0 讨论(0)
提交回复
热议问题