Data types play an important role while creating tables for databases. A database table can contain multiple columns with different data types like numeric or string.
By the below characteristics, you can determine MySQLi data types:
- The type of values it holds.
- The space it takes or the length of the value.
- If the value can be indexed or not.
- How it compares the values of data types.
Important MySQLi Data Types
In this MySQLi tutorial, we will learn about some important data types and how to use them in the tables. MySQLi data types can be divided into 4 major categories.
- Numeric data types
- String data types
- Date and time data types
Numeric data types
MySQLi supports the standard SQL numeric data types, including INTEGER, DECIMAL, SMALLINT, and NUMERIC. These numeric data types can include the exact numeric data types (Example:- numeric, integer, decimal, etc.) and the approximate numeric data types (Example:- real, float, and double precision).
String data types
In MySQLi, a string can be a simple plain text or binary data such as images or files. Strings can be searched and compared based on pattern matching by using the operators and regular expressions.
Date and time data types
MySQLi provides data types for time and date, as well as the combination of time and date. MySQLi also supports the timestamp data type used to track the changes in a table’s row. Use year data type to store years without date and months.