View All
View All
View All
View All
View All
View All
View All
View All
View All
View All
View All
View All

Difference Between VARCHAR and VARCHAR2

By Mukesh Kumar

Updated on Apr 22, 2025 | 6 min read | 1.4k views

Share:

What if using the wrong data type caused unexpected behavior in your Oracle database? That’s exactly what can happen if you confuse VARCHAR with VARCHAR2.

In SQL, both VARCHAR and VARCHAR2 are used to store variable-length character strings. However, in Oracle, there's a crucial distinction: VARCHAR is a reserved keyword and behaves differently across versions, while VARCHAR2 is the standard and recommended data type for storing variable-length character data.

The most important difference? VARCHAR is deprecated and might change behavior in future Oracle versions, whereas VARCHAR2 is fully supported and stable.

In this blog, we’ll break down what VARCHAR and VARCHAR2 are, how they differ in syntax and storage, why Oracle prefers VARCHAR2, and when and how to use it correctly in your database applications.

Explore our Data Science and Machine Learning Courses to master database management and advanced data techniques today!

Key Differences Between VARCHAR and VARCHAR2

Parameter

VARCHAR

VARCHAR2

Full Form Variable Character Variable Character 2
Usage in Oracle Reserved for future use Actively used and recommended
Current Support Deprecated and discouraged Fully supported
Default Mapping Internally maps to VARCHAR2 Native Oracle datatype
Storage Allocation Variable-length (same as VARCHAR2) Variable-length (stores only actual data size)
Maximum Size Same as VARCHAR2 (treated as such) Up to 4,000 bytes in SQL, 32,767 in PL/SQL
NULL Handling Treated the same as VARCHAR2 (currently) NULL and empty string treated as the same
Future Compatibility May change in future Oracle versions Safe and consistent across versions
ANSI Compliance Based on ANSI SQL standard Oracle-specific extension
Documentation Status Not recommended in Oracle documentation Well-documented and supported
Preferred For Use? No Yes
Semantic Support Byte semantics only Byte and character semantics
Behavior Stability Unstable (may change) Stable

Unlock the power of AI and data-driven decision-making with these cutting-edge courses:

What is VARCHAR?

The VARCHAR data type stands for Variable Character and is used to store character strings of variable length. It allows you to define a maximum number of characters, but only uses storage space for the actual length of the data inserted—making it more efficient than fixed-length types like CHAR.

VARCHAR(20)

This allows up to 20 characters, but if you store "Hello", it only uses space for 5 characters (plus a byte for length).

Also Read - Difference Between Deep Learning and NLPDifference Between IOT and AI

Coverage of AWS, Microsoft Azure and GCP services

Certification8 Months

Job-Linked Program

Bootcamp36 Weeks

What is VARCHAR2?

VARCHAR2 is Oracle’s official data type for storing variable-length character strings. Like VARCHAR, it allows you to define a maximum length, but it dynamically allocates storage based on the actual length of the input data.

VARCHAR2(50)

This stores strings up to 50 characters, but only consumes space for the characters you input—plus 1 or 2 bytes to store the length, depending on how many bytes the string contains.

Top Blogs to Explore - Difference Between Data Science and Artificial Intelligence

Why It's Preferred Over VARCHAR

Oracle explicitly recommends VARCHAR2 because:

  • VARCHAR is reserved for future changes and may not always behave the same.
  • VARCHAR2 is guaranteed to behave consistently across versions.
  • It's optimized for performance and fully documented for production use.

In short: VARCHAR2 is safe, stable, and future-proof, making it the preferred choice for storing variable-length strings in Oracle.

Must Check - Difference Between Data Science and Data AnalyticsDifference Between Machine Learning and Data Analytics

Common Use Cases for VARCHAR2

VARCHAR2 is one of the most frequently used datatypes in Oracle-based applications, thanks to its efficiency, flexibility, and support for variable-length text storage. Here are some real-world use cases:

1. Storing Usernames or Email Addresses

These vary in length but rarely exceed a certain limit.

username VARCHAR2(50),

email VARCHAR2(100)

2. Product Descriptions in E-commerce

Descriptions can be short or long, and VARCHAR2 saves space by storing only actual content.

product_description VARCHAR2(1000)

3. Customer Feedback or Comments

User-submitted content often varies in length and is a perfect fit for VARCHAR2.

customer_review VARCHAR2(2000)

4. Storing URLs or File Paths

These entries are variable by nature and benefit from dynamic length allocation.

image_url VARCHAR2(255)

5. Mobile Numbers or Contact Details

While consistent in format, they’re stored as strings to preserve formatting and prevent mathematical operations.

contact_number VARCHAR2(15)

6. Employee Designation or Role

Job titles differ greatly in length and frequency, making fixed-length storage inefficient.

designation VARCHAR2(100)

7. Audit Trail and Logging

For storing metadata or logs in admin/audit tables.

action_summary VARCHAR2(500),

ip_address VARCHAR2(45)

8. Flexible Metadata Fields

When a field's content is semi-structured or varies across entries.

custom_metadata VARCHAR2(2000)

Explore Now: Difference Between AI and Human IntelligenceDifference Between Bias and Variance

Conclusion: Which One Should You Use?

If you’re working with Oracle databases, the answer is clear—always use VARCHAR2, never VARCHAR.

While both may behave the same today, VARCHAR is a reserved keyword and could be redefined in future Oracle releases. Using it risks unexpected behavior, compatibility issues, and unnecessary maintenance headaches down the line.

VARCHAR2, on the other hand, is:

  • Fully supported and documented by Oracle
  • Stable across all versions
  • Optimized for variable-length character data
  • Capable of handling both byte and character semantics

From a performance, compatibility, and future-proofing perspective, VARCHAR2 is the only safe and recommended choice.

Similar Reads: Explore our Top Difference Between Blogs

Boost your career with our popular Software Engineering courses, offering hands-on training and expert guidance to turn you into a skilled software developer.

Master in-demand Software Development skills like coding, system design, DevOps, and agile methodologies to excel in today’s competitive tech industry.

Stay informed with our widely-read Software Development articles, covering everything from coding techniques to the latest advancements in software engineering.

Frequently Asked Questions

1. What is the primary difference between VARCHAR and VARCHAR2 in Oracle?

2. Why does Oracle recommend using VARCHAR2 over VARCHAR?

3. How does Oracle handle empty strings in VARCHAR2 columns?

4. What are the maximum lengths for VARCHAR2 columns in Oracle?

5. What is the difference between VARCHAR2(10) and VARCHAR2(10 CHAR)?

6. Is it advisable to define VARCHAR2 columns with large sizes, like VARCHAR2(4000), if only small strings are stored?

7. Can VARCHAR2 columns be indexed in Oracle?

8. How does Oracle compare VARCHAR2 values?

9. Is there any performance difference between CHAR and VARCHAR2 in Oracle?

10. Can VARCHAR2 columns be used in partitioned tables?

11. Is it possible to change a column from VARCHAR to VARCHAR2 in an existing Oracle table?

Mukesh Kumar

188 articles published

Get Free Consultation

+91

By submitting, I accept the T&C and
Privacy Policy

India’s #1 Tech University

Executive PG Certification in AI-Powered Full Stack Development

77%

seats filled

View Program

Top Resources

Recommended Programs

upGrad

AWS | upGrad KnowledgeHut

AWS Certified Solutions Architect - Associate Training (SAA-C03)

69 Cloud Lab Simulations

Certification

32-Hr Training by Dustin Brimberry

upGrad KnowledgeHut

upGrad KnowledgeHut

Angular Training

Hone Skills with Live Projects

Certification

13+ Hrs Instructor-Led Sessions

upGrad

upGrad KnowledgeHut

AI-Driven Full-Stack Development

Job-Linked Program

Bootcamp

36 Weeks