As told by @rray b
is used for binary data, for example photos, zipped files, etc.
The guys VARCHAR
and TEXT
are fields that use string
that is accept from A to Z from 0 to 9, so the use should be the s
, do not use to make calculations.
So the supported characters vary depending on the collection used. For example:
utf8_general_ci
supports Unicode characters however it is simpler.
utf8mb4_unicode_ci
supports most (if not all) Unicode characters.
latin1_general_ci
does not use Unicode, but supports accents.
That is, the s
you can pass a string, but when the process reaches the query the characters can be lost if they are not compatible with the collection
used.
Working with Monetary Values
If you’re going to use monetary values, maybe you should use DECIMAL
(note that you will not use comma).
Check out these answers (despite talking about sql-server): /a/5760/3635
The decimal type
Decimal type does not have the same type accuracy problems float
and double
. It is a fixed point type, not floating. In other words, if you define a field in a database as Mysql of type DECIMAL(10,2)
, means that it will be a 10-digit (base 10) number, of which 2 will be after the comma. Always. Some databases even store such data internally as strings.
This storage strategy eliminates the problem of data storage rounding, but on the other hand it decreases type flexibility. While it may not be a good choice for data where the number of decimals cannot be set, it is a good option for example for financial values (since these always have 2 decimal places).
It should also be taken into account that in some cases decimal values will be converted to floating point numbers implicitly when used in calculations. In this case if the expected result also of the decimal type, it will be rounded and converted from float to decimal. I mean, the accuracy is better, but it’s not limitless.
Source: http://douglascunha.com/blog/2010/08/tipos-sql-float-double-decimal/#sthash.VGlFZBL7.dpuf
Columns with fractionated numbers the thousand separator is usually point.
b
is for binary data, for example save an image upload.– rray
Currency values would be money? Maybe it is legal to use DECIMAL.
– Guilherme Nascimento
About the problem of using double/float/real have a few questions, just take a look at: Different numbers become equal after conversion with doubleval and Best kind of data to work with money?
– rray