Solved

maximum size of VARCHAR2()

Posted on 2006-07-15
7
23,099 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 143

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
Webinar: Choosing a MySQL HA Solution

Join Percona’s Principal Technical Services Engineer, Marcos Albe as he presents Choosing a MySQL High Availability Solution on Thursday, June 29, 2017 at 10:00 am PDT / 2:00 pm EDT (UTC-7).

 

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 143

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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

717 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