MySQL provides multiple data types to store different types of data, including integer types, floating point types, fixed point types, character types, time and date types, and other types. These data types have different characteristics and uses and are used to meet different data storage needs.
Common data types in MySQL
MySQL provides multiple data types to store different data, each Each type has its own unique properties and uses. The following are some of the most commonly used data types:
Integer type
-
TINYINT: An 8-bit unsigned integer ranging from 0 to 255
-
SMALLINT: 16-bit unsigned integer ranging from 0 to 65535
-
MEDIUMINT: 24-bit unsigned integer ranging from 0 to 16777215
-
INT: 32-bit unsigned integer ranging from 0 to 4294967295
-
BIGINT: 64-bit unsigned integer ranging from 0 to 18446744073709551615
Floating point type
- ##FLOAT: 32-bit floating point number, ranging from approximately -3.4e38 to 3.4e38
- DOUBLE: 64-bit floating point number, ranging from approximately -1.7e308 to 1.7e308
Fixed-point type
- DECIMAL: Fixed-point number, used for precise calculations
- NUMERIC: Similar to DECIMAL, but only supports a limited number of decimal places
String type
- CHAR(n): Fixed length string, length is n
- VARCHAR(n): Variable length string, the maximum length is n
- TEXT: Long string, no limit to the length
Time and date type
- DATE: Date, format is YYYY-MM-DD
- TIME: Time, The format is HH:MM:SS
- DATETIME: The date and time are in the format YYYY-MM-DD HH:MM:SS
- TIMESTAMP: Timestamp, record creation or update time
Other types
- BLOB: Binary large object, use For storing binary data
- ENUM (value 1, value 2, ...): Enumeration type, only allowed to store specified values
- SET ( value1, value2, ...): Collection type, allows to store a set of values
The above is the detailed content of What are the common data types in mysql?. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn