SQL Error 1406 Data too long for column

前端 未结 3 1247
無奈伤痛
無奈伤痛 2020-12-29 11:44

I am trying to execute the query below in MySQL but get the SQL error 1406 Data too long for column error every time. The column data type is longtext. Any ideas?

         


        
相关标签:
3条回答
  • 2020-12-29 11:51

    I think you make the content filed as the varchar type. but for store the long text you have make it the text type. this type not required any length

    0 讨论(0)
  • 2020-12-29 11:56

    Apart from the obvious possibility of getting an error for a different column (your error message does not seem to mention the exact column, which is weird), here's what the manual has to say about LONGTEXT:

    A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 – 1) characters. The effective maximum length is less if the value contains multi-byte characters. The effective maximum length of LONGTEXT columns also depends on the configured maximum packet size in the client/server protocol and available memory. Each LONGTEXT value is stored using a four-byte length prefix that indicates the number of bytes in the value.

    You can verify maximum packet size with this query:

    SELECT @@max_allowed_packet
    

    If it happens to be a small value, see this related answer for further info.

    0 讨论(0)
  • 2020-12-29 12:05

    There must be an issue with your column datatype.

    The string you are inserting (via update) is 1,875 which is nowhere near the limit of longtext.

    Take a look at this "pour l''Europe et l''Afrique" in your insert string. It may be causing you issues, try to insert the data without the "'" character.

    could you try to insert a string of 1,875 characters, perhaps "aaaaaaa....". this would rule out a problem with the contents of the string you are inserting.

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