D
MySQL Datatypes
This appendix explains the different datatypes used in MySQL.
As explained in Chapter 1, “Understanding SQL,” datatypes are basically rules that define what data may be stored in a column and how that data is actually stored.
Datatypes are used for several reasons:
Datatypes enable you to restrict the type of data that can be stored in a column. For example, a numeric datatype column accepts only numeric values.
Datatypes allow for more efficient storage internally. For example, numbers and datetime values can be stored in a more condensed format than can text strings.
Datatypes allow for alternate sorting orders. If everything is treated as strings,
1
comes before10
, which comes before2
. (Strings are sorted in dictionary ...
Get MySQL Crash Course, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.