0% found this document useful (0 votes)
5 views

SQL Data Types

This summary describes the main SQL data types including INT, VARCHAR, CHAR, FLOAT, DOUBLE, DECIMAL, DATE, DATETIME, TIMESTAMP, TEXT, and BLOB. The data types are used to store different types of data like numbers, text, dates and binary files in a database.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

SQL Data Types

This summary describes the main SQL data types including INT, VARCHAR, CHAR, FLOAT, DOUBLE, DECIMAL, DATE, DATETIME, TIMESTAMP, TEXT, and BLOB. The data types are used to store different types of data like numbers, text, dates and binary files in a database.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

SQL data types

1. INT: Stands for integer. It is used to store whole numbers (both positive and negative)
without any fractional part. Examples include 1, -5, 100, etc. The size of an INT varies
depending on the database system but typically uses 4 bytes of storage.
2. VARCHAR: Stands for variable character. It is used to store variable-length
alphanumeric strings. The maximum length must be specified when defining a
VARCHAR column. It is efficient for storing strings of varying lengths up to the
specified maximum.
3. CHAR: Stands for character. Similar to VARCHAR, it is used to store fixed-length
alphanumeric strings. However, CHAR always uses the specified length, padding shorter
strings with spaces. It's useful for fixed-length data, such as postal codes or state
abbreviations.
4. FLOAT: Represents approximate numeric values with single precision. It is commonly
used for scientific computations or when precision up to approximately 7 decimal digits
is sufficient. FLOAT requires 4 bytes of storage.
5. DOUBLE: Represents approximate numeric values with double precision. It provides
higher precision compared to FLOAT, typically supporting around 15 decimal digits.
DOUBLE requires 8 bytes of storage.
6. DECIMAL: Also known as DEC or NUMERIC, it represents exact numeric values with
fixed precision and scale. Precision refers to the total number of digits, while scale
represents the number of digits after the decimal point. DECIMAL is commonly used for
financial data where precision is critical.
7. DATE: Stores a date value without any time component. It is used to represent dates in
the format YYYY-MM-DD. DATE data type is useful for storing dates of events,
birthdays, etc.
8. DATETIME: Stores both date and time values. It is used to represent a specific point in
time, including both the date and the time down to fractions of a second. DATETIME
data type is useful for storing timestamps of events, transactions, etc.
9. TIMESTAMP: Similar to DATETIME, it also stores both date and time values.
However, TIMESTAMP typically represents a point in time relative to the start of the
epoch (January 1, 1970, 00:00:00 UTC) and is often used for tracking changes to records.
10. TEXT: Used to store large blocks of text data, such as articles, descriptions, or
comments. It can hold a variable amount of text, up to a maximum specified limit, which
varies depending on the database system.
11. BLOB: Stands for Binary Large Object. It is used to store large binary data, such as
images, audio, or video files. BLOB can hold a variable amount of binary data, up to a
maximum specified limit, which varies depending on the database system.

You might also like