SQL Datatype

In SQL (Structured Query Language), there are several data types available to store different types of data in database tables. The specific data types may vary slightly depending on the database management system (DBMS) you are using, but I’ll provide you with a common set of SQL data types:

  1. Numeric Data Types:
    • INT (integer): Used to store whole numbers.
    • DECIMAL(p, s) or NUMERIC(p, s): Used to store fixed-point numbers with a specified precision (p) and scale (s).
    • FLOAT: Used to store floating-point numbers.
    • DOUBLE: Used to store double-precision floating-point numbers.
  2. Character Data Types:
    • CHAR(n): Used to store fixed-length character strings of length ‘n’.
    • VARCHAR(n): Used to store variable-length character strings with a maximum length of ‘n’.
    • TEXT: Used to store large variable-length character strings.
  3. Date and Time Data Types:
    • DATE: Used to store a date (year, month, and day).
    • TIME: Used to store a time (hours, minutes, seconds).
    • TIMESTAMP: Used to store a date and time.
  4. Boolean Data Type:
    • BOOLEAN: Used to store true or false values.
  5. Binary Data Types:
    • BINARY(n): Used to store fixed-length binary data of length ‘n’.
    • VARBINARY(n): Used to store variable-length binary data with a maximum length of ‘n’.
    • BLOB: Used to store large variable-length binary data.
  6. Other Data Types:
    • ENUM: Used to store a predefined list of values.
    • JSON: Used to store JSON (JavaScript Object Notation) data.

These are some of the commonly used data types in SQL. It’s worth noting that different database systems might offer additional data types or have variations in the naming conventions.