SQL Data Types

Filed Under: SQL

SQL Data Types define the type of value that can be stored in a table column. For example, if we want a column to store only integer values, then we can define its data type as int.

SQL Data Types

SQL data types can be broadly divided into following categories.

  1. Numeric data types such as int, tinyint, bigint, float, real, etc.
  2. Date and Time data types such as Date, Time, Datetime, etc.
  3. Character and String data types such as char, varchar, text, etc.
  4. Unicode character string data types, for example nchar, nvarchar, ntext, etc.
  5. Binary data types such as binary, varbinary, etc.
  6. Miscellaneous data types – clob, blob, xml, cursor, table, etc.

sql data types

SQL Data Types important points

  • Not all data types are supported by every relational database vendor. For example, Oracle database doesn’t support DATETIME and MySQL doesn’t support CLOB data type. So while designing database schema and writing SQL queries, make sure to check if the data types are supported or not.
  • Data types listed here doesn’t include all the data types, these are the most popularly used data types. Some relational database vendors have their own data types that might be not listed here. For example, Microsoft SQL Server has money and smallmoney data types but since it’s not supported by other popular database vendors, it’s not listed here.
  • Every relational database vendor has its own maximum size limit for different data types, you don’t need to remember the limit. Idea is to have the knowledge of what data type to be used in a specific scenario.

Let’s look into different categories of SQL data types in detail.

SQL Numeric Data Types

bigint-9,223,372,036, 854,775,8089,223,372,036, 854,775,807
decimal-10^38 +110^38 -1
numeric-10^38 +110^38 -1
float-1.79E + 3081.79E + 308
real-3.40E + 383.40E + 38

SQL Date and Time Data Types

DATEStores date in the format YYYY-MM-DD
TIMEStores time in the format HH:MI:SS
DATETIMEStores date and time information in the format YYYY-MM-DD HH:MI:SS
TIMESTAMPStores number of seconds passed since the Unix epoch (‘1970-01-01 00:00:00’ UTC)
YEARStores year in 2 digits or 4 digit format. Range 1901 to 2155 in 4-digit format. Range 70 to 69, representing 1970 to 2069.

SQL Character and String Data Types

CHARFixed length with a maximum length of 8,000 characters
VARCHARVariable-length storage with a maximum length of 8,000 characters
VARCHAR(max)Variable-length storage with provided max characters, not supported in MySQL
TEXTVariable-length storage with maximum size of 2GB data

Note that all the above data types are for character stream, they should not be used with Unicode data.

SQL Unicode Character and String Data Types

NCHARFixed length with maximum length of 4,000 characters
NVARCHARVariable-length storage with a maximum length of 4,000 characters
NVARCHAR(max)Variable-length storage with provided max characters
NTEXTVariable-length storage with a maximum size of 1GB data

Note that above data types are not supported in MySQL database.

SQL Binary Data Types

BINARYFixed length with a maximum length of 8,000 bytes
VARBINARYVariable-length storage with a maximum length of 8,000 bytes
VARBINARY(max)Variable-length storage with provided max bytes
IMAGEVariable-length storage with maximum size of 2GB binary data

SQL Miscellaneous Data Types

CLOBCharacter large objects that can hold up to 2GB
BLOBFor binary large objects
XMLfor storing XML data
JSONfor storing JSON data

That’s all for a quick roundup on SQL data types.

Reference: Oracle Database Data Types, MySQL Data Types


  1. Milt says:

    Thank you, informative and to the point.

  2. Shivansh says:

    Where is enum

  3. Bhargav says:

    Thank you

  4. ezhil says:

    what is the data type for CSE5001

    1. Keerthi says:


    2. Suraj says:

      Char(7); OR Varchar

  5. Gowthami says:

    How to sort column VALUES in ASC order a column

    1. Pankaj says:

      Use “Order by ASC” clause at the end of the select query.

    2. YOurBRo says:

      just use ORDER BY at last no need to write ASC

  6. prasanna lakshmi says:

    some columns like salary will not take int ,smallint data types .it takes only char and varchar why???

    1. Ken says:

      If you are using a decimal point, float is the correct data type.

      1. Suraj says:

        Yes its correct data type but if you want store precious value then you can use ‘real’ datatype.

  7. Sylvester Marshall says:

    Hi Pankaj,

    The tutorial contents and the graphical presentation are absolutely fantastic. The amount of efforts you have taken is highly appreciated and I would like to express my sincere gratitude. God Bless you dear !!

    1. Samuel says:

      Thank you for this useful material. Be blessed always
      I came a little late but still have benefited.

  8. Rajaram says:

    Good Evening Shri.Pankaj Sir,

    very very useful & beneficial of your SQL lecture.
    Great thanks full for your Guide in SQL study materials.

    by Rajaram

  9. Saurabh Rawat says:

    Hello everyone here
    I am new at sql
    How can i insert data into a table which contain both Character and letter (For eg A001)
    Which datatype should i use here. Please let me know

    1. Pankaj says:

      Use varchar or varchar2 for string data.

    2. Ajaykumar Singh says:

      use ‘varchar(length)’ datatype

  10. Mr SQL says:

    Type BIT is not a numeric data type, its binary. Also it is no longer part of SQL standard. So better to remove it.
    Type YEAR does not exist in SQL standard. Also never use year numbers with only 2 digits (remember year2k bug?)

    You miss the type BOOLEAN which can have values true or false. It is fundamentally different from BIT.
    You miss the type INTERVAL of which there are 2 basic ones: INTERVAL SECONDS (can include fractions) and INTERVAL MONTHS.

    Type TEXT and NTEXT are old synonyms for CLOB, so use CLOB (or CHARACTER LARGE OBJECT).
    Type IMAGE is an old synonym for BLOB, so use BLOB (or BINARY LARGE OBJECT).

  11. sadiqullah says:

    thank’s so much

  12. Blabla says:

    Very good my son..
    God bless you

  13. Shirajul says:


    Is it possible to enter an Array for a value in a table?

    Is there an ARRAY column type?

    Kind Regards,

    1. Sew says:

      But why?? I think better idea is create another table and make refference

Comments are closed.

Generic selectors
Exact matches only
Search in title
Search in content