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

Data Types Range Examples

The document describes different SQL data types including their range of values and examples of appropriate uses. Tinyint can store values from 0 to 255 and is suitable for limited calculations or accounting discounts. Smallint stores -32,768 to 32,767 and can hold IDs. Int stores larger integers from -2 billion to 2 billion and is suitable for transactions. Bigint stores very large integers. Decimal stores numbers with decimals. Datetime stores dates and times with varying precisions and ranges.

Uploaded by

mhdworld
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Data Types Range Examples

The document describes different SQL data types including their range of values and examples of appropriate uses. Tinyint can store values from 0 to 255 and is suitable for limited calculations or accounting discounts. Smallint stores -32,768 to 32,767 and can hold IDs. Int stores larger integers from -2 billion to 2 billion and is suitable for transactions. Bigint stores very large integers. Decimal stores numbers with decimals. Datetime stores dates and times with varying precisions and ranges.

Uploaded by

mhdworld
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Data Types Range Examples

tinyint Range of values from 0 to 255 1. This data type can be used
for any that purpose which
required number and in very
limited term.

2. This data type can be used


for the calculation of number
of days which exist in 30, also
for the calculation of number
of weeks.

3. This data type can be used in


accounting software where
the term (within 10 or 20
days etc) has been set for
discount purpose.
smallint Range of values: -32,768 (-2^15) through 1. This data type can be used to
32,767 (2^15 - 1) hold an employee id.

2. This data type can also be


used for holding the student
id of any school, college and
University.

3. This data type can be used to


stored invoice no (sales id).
int Range of values: -2,147,483,648 (-2^31) 1. This data type can be used
through 2,147,483,647 (2^31 – 1) for holding the number of
transactions for small or
medium organizations.

2. The ATM machine is another


example for the use of this
data type to store as number
of transaction.

3. It can be used in DATA WARE


houses to record no of
transactions.
bigInt Range of values : -9,223,372,036,854,775,808 1. This data type also can be
(-2^63) through 9,223,372,036,854,775,807 used for holding the number
(2^63-1) of transactions but it may for
the large organizations.
2. This data type can also be
used to store images, which
will convert into binary
format (010101).
decimal or Range of values: -10^38 + 1 through 10^38 -1 1. This data type can be used to
numeric Precision: minimum of 0 and maximum of 38 store values with decimals.

2. The amount of salary,


income, income tax etc.
smallmoney Range of values: -214,748.3648 through 1. This data type can be used to
214,748.3647 store income, salary of
Precision: 10 employees.

2. This data type can be used to


store Profit, Revenue,
expense and other accounts
of an organization.
money Range of values: -922,337,203,685,477.5808 1. This data type can be used to
through 922,337,203,685,477.5807 store the same as small
Precision: 19 money but in money data
type we can store very large
number of amount as
compare to small money.

2. This data type can also be


used to store the value of
Galaxy information, like
distance of moon and sun
and other planets in the
universe.
smalldatetime Date range: Jan 1, 1900 through Jun 6,2079 1. This data type can be used to
Time resolution: 1 minute hold date for the short
Length: 4 limited period of time.

2. This data type can be used


for holding the contract
duration / date information
which can be a limited period
of time. (For e.g. 1 to 5 years
or 5 to 10 etc.)
datetime Date range: Jan 1, 1753 through Dec 31, 999 1. This data type can be used to
Time resolution: 3.33 milliseconds hold date and time for long
Length: 8 (till dec 31 9999) period of
time.

2. This data type can be used


for holding the hiring as well
as firing date and time
information of employees. It
can be used for the long
period of time.

3. It also can be used to hold


sales date, purchase date and
other accounting period of
date and time.
real Range of values: -3.40E+38 through 3.40E+38 1. This data type can be used to
hold a number or figure
which may be calculated for
the laboratory test purpose.

2. This data type can be used to


store scientific values.
float Range of values: -1.79E + 308 through 1. This data type can be used to
1.79E + 308 hold scientific values.

2. This data type can be used to


store a figure which results in
testing the experiment of
chemicals.
char Fixed-length non-Unicode character data 1. This data type can be used to
with a maximum length of 8,000 characters. store the character value like
gender (M or F, male or
female ) (but it will not
readable in other language
other than It has created)

2. This data type can also be


used to store the information
of an employee’s manager or
commission, if an employee
has a manager or have a
commission then the value
would be ‘Y’ (yes) else ‘N’
(no). (but it will not readable
in other language other than
It has created)

3. This data type can be used


for the value that length is
known.
Varchar(max) Variable-length non-Unicode data with a 1. This data type can be used to
maximum length of 2^31 characters(). store the Name of a student,
employee, person etc.
2. This data type can be used
for the value that length is
unknown.

3. This data type can be used to


store the message, which
may be of 2 or 3 lines or
more.
text The maximum number of characters in a text 1. This data type can be used to
data type is 2GB. store the value like a detail
text/message or passage.

2. This data type can be used to


store the values like
suggestion, Feedback etc.
Nchar Characters 1 through 4,000. 1. This data type can be used to
store the character value like
gender (M or F, male or
female) But with Unicode
(readable in any language).

2. This data type can also be


used to store the information
of an employee’s manager or
commission, if an employee
has a manager or have a
commission then the value
would be ‘Y’ (yes) else ‘N’
(no). But with Unicode
(readable in any language).

3. This data type can be used to


store the value that length is
known. But with Unicode
(readable in any language).
nVarchar(max) Variable-length non-Unicode data with a 1. This data type can be used to
maximum length of 2^31 characters (). store the Name of a student,
employee, person etc. But
with Unicode (readable in
any language).

2. This data type can be used


for the value that length is
unknown. But with Unicode
(readable in any language).
3. This data type can be used to
store the message, which
may be of 2 or 3 lines or
more. But with Unicode
(readable in any language).
ntext The maximum number of characters in a text 1. This data type can be used to
data type is 2GB. store the value like a detail
text/message or passage. But
with Unicode (readable in
any language).

2. This data type can be used to


store the values like
suggestion, Feedback etc. But
with Unicode (readable in
any language).
binary(n) Fixed values from 1 through 8,000. 1. This data type is used to
store images with a fix or
limited size. If small size of
picture will be inserted it will
occupy the same space as
mentioned when defining
data type.

2. This data type can be used by


the hr department to store
the employee’s picture as an
identity.

3. This data type can be used by


school, college and university
database to store picture of
students.
varbinary(n) Variable values from 1 through 8,000. 1. This data type is used to
store images with a variable
size but also in a limited
range. Space will occupy only
according to the size of
picture.

2. This data type can be used by


the hr department to store
the employee’s picture as an
identity but the space will
occupy according to the size
of picture.
3. This data type can be used by
school, college and university
database to store picture of
students but the space will
occupy according to the size
of picture.
Image or 1. This data type can be used to
varbinary(max) stored large size of images.
For example high resolution
pictures and scans
documents. The space will
occupy according to size of
picture because it is variable
in size.

2. This data type can also be


used to store employee’s
education scan documents,
experience certificates,
professional qualification,
and medical documents and
so on.

3. This data type can be used to


store student previous and
current record scan
documents, medical
certificates, birth certificate
etc.
Timestamp 1. This data type can be used to
store date with the
information change in
milliseconds.

2. This data type can be used


where the transactions
perform in a milliseconds and
the information of that
seconds is required.

3. This data type can be used in


software like in sports,
where a time is noted is
milliseconds like human race,
car race, swimming etc.
Uniqueidentifier 1. This data type can be used to
store the value which
globally unique.

You might also like