2.5f

Data Types in Databases

Numeric Data Types

  • Integer Types:

    • Used for whole numbers, can be classified as signed or unsigned.

      • Signed Integers: Can be negative or positive.

      • Unsigned Integers: Only positive, can store larger numbers than signed integers of the same type.

  • Floating Point Types:

    • FLOAT: 4 bytes, approximate range of -3.4E+38 to 3.4E+38.

    • DOUBLE: 8 bytes, approximate range of -1.8E+308 to 1.8E+308.

  • Decimal Types:

    • DECIMAL(M, D): Storage varies depending on M (number of significant digits) and D (number of digits after the decimal point).

Character Data Types

  • CHAR(N): Fixed-length string, uses N bytes + 1 byte for length; where 0 ≤ N ≤ 255.

  • VARCHAR(N): Variable-length string, uses length of characters + 1 byte; max 65,535 characters.

Date and Time Data Types

  • DATE:

    • 3 bytes, format: YYYY-MM-DD.

    • Range: '1000-01-01' to '9999-12-31'.

  • TIME:

    • 3 bytes, format: hh:mm:ss.

  • DATETIME:

    • 5 bytes, format: YYYY-MM-DD hh:mm:ss.

    • Range: '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.

Binary Data Types

  • BINARY: Stores data exactly as they exist in memory.

  • VARBINARY: Similar to BINARY but can vary in length.

Special Data Types

  • Spatial Data Types: Used for storing geometric information, such as geometric shapes on a map.

    • Examples include points, lines, and polygons.

  • Document Types: Such as JSON and XML, used for storing structured textual data.

robot