SQL DataTypes
SQL data types define the type of data that can be stored in a table's columns. They help ensure data integrity and optimize storage. Here is an overview of common SQL data types:
Numeric Data Types
| DataType |
Description |
| INTEGER |
Stores whole numbers. |
| SMALLINT |
Stores smaller range of whole numbers. |
| BIGINT |
Stores larger range of whole numbers. |
| DECIMAL |
Stores fixed-point numbers. |
| NUMERIC |
Similar to DECIMAL. |
| FLOAT |
Stores floating-point numbers with approximate precision. |
| REAL |
Stores floating-point numbers with less precision than FLOAT. |
| DOUBLE |
Stores double precision floating-point numbers. |
Character String Data Types
| DataType |
Description |
| CHAR |
Fixed-length character string. |
| VARCHAR |
Variable-length character string. |
| TEXT |
Variable-length character string with unlimited length. |
Date and Time Data Types
| DataType |
Description |
| DATE |
Stores date values. |
| TIME |
Stores time values. |
| TIMESTAMP |
Stores date and time values. |
| DATETIME |
Stores date and time values (often used interchangeably with TIMESTAMP in some RDBMS). |
| YEAR |
Stores year values. |