358 views, 0 RAMs, and 1 comment
Over the past few weeks, I have been trying to pick up some SQL in my free time. It is going decently well, but I seem to be getting one error a lot and don't know how to fix it. The error is "string or binary data would be truncated." What is this, how can I fix it?
This is a debug account.
Trunication is basically where you're going to lose some of your data by inserting it. This is cause by trying to pass in data which is larger than the table allows.
For example, if you have passwords stored as a MD5 hash your table will have that column set up for 32 characters.
If you were to then change this MD5 to SHA2, your new password string would be 200 characters (from memory). The last 168 characters would not fit and would be lost.
Go through each column type and make sure the data you're passing in fits, when you find the error you can either:
- Alter the table structure to allow it.
- Validate data before it's sent to the table and reject it here.
Hope this helps.
"THAT DOG IS GETTING RAPED" - Terry A. Davis
Post a New Comment
Do you like having a good time?
Register an Account
Read Quality Articles
Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.
Argue with People on the Internet
Use your account to explain why people are wrong on the Internet forum.
Vandalize the Wiki
Or don't. I'm not your dad.
Ask and/or Answer Questions
If someone asks a terrible question, post a LMGTFY link.
Make Some Money
Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.
Answers— Read More
Find more related content below!
- Selicting database with the MySQL command line?
- How do I install Oracle 11g?
- [PostgreSQL vs MySQL] Which DB has the best performance?
- When to Use Apache Cassandra vs MongoDB?
- [SQL Server] Difference between datetime and datetime2?
- What are the differences between MariaDB and MySQL (sine MariaDB is a fork)?
- [Dreamhost Error] How to fix "MySQL 504 Gateway Time-out; The server didn't respond in time?"
- What do I do "Access denied for user 'root'@'localhost'"? Help needed
- How to fix "Operand should contain 1 column(s)"?
- How to fix "Every derived table must have its own alias"?