乐闻世界logo
搜索文章和话题

What are the different data types in MySQL?

2月7日 00:10

In MySQL, data types can be broadly categorized into the following groups:

  1. Numeric types:

    • Integer: TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT
    • Floating-point and double-precision: FLOAT, DOUBLE, DECIMAL
  2. Date and time types:

    • DATE: Only date values
    • TIME: Only time values
    • DATETIME: Date and time
    • TIMESTAMP: Timestamp
    • YEAR: Year
  3. String types:

    • String: CHAR, VARCHAR
    • Text: TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT
    • Binary: BINARY, VARBINARY
    • Binary text: TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB
    • Enum type: ENUM
    • Set type: SET
  4. Spatial data types:

    • GEOMETRY, POINT, LINESTRING, POLYGON, etc.
  5. JSON data types:

    • JSON

Each data type has specific use cases and storage requirements. Selecting the appropriate data type can optimize database performance and storage efficiency.

标签:MySQL