Common SQL Data Types: by Leonamel Amolo

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 10

COMMON SQL

DATA TYPES
BY; LEONAMEL AMOLO
Sql data • In SQL the columns of a table are
defined to store a specific kind of value
such as numbers, dates, or text; these are
types called data types.  With over thirty types
of SQL server data types to choose
from, data types can seem intimidating,
but in reality, there are just a few
commonly used in databases.
• Once you understand data types in
general, it isn’t a complicated subject. 
You’ll also come to understand why there
is a need for data types and the reason
there so many varieties.
What are SQL Server Data Types?

For our example, we’ll talk


about a person.  If you were
Before we get into the data thinking about the
types used in SQL server, I information you could use
think it is important for to describe a person you
everyone to understand may think to collect their
what a data type is, and why name, birthdate, weight,
they are needed for use in and number of children. 
computers. For each of these attributes,
the data generally falls into
Data types define the characteristics of
the data that can be stored in a location
such as a database column.  A data type
defines the possible set of values that
How SQL are accepted.  For example, a type of 
INT which stands for integer in SQL
Types server can only accept whole numbers,
decimal values are not allowed.
Help
Here is a listing of some people and
their ages
Name Age

• John • 12
• Sue • Twenty three
• Bob • Twenty and four years
• Sally • VIII
• Roque • Otcho
Can you see the issue with these ages? 
They’re all in an inconsistent format. 
Not only are they hard to read, but
sorting and calculating the data is
difficult.  By using SQL Server data
types, which enforce the expected type
of data to be stored, we can achieve a
much better result.  Here is the same
table with the ages shown as integers
Name Age

• John • 12
• Sue • 23
• Bob • 24
• Sally •8
• Roque •8
When age is defined as an integer the expectation is data are
entered as whole numbers.
Also, without getting into technical details, you can see storing
the age as an integer takes up much less space than the age in the
first table.  This may not seem like a huge consideration with
small databases, but when working with data on smartphones or
“big data” scenarios, these considerations add up.
Once the system understands the data type, it can then sort the
data in an order that makes sense as well as perform calculations.
Thank you!

You might also like