?
Solved

maximum size of VARCHAR2()

Posted on 2006-07-15
7
Medium Priority
?
23,110 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 60 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
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

770 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