0% found this document useful (0 votes)
2 views6 pages

SQL Data Types

SQL data types are categorized into five groups: Character/String, Numeric, Date/Time, Binary, and Miscellaneous. Each category includes specific data types with defined characteristics, such as maximum lengths and formats. Understanding these data types is essential for effective database management and data manipulation.

Uploaded by

Gayu Ks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

SQL Data Types

SQL data types are categorized into five groups: Character/String, Numeric, Date/Time, Binary, and Miscellaneous. Each category includes specific data types with defined characteristics, such as maximum lengths and formats. Understanding these data types is essential for effective database management and data manipulation.

Uploaded by

Gayu Ks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

a shot of dev knowledge

SQL Data Types


Edpresso Team

🔊 Keep up to date

Sign up to the Edpresso newsletter


Stay up to date on the latest from Edpresso, with new shots, content, and announcements

Email

Get Offer

SQL data types are divided into five categories:

1. Character/String Data Types


2. Numeric Data Types
3. Date/Time Data Types
4. Binary Data Types
5. Miscellaneous Data Types

Char,Varchar,
Nchar,Narchar,
Text,Ntext

Char/String bit,smallint,int,
bigint,decimal,
real,numeric,
Numeric float

Datetime,
Date, Time,
SQL Data Date/Time Timestamp,
Types Year

Binary,
Binary Varbinary,
Varbinary(max),
image
Miscellaneous
Clob, Blob,
JSON, XML

SQL Data Types

1. Character/String Data Types


Character/Strings can be used to store strings like names, locations, etc. and even
large text files.

Data Type Description

Maximum 8000 character long fixed


CHAR
length string

Maximum 8000 character long vari-


VARCHAR
able length string

Maximum max character long variable


VARCHAR(max)
length string

Unicode Maximum 8000 character


NCHAR
long fixed length string

Unicode Maximum 8000 character


NVARCHAR
long variable length string

Unicode Maximum max character long


NVARCHAR(max)
variable length string

Maximum 2GB sized variable length


TEXT
string

2. Numeric Data Types


Numeric data types can be used to store exact or decimal numeric data, from very
small numbers in a bit or tinyint to very large numbers in a bigint .

Data Type Minimum Maximum

bit 0 1

tinyint 0 255

smallint -32,768 32,767

int -2,147,483,648 2,147,483,647

-9,223,372,036,854,775,8 9,223,372,036,854,775,80
bigint
08 7
Data Type Minimum Maximum

decimal -10^38 - 1 -10^38 - 1

real -3.40E + 38 3.40E + 38

numeric -10^38 +1 10^38 -1

float -1.79E + 308 1.79E + 308

3. Date/Time Data Types


Date/Time data types are used to store data and time objects. Storing a date as a
date/type object instead of a string can make it very easy to work with data at a later
point.

Data Type Description

Date and Time stored in the YYYY-MM-


Datetime
DD HH:MI:SS format

Date stored in the YYYY-MM-DD


Date
(/) format Log in Join for free

Time Time stored in the HH:MI:SS format

Number of seconds passed stored


Timestamp
since ‘1970-01-01 00:00:00’ UTC

Year stored in 2-digit (from 1970-2069)


Year
or 4-digit (from 1901 2155) format

4. Binary Data Types


Binary data types are used to store data in its binary form, instead of storing it as
strings, which can be a big factor in saving space.

Data Type Description

Maximum length of 8000 bytes fixed


BINARY
binary
Data Type Description

Maximum length of 8000 bytes vari-


VARBINARY
able binary

Maximum length of max bytes fixed


VARBINARY(max)
binary

Maximum 2GB sized variable length


NTEXT
binary

5. Miscellaneous Data Types


These data types are for special types of data as described below:

Data Type Description

CLOB Upto 2GB large character objects

BLOB For storing binary large objects

JSON For storing JSON objects

XML For storing XML objects

RELATED TAGS

sql data datetime timestamp

License: Creative Commons -Attribution -


ShareAlike 4.0 (CC-BY-SA 4.0)
(https://creativecommons.org/licenses/by-sa/4.0/)

Keep Exploring
How to create a database cursor in SQL
Data replication: Master-Slave

How to connect to an SQL database in PHP

(/)

Learn in-demand tech skills in half the time

LEARN

Courses

(/explore)

Early Access Courses

(/explore/early-access)

Edpresso

(/edpresso)

Blog

(/blog)

Pricing

(/unlimited)

Free Trial New

(/trial)

For Business

(/business)

CodingInterview.com (//codinginterview.com/)

SCHOLARS H IPS

For Students

(/github-students)

For Educators

(/github-educators)

CONTRIBUTE

Become an Author

(/authors)

Become an Affiliate
(/affiliate)

LEGAL

Privacy Policy

(/privacy)

Terms of Service

(/terms)

Business Terms of Service

(/enterprise-terms)

MORE

Our Team

(/team)

Careers (//jobs.lever.co/educative) Hiring

For Bootcamps (//try.educative.io/bootcamps)

Blog for Business

(/blog/enterprise)

Quality Commitment

(/quality)

FAQ

(/courses/educative-faq)

Press

(/press)

Contact Us

(/contactUs)

educativeinc)(//linkedin.com/company/educative-(//twitter.com/educativeinc)(//www.youtube.com/channel/UCT_8FqzTIr2Q1BOtvX_DPPw/?(//educativesess
inc/) sub_confirmation=1)

Copyright ©2021 Educative, Inc. All rights reserved.

You might also like