Skip to content

Data types in SQL

SQL supports a variety of data types that can be used to define the structure of tables and the type of data that can be stored in each column. The choice of data type can affect the performance and storage requirements of your database, so it's important to choose the appropriate data type for each column.

Common SQL Data Types

  1. Integer Types – used to store whole numbers (e.g., INT, SMALLINT, BIGINT)
  2. Floating-Point Types – used to store decimal numbers (e.g., FLOAT, DOUBLE, REAL)
  3. Character Types – used to store text (e.g., CHAR, VARCHAR, TEXT)
  4. Date and Time Types – used to store date and time values (e.g., DATE, TIME, DATETIME, TIMESTAMP)
  5. Boolean Type – used to store true/false values (e.g., BOOLEAN)
  6. Binary Types – used to store binary data (e.g., BINARY, VARBINARY, BLOB)
  7. JSON Type – used to store JSON data (e.g., JSON)
  8. UUID Type – used to store universally unique identifiers (e.g., UUID)
  9. Array Type – used to store arrays of values (e.g., ARRAY)
  10. Enum Type – used to store a predefined set of values (e.g., ENUM)
  11. Spatial Types – used to store spatial data (e.g., GEOMETRY, POINT, LINESTRING, POLYGON)
  12. XML Type – used to store XML data (e.g., XML)
  13. Money Type – used to store currency values (e.g., MONEY)
  14. Bit Type – used to store bit values (e.g., BIT)
  15. Serial Type – used to store auto-incrementing integer values (e.g., SERIAL, BIGSERIAL)
  16. UUID Type – used to store universally unique identifiers (e.g., UUID)
  17. JSONB Type – used to store JSON data in a binary format for faster access (e.g., JSONB)