What are the datatypes used in MYSQL?

 Some of the datatypes used in SQL are listed below:

Numeric Data Types:

  1. TINYINT:

    • Size: 1 byte
    • Range: -128 to 127
  2. SMALLINT:

    • Size: 2 bytes
    • Range: -32,768 to 32,767
  3. INTEGER or INT:

    • Size: 4 bytes
    • Range: -2,147,483,648 to 2,147,483,647
  1. MEDIUM INT:

    • Size: 8 bytes
    • Range: -8388608 to 8388607
  2. BIG INT:

  3. Size: 8 bytes

  4. Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

  1. DECIMAL or NUMERIC:

    • Precision: Up to 65 digits
    • Scale: Up to 30 digits
  2. FLOAT:

    • Size: 4 bytes
    • Precision: 7 digits
  3. REAL:

    • Size: 4 bytes
    • Precision: 7 digits
  4. DOUBLE or DOUBLE PRECISION:

    • Size: 8 bytes
    • Precision: 15 digits

Character String Data Types:

  1. CHAR(n):

    • Size: Fixed length of n characters.
  2. VARCHAR(n):

    • Size: Variable length up to n characters.
    • Range: 1 to 65,535 bytes.
  3. TEXT:

  • Size: Variable length.
  • Range: 1 to 65,535 bytes.

Date and Time Data Types:

  1. DATE:

    • Size: 3 bytes
  2. TIME:

    • Size: 3 bytes
  3. DATETIME:

    • Size: 8 bytes
  4. TIMESTAMP:

    • Size: 4 bytes

Boolean Data Type:

  1. BOOLEAN or BOOL:
    • Values: TRUE, FALSE, or NULL

Binary Data Types:

  1. BINARY(n):

    • Size: Fixed length of n bytes.
  2. VARBINARY(n):

    • Size: Variable length up to n bytes.
    • Range: 1 to 65,535 bytes.
  3. BLOB:

    • Size: Variable length.
    • Range: 1 to 65,535 bytes.

Miscellaneous Data Types:

  1. ENUM:

    • Size: 1 or 2 bytes, depending on the number of enumeration values.
  2. SET:

    • Size: 1, 2, 3, 4, or 8 bytes, depending on the number of set members.
  3. JSON:

    • Size: Variable length.

Comments

Popular posts from this blog

Java Program to create a large array and copy its values equally to two small arrays and display the second array only

Python program to sum up the Salary when the Name and Age matches with subsequent rows.