Solved

maximum size of VARCHAR2()

Posted on 2006-07-15
7
23,017 Views
Last Modified: 2008-06-04
What is the maximum size of VARCHAR2(),
Is it 3000?
If yes,
If I create table with VARCHAR2(3000) is it wasting the memory or it will cover only what space I used?


For example,

         Create table x (name VARCHAR2(3000));

 and

          Insert into x (name) values (‘SQL’);

I used only 3, Does this waste 2997 or not?
0
Comment
Question by:javamate06
7 Comments
 
LVL 37

Accepted Solution

by:
Harisha M G earned 30 total points
ID: 17116765
Hi javamate06, in which database ? Oracle ?

If you use VARCHAR2, it won't waste any space.

http://www.ss64.com/orasyntax/datatypes.html


---
Harish
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17116777
In Oracle: 4000
In MSSQL (2000): 8000
in MSSQL (2005):  MAX = 2GB

In all the databases, there is NO waste of space.
0
 
LVL 3

Expert Comment

by:cdemir
ID: 17116784
in Oracle;

>> What is the maximum size of VARCHAR2(),
varchar2(4000)

>> I used only 3, Does this waste 2997 or not?
No. Allowing extra space in a VARCHAR column is usually harmless — after all, the definition doesn’t affect the storage — but it does affect sorts.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:javamate06
ID: 17116805
thanks mgh_mgharish

You said "If you use VARCHAR2, it won't waste any space.". So, is there a type like VARCHAR2 wasiting spaces by initializing the size?
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17116807
yes, using CHAR(4000) will allocate each time 4000 characters
0
 
LVL 37

Expert Comment

by:Harisha M G
ID: 17116822
angel is correct..

>> but it does affect sorts.
Performence can be increased slightly by creating index on that column
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 17116880
Hi javamate06,
performance is also affected by having to store the length of the data with the column...
but that's not usually a concern if your storing a lot of data...

a general rules of thumb from db2/udb
if its less than 30 bytes define it as char to its maximum value
if it generally varies by less than 10-20 bytes use char


hth
 


Cheers!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Insert Query Help 16 87
MSSQL Convert Char To Date 4 43
MySQL ERROR 1045 (28000) 2 40
SQL BACKUP - 2008 R2 8 12
Database tuning – How to start and what to tune. This question is frequently asked by many people, both online and offline. There is no hard and fast rule-of-thumb for performance tuning, however, before beginning the tuning process one should a…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now