Reply
Why does CHAR columns come out as VARCHAR ones
Old 10-25-2006, 01:51 AM Why does CHAR columns come out as VARCHAR ones
Skilled Talker

Posts: 61
I have just tried to set the below table in a MYSQL database, but when I do the show columns from, all of the columns of which I have set to with 'CHAR', are all shown as 'VARCHAR", and the table is listed as 'dynamic' rather than 'fixed'

What is going on?
Is there some variable of which is confusing the system in some way?

CREATE TABLE watchregcontact (
wtcctsp TIMESTAMP,
wtccip CHAR(20),
wtccjacn INT UNSIGNED,
wtccrow BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
wtccdte DATETIME,
wtccmt CHAR(10),
wtccmr CHAR(8),
wtcchead CHAR(50),
wtccmbod TEXT,
wtccpd DATETIME,
wtccpb TINYTEXT,
wtccfd DATETIME,
wtccfb TEXT,
wtccpi CHAR(20),
wtccpu CHAR(30),
wtccfi CHAR(20),
wtccfu CHAR(30)
);
TRANZIT JIM is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 10-29-2006, 07:17 AM Re: Why does CHAR columns come out as VARCHAR ones
chrishirst's Avatar
Super Moderator

Posts: 15,326
Location: Blackpool. UK
if you have several CHAR columns with differing widths MySQL will optimise them all as VARCHAR types. This will save space in the database as CHAR columns are padded with spaces to fill the specified width but VARCHAR are not.
So a 10 character string in a 50 wide CHAR column will take up 50 bytes but as a VARCHAR will only take up 11 bytes
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System | Bits & Bobs
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Why does CHAR columns come out as VARCHAR ones
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12270 seconds with 12 queries