Link to home
Start Free TrialLog in
Avatar of javamate06
javamate06

asked on

maximum size of VARCHAR2()

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?
ASKER CERTIFIED SOLUTION
Avatar of Harisha M G
Harisha M G
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In Oracle: 4000
In MSSQL (2000): 8000
in MSSQL (2005):  MAX = 2GB

In all the databases, there is NO waste of space.
Avatar of cdemir
cdemir

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.
Avatar of javamate06

ASKER

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?
yes, using CHAR(4000) will allocate each time 4000 characters
angel is correct..

>> but it does affect sorts.
Performence can be increased slightly by creating index on that column
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!