Basic Data Types
Basic Data Types
by Ijaz Ahmad
VARCHAR: Variable Character Length
1 Definition
2 Characteristics
VARCHAR allows you to specify a maximum length for the stored value. It uses
only as much storage as needed, optimizing space usage in the database.
3 Example
TEXT is a data type used to TEXT is commonly used in When querying TEXT
store large amounts of text, applications that require columns, it's important to
such as paragraphs, articles, storing user-generated understand that operations
or comments. It allows for content, such as social on these columns may
storing up to 65,535 media platforms, forums, affect performance due to
characters. and blogs. their size.
INT: Integer Numbers
INT is a data type used to store INT can store values in the INT allows for arithmetic
whole numbers without decimal range of approximately -2 operations such as addition,
places. It is commonly used for billion to +2 billion, depending subtraction, multiplication, and
counting, indexing, and on the specific implementation. division, making it versatile for
performing arithmetic various calculations.
operations.
BIGINT: Large Integer Numbers
1 Definition
FLOAT is a data type used to store decimal numbers with a floating point. It is commonly used
for measurements, scientific calculations, and financial data.
Precision
FLOAT provides a certain level of precision, but it may not be entirely accurate due to inherent
limitations of representing decimal values in binary format.
Range
FLOAT can handle a wide range of positive and negative values, making it suitable for scenarios
that require a flexible range of decimal numbers.
DOUBLE: High-Precision Floating-Point
Numbers
DOUBLE is a data type that DOUBLE is commonly used in When dealing with financial
provides higher precision for scientific research, engineering, calculations involving money,
decimal numbers compared to and financial modeling, where DOUBLE can ensure more
FLOAT. It is typically used in precision and accuracy are accurate results due to its higher
scenarios that require extremely crucial for accurate results. precision.
precise calculations.
BOOL: Boolean Values
1 Definition
BOOL is a data type used to represent boolean values, which can be either true or
false. It is commonly used in logic and decision-making scenarios.
2 Application
BOOL is useful for storing binary information, such as toggling states, tracking
preferences, or checking the validity of certain conditions.
3 Representations
DATE is a data type used for storing dates such as birthdays, events, or deadlines.
2 TIME
TIME is a data type used to store specific times, such as appointment schedules or logging
timestamps.
3 YEAR
YEAR is a data type used to store specific years, often used for recording historical or
chronological information.