I would like to know what is the idea behind the database value type. Except the use of space and performance, why the table field need to specific in whether int, float or other type. Is this any result for that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Certain functions in MYSQL will act different depending on the data type. For example, if the MAX function is passed string values, it will return the maximum STRING value based on character, and if you were expecting it to sort values based on their numeric value, you’d be out of luck. Yes, MYSQL will sometimes cast things to numeric values when it needs to, but you can’t count on it. This is because strings are fundamentally different from numeric values – and are treated differently.
Also, MYSQL has less data types than you think – a lot are simply aliases that dictate maximum storage and such. SQLite3 (used in iOS and other stuff) only has 5 data types – Null, Integer, Real, Text, and Blob.
Finally, you said ignoring performance, but performance is very important in MYSQL, especially with large data sets. When checking 100000 rows to get the largest value, why would you want to have to cast each one from a number to a string, if they ought to have been a number in the first place?