Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
SQL Data Types: A Comprehensive Guide - SQL Data Types

SQL Data Types: A Comprehensive Guide

Posted on January 2, 2025March 28, 2025 By Rishabh saini No Comments on SQL Data Types: A Comprehensive Guide

SQL Data Types

Data types in SQL define the kind of data a column in a database table can hold. They are fundamental to structuring data effectively and ensuring its integrity. For instance, if you want a table column to store textual data, you’ll declare a string data type for it. SQL data types are primarily categorized into three groups:

  • String Data Types
  • Numeric Data Types
  • Date and Time Data Types

Below, we explore these categories with details specific to popular database systems: MySQL, SQL Server, and Oracle.

Complete Python Course with Advance topics:-Click here

SQL Data Types: A Comprehensive Guide
SQL Data Types: A Comprehensive Guide

MySQL Data Types

MySQL provides a wide array of data types to handle various data formats. The examples here are based on MySQL 8.0.

MySQL String Data Types

  • CHAR(size): Fixed-length strings, holding up to 255 characters. Default size is 1.
  • VARCHAR(size): Variable-length strings, supporting up to 65,535 characters.
  • BINARY(size): Fixed-length binary byte strings, similar to CHAR.
  • VARBINARY(size): Variable-length binary byte strings, similar to VARCHAR.
  • TEXT: Holds strings up to 65,535 bytes. Variants include:
    • TINYTEXT (up to 255 characters)
    • MEDIUMTEXT (up to 16,777,215 characters)
    • LONGTEXT (up to 4,294,967,295 characters).
  • ENUM(val1, val2, …): Allows storing a single value from a predefined list. Maximum of 65,535 values.
  • SET(val1, val2, …): Allows storing multiple values from a predefined list, with up to 64 options.

MySQL Numeric Data Types

  • BIT(size): A bit-value type, storing 1–64 bits.
  • INT(size)/INTEGER(size): Standard integer type. Signed range: -2,147,483,648 to 2,147,483,647.
  • FLOAT(size, d): Floating-point numbers with customizable precision.
  • DOUBLE(size, d): Larger floating-point numbers with extended precision.
  • DECIMAL(size, d): Fixed-point numbers with a maximum size of 65 and a precision of 30.
  • BOOL: Boolean values (true or false).

MySQL Date and Time Data Types

  • DATE: Stores dates in the format YYYY-MM-DD.
  • DATETIME(fsp): Date and time combination (YYYY-MM-DD hh:mm:ss).
  • TIMESTAMP(fsp): Stores timestamps, based on Unix epoch time.
  • TIME(fsp): Stores time in hh:mm:ss format.
  • YEAR: Stores four-digit year values (e.g., 1901 to 2155).

SQL Server Data Types

SQL Server supports a robust set of data types tailored for modern applications.

SQL Server String Data Types

  • char(n): Fixed-width strings, up to 8,000 characters.
  • varchar(n): Variable-width strings, up to 8,000 characters.
  • varchar(max): Variable-width strings, up to 1,073,741,824 characters.
  • nchar: Fixed-width Unicode strings, up to 4,000 characters.
  • nvarchar: Variable-width Unicode strings, up to 4,000 characters.
  • text: Legacy data type for large text blocks (up to 2GB).

SQL Server Numeric Data Types

  • bit: Holds binary values (0, 1, or NULL).
  • tinyint: Whole numbers from 0 to 255.
  • smallint: Whole numbers from -32,768 to 32,767.
  • int: Whole numbers from -2,147,483,648 to 2,147,483,647.
  • bigint: Whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
  • float(n): Floating-point numbers with high precision.
  • money: Stores monetary values with up to four decimal places.

SQL Server Date and Time Data Types

  • datetime: Date-time combination with an accuracy of 3.33 milliseconds.
  • datetime2: Extended precision for date-time, accurate to 100 nanoseconds.
  • date: Date-only format.
  • time: Time-only format with 100-nanosecond accuracy.

Oracle Data Types

Oracle offers a rich set of data types designed to handle a variety of data storage requirements.

Oracle String Data Types

  • CHAR(size): Fixed-length strings, up to 2,000 bytes.
  • VARCHAR2(size): Variable-length strings, up to 4,000 bytes.
  • NCHAR(size): Fixed-length national character strings.
  • NVARCHAR2(size): Variable-length Unicode strings.

Oracle Numeric Data Types

  • NUMBER(p, s): Precision (p) up to 38 digits, scale (s) ranging from -84 to 127.
  • FLOAT(p): Floating-point numbers, with precision up to 126.
  • BINARY_FLOAT/BINARY_DOUBLE: Optimized floating-point numbers with binary precision.

Oracle Date and Time Data Types

  • DATE: Date and time combination with a range from January 1, 4712 BC, to December 31, 9999 AD.
  • TIMESTAMP: Extended date-time precision with optional time zones.

Oracle Large Object Data Types (LOB Types)

  • BLOB: Binary large objects, up to 4GB.
  • CLOB/NCLOB: Large character objects, supporting up to 4GB.
  • BFILE: Binary data stored externally, up to 4GB.

Choosing the Right Data Type

Selecting the right data type is critical for efficient storage, faster queries, and ensuring data consistency. Consider the following factors:

  • The nature of data (e.g., textual, numerical, or temporal).
  • Storage size and performance.
  • The database system’s specific features and limitations.

Download New Real Time Projects :-Click here
PHP PROJECT:- CLICK HERE


sql data types with examples
sql data types pdf
mysql data types
oracle sql data types
postgresql data types
data types in sql w3schools
sql data types with examples pdf
number data type in sql
sql data types in dbms
sql constraints

Post Views: 1,912
SQL Tutorial Tags:binary data types, bulit-in data types, data types, data types in c#, data types in java, data types in mysql, data types in plsql, data types in sql, data types in sql server, data types of oracle, data types tsql, learn data types, mysql data types, numeric data types, numeric data types in mysql, oracle data types, sql data types, string data types, system data types, t sql data types, t-sql - data types, types, types of databases, what are data types in sql?

Post navigation

Previous Post: SQL Tutorial: A Comprehensive Guide
Next Post: Hotel Management System Using Python Tkinter GUI

More Related Articles

IN vs EXISTS in SQL IN vs EXISTS in SQL: A Complete Guide SQL Tutorial
WHERE Condition in SQL WHERE Condition in SQL SQL Tutorial
SQL ALTER TABLE SQL ALTER TABLE: A Comprehensive Guide SQL Tutorial

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may also like

  1. Comprehensive Guide to SQL Syntax and Key Commands
  2. Rename Database in SQL Like a Pro : A Comprehensive Guide
  3. SQL WITH Clause
  4. SQL UPDATE with JOIN
  5. Understanding SQL CROSS JOIN with Examples
  6. IN vs EXISTS in SQL: A Complete Guide

Most Viewed Posts

  1. Top Large Language Models in 2025
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. login form in php and mysql , Step-by-Step with Free Source Code
  4. Flipkart Clone using PHP And MYSQL Free Source Code
  5. News Portal Project in PHP and MySql Free Source Code
  6. User Login & Registration System Using PHP and MySQL Free Code
  7. Top 10 Final Year Project Ideas in Python
  8. Blog Site In PHP And MYSQL With Source Code || Best Project
  9. Online Bike Rental Management System Using PHP and MySQL
  10. E learning Website in php with Free source code
  • AI
  • ASP.NET
  • Blockchain
  • ChatCPT
  • code Snippets
  • Collage Projects
  • Data Science Project
  • Data Science Tutorial
  • DBMS Tutorial
  • Deep Learning Tutorial
  • Final Year Projects
  • Free Projects
  • How to
  • html
  • Interview Question
  • Java Notes
  • Java Project
  • Java Script Notes
  • JAVASCRIPT
  • Javascript Project
  • JSP JAVA(J2EE)
  • Machine Learning Project
  • Machine Learning Tutorial
  • MySQL Tutorial
  • Node.js Tutorial
  • PHP Project
  • Portfolio
  • Python
  • Python Interview Question
  • Python Projects
  • PythonFreeProject
  • React Free Project
  • React Projects
  • Spring boot
  • SQL Tutorial
  • TOP 10
  • Uncategorized
  • Agentic RAG AI System Using Python – Complete Final Year Project Guide
  • AI-Powered Online Examination System with Face Detection Using PHP & MySQL
  • Real-Time Medical Queue & Appointment System with Django
  • Online Examination System in PHP with Source Code
  • AI Chatbot for College and Hospital

Most Viewed Posts

  • Top Large Language Models in 2025 (8,628)
  • Online Shopping System using PHP, MySQL with Free Source Code (5,248)
  • login form in php and mysql , Step-by-Step with Free Source Code (4,908)

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme