The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Special Forums > UNIX and Linux Applications
Google UNIX.COM


UNIX and Linux Applications Questions involving software not covered by other forum go here. This includes Databases and Middleware.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
MySQL article - Sun and MySQL: How It Stacks Up for Developers iBot UNIX and Linux RSS News 0 02-28-2008 07:20 PM
MySQL conflicts with mysql-3.23.58-16.RHEL3.1 johnveslin Linux 2 07-17-2007 03:49 AM
How to replace any char with newline char. mightysam Shell Programming and Scripting 4 06-15-2006 04:46 AM
mysql would not start: missing mysql.sock xnightcrawl UNIX for Advanced & Expert Users 2 05-26-2006 07:06 AM
MySQL problem >> missing mysql.sock _hp_ UNIX for Advanced & Expert Users 8 11-03-2002 10:44 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-06-2007
Registered User
 

Join Date: Jul 2007
Posts: 51
Mysql CHAR vs VARCHAR

Looking for any advise from a DBA/DA. When should you use CHAR and when should you use VARCHAR when designing a table. From my readings seems like VARCHAR will accept any length string even though you define a length to it, so I setup gadget VARCHAR(10) I could actually put something with 20 characters in there. Thanks for any advise on this. Bill
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 11-06-2007
Registered User
 

Join Date: Nov 2007
Posts: 4
RE: Mysql CHAR vs VARCHAR

Actually a VARCHAR(10) will only allow up to 10 characters and no more.

The main difference between CHAR and VARCHAR is how data is stored in the column. The length of a CHAR column is fixed and when CHAR values are stored, they are right-padded with spaces to the specified length. In contrast to CHAR, VARCHAR values are stored using only as many characters as are needed.

Please see the MySQL docs for more details:
MySQL AB :: MySQL 5.0 Reference Manual :: 10.4.1 The CHAR and VARCHAR Types

Cheers!
Nate
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0