List:General Discussion« Previous MessageNext Message »
From:A. Brandic Date:May 26 1999 3:01pm
Subject:Re: SHOW COLUMNS confuses CHAR/VARCHAR
View as plain text  


On Wed, 26 May 1999, Paul DuBois wrote:

> At 9:47 AM -0500 5/26/99, A. Brandic wrote:
> >My view was that if you use a CHAR rather than a VARCHAR, execution of  a
> >query is faster.  Is this true, and how much faster?
> >I've done some test on a few tables with 15 coulms and 15000 rows (simple
> >selects and Joins) and there was a difference.  I guess on bigger DBs the
> >difference will be greter?  Am I right (or left:)).
> 
> I'm not really sure.  But you should be able to keep your table from
> turning into a varible length table by creating it like this:
> 
> create table Tab1 (
>   Code CHAR(8),
>   Bank CHAR(40),
>   Method CHAR(2),
>   Name CHAR(40)
> );
> 
> That way, you won't have any VARCHAR columns, and MySQL won't mess
> with your definition. :-)
>
Yeh, I've got that one too but I the thing is, if a column is 40 or over you 
rely 
want it to take up as less space as possible so VARCHAR would be OK (or 
eaven 25 or over).

Then, I'm new in all this, still learning and this Mailing List is 
helpping me a lot :).

My aim is to be able to set up a Linux machine as a Web Server with MySql on 
it and use PHP as the interface between the two.  I'm still at the Uni :).

Thnx.
Ajdin  
> 
> >
> >Ajdin
> >
> >
> >On Wed, 26 May 1999, Paul DuBois wrote:
> >
> >> At 8:49 AM -0500 5/26/99, kai@stripped wrote:
> >> >>Description:
> >> >The output of a
> >> >  show columns from TABLE
> >> >command has problems with CHAR and VARCHAR columns. The script in the
> next
> >> >section produces the following output:
> >> >
> >> >Field	Type	Null	Key	Default	Extra
> >> >Code	varchar(8)	YES		NULL
> >> >Bank	varchar(40)	YES		NULL
> >> >Method	char(2)	YES		NULL
> >> >Name	varchar(40)	YES		NULL
> >> >
> >> >Each VARCHAR column was created as a CHAR column, and the CHAR column
> was
> >> >created as a VARCHAR column.
> >> >
> >> >>How-To-Repeat:
> >> >Execute the following script:
> >> >
> >> >#!/bin/bash
> >> >set +x
> >> >
> >> >mysql -u root <<EOF
> >> >
> >> >drop database if exists bug;
> >> >create database bug;
> >> >use bug;
> >> >
> >> >create table Tab1 (
> >> >  Code CHAR(8),
> >> >  Bank CHAR(40),
> >> >  Method VARCHAR(2),
> >> >  Name CHAR(40)
> >> >);
> >> >
> >> >show columns from Tab1;
> >> >EOF
> >> >
> >> >>Fix:
> >> >	???
> >>
> >>
> >> MySQL silently changes CHAR(N) to VARCHAR(N) for N>=4 if you have any
> >>VARCHAR
> >> columns since by including such columns in your table, the records become
> >> variable-length anyway.
> >>
> >> Reference:
> >>
>
> >>http://www.mysql.com/Manual_chapter/manual_Reference.html#Silent_column_changes
> >>>>
> >> --
> >> Paul DuBois, paul@stripped
> >> Northern League Chronicles: http://www.snake.net/nl/
> >>
> >> ---------------------------------------------------------------------
> >> Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
> >> posting. To request this thread, e-mail mysql-thread3963@stripped
> >>
> >> To unsubscribe, send a message to the address shown in the
> >> List-Unsubscribe header of this message. If you cannot see it,
> >> e-mail mysql-unsubscribe@stripped instead.
> >>
> 
> 
> --
> Paul DuBois, paul@stripped
> Northern League Chronicles: http://www.snake.net/nl/
> 
Thread
SHOW COLUMNS confuses CHAR/VARCHARkai26 May
  • Re: SHOW COLUMNS confuses CHAR/VARCHARPaul DuBois26 May
    • Re: SHOW COLUMNS confuses CHAR/VARCHARA. Brandic26 May
      • Re: SHOW COLUMNS confuses CHAR/VARCHARPaul DuBois26 May
        • Re: SHOW COLUMNS confuses CHAR/VARCHARA. Brandic26 May