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:
- 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.
- 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.
- 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.
- Boolean Data Type:
- BOOLEAN: Used to store true or false values.
- 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.
- 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.