Update with SET giving error

Asked

Viewed 105 times

1

I have several UPDATE with practically the same code as this:

UPDATE cliente
  SET Email = '[email protected]'
  WHERE idCliente = 0000;

But some make this mistake:

Data truncation: Data Too long for column 'Email' at Row 1

  • 2

    What type and size of email field?

  • 1

    In the Scheme of your table check the type and amount of characters you set for the 'Email' column if you return Too long date is because you exceeded the set limit

  • you will need a ALTER TABLE cliente CHANGE Email Email VARCHAR(255) instead of 255 change to the size you want but can be 255 even. You must specify the column name Email 2 times if you only want to change the definition of the column (and not its name). To also change the name of the same, provide the new name after the name of the same ALTER TABLE cliente CHANGE Email NovoNome VARCHAR(255)

1 answer

6


The error message is clear about what is happening: the data is too long for the column Email.

You are trying to save 29 characters, surely this column is configured in the table with a smaller size than this, or put a smaller piece of data or put a larger size in the column.

Note also that if the characters leave the spectrum of what is called ASCII table the character will occupy 2 or more bytes what can do, depending on the configuration of the table, need a bigger reserve.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.