Cover Image for MySQL Data Types
97 views

MySQL Data Types

MySQL supports a wide range of data types that allow you to store and manipulate different types of data efficiently. Here are some of the commonly used data types in MySQL:

  1. Numeric Data Types:
  • INT or INTEGER: A standard integer.
  • TINYINT: A very small integer.
  • SMALLINT: A small integer.
  • MEDIUMINT: A medium-sized integer.
  • BIGINT: A large integer.
  • DECIMAL or NUMERIC: Fixed-point numbers.
  • FLOAT: A single-precision floating-point number.
  • DOUBLE: A double-precision floating-point number.
  1. Character String Data Types:
  • CHAR: Fixed-length character strings.
  • VARCHAR: Variable-length character strings.
  • TEXT: Variable-length text strings (with a large storage capacity).
  • ENUM: A string object that can have one value chosen from a list of allowed values.
  1. Binary Data Types:
  • BINARY: Fixed-length binary strings.
  • VARBINARY: Variable-length binary strings.
  • BLOB: Binary large objects for storing binary data (e.g., images).
  1. Date and Time Data Types:
  • DATE: Date (YYYY-MM-DD).
  • TIME: Time (HH:MM:SS).
  • DATETIME: Date and time (YYYY-MM-DD HH:MM:SS).
  • TIMESTAMP: A timestamp that updates automatically (YYYY-MM-DD HH:MM:SS).
  • YEAR: A year in two-digit or four-digit format.
  1. Boolean Data Type:
  • BOOLEAN or BOOL: A true/false or 1/0 value.
  1. JSON Data Type:
  • JSON: For storing JSON (JavaScript Object Notation) data.
  1. Spatial Data Types:
  • GEOMETRY: For storing geometry values.
  • POINT: A single point in space.
  • LINESTRING: A curve with straight segments.
  • POLYGON: A closed polygon.
  • GEOMETRYCOLLECTION: A collection of geometries.
  1. Set Data Type:
  • SET: A string object that can have zero or more values chosen from a list of allowed values.
  1. ENUM Data Type:
  • ENUM: A string object that can have one value chosen from a list of allowed values.

These data types provide the flexibility to store various types of data efficiently in your MySQL database. It’s essential to choose the appropriate data type for each column to ensure efficient storage and retrieval of data. Additionally, MySQL also supports user-defined data types and custom types in some storage engines.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS