Knowledgebase

Understanding Column Data Types Print

  • databasesphpmyadmin, databases, woocommerce, errors, troubleshooting, guide, howto, solution
  • 0

What each column can hold.

NUMBERS

INT for whole numbers, with variants for different ranges DECIMAL for exact values, which is what money should use FLOAT and DOUBLE for approximate values, which money should never use

Storing prices as floating point produces rounding errors that appear in totals.

TEXT

VARCHAR for short text with a defined maximum TEXT for longer content LONGTEXT for very long content, such as post bodies

A VARCHAR limited to 255 characters rejects anything longer, producing a data too long error.

DATES

DATE for a date alone DATETIME for a date and time TIMESTAMP, which is stored relative to a timezone and converted on retrieval

The distinction between DATETIME and TIMESTAMP causes genuine confusion when timezones differ.

OTHER

BOOLEAN, usually stored as a small integer ENUM, a fixed list of permitted values JSON, in newer versions

WHY THIS MATTERS

Inserting a value the column cannot hold produces an error. Understanding the type explains why.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot