Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please explain DataType Length to me???

Status
Not open for further replies.

chrigil

Programmer
Sep 23, 2003
178
GB
Can someone explain Data Type lengths to me?

From what I can tell the meaning of the word Length depends on the actual datatype being used. Is this correct?

For instance if I use a VARCHAR of length 200 it literally means 200 characters.

If I use an INT of Length 4 does this mean a maximum range of 0 to 9999, -9999 to 9999, or something else?

If I have a TEXT of Length 16 it seems to mean 16Bit or 65,536 characters. Is this correct?

It's quite confusing because having moved from Access to SQL Server (via MySQL) I seem to think that Access dealt mainly in Bits rather than specific field sizes.



Thanks in advance,

Chris
 
Chris,

Length can mean the number of characters, but also the number of bytes each datatype will take up.

In your example, varchar(200) will store upto 200 characters, however int will take up 4 bytes and store a number from -2,147,483,648 to 2,147,483,647.

Search Books online for Datatypes and this should clear things up for you.

Hope this helps.


Leigh Moore
Business Systems Manager
Vets4Pets Veterinary Group
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top