dbTalk Databases Forums  

Any way to get max size of VARCHAR column?

comp.databases.mysql comp.databases.mysql


Discuss Any way to get max size of VARCHAR column? in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John Nagle
 
Posts: n/a

Default Any way to get max size of VARCHAR column? - 07-09-2010 , 05:06 PM






Is there any way to get the maximum size of a VARCHAR column?
Some function like "COLUMN_WIDTH(columname)", perhaps?

LENGTH gives the size of the contents, not the size limit of
the column, for VARCHAR columns. The output from DESCRIBE
requires parsing. The intent is to find out if an item is too
big before it goes into a file for a LOAD DATA INFILE and
aborts the whole load.

John Nagle

Reply With Quote
  #2  
Old   
JRough
 
Posts: n/a

Default Re: Any way to get max size of VARCHAR column? - 07-09-2010 , 07:30 PM






On Jul 9, 2:06*pm, John Nagle <na... (AT) animats (DOT) com> wrote:
Quote:
* *Is there any way to get the maximum size of a VARCHAR column?
Some function like "COLUMN_WIDTH(columname)", perhaps?

* * LENGTH gives the size of the contents, not the size limit of
the column, for VARCHAR columns. *The output from DESCRIBE
requires parsing. *The intent is to find out if an item is too
big before it goes into a file for a LOAD DATA INFILE and
aborts the whole load.

* * * * * * * * * * * * * * * * John Nagle
I'm not sure what you are asking?
The size of the varchar(_) column you can find through mysql query
browser.
You find it in the data structure. You can see the databases tables
in the schema section.
You click on your table and copy the create table contents to the
clipboard then paste it into a query browser and you can see what the
size of the field is.
If you mean you have to check that all the data fits into that column
you have to loop through the rows and check them using file handling
routines.
Look up file handling in the php manual to know how to read to and
write to a file. You have to read each row and put the data into an
array to loop through the fields in the rows to check the data.

Reply With Quote
  #3  
Old   
Axel Schwenke
 
Posts: n/a

Default Re: Any way to get max size of VARCHAR column? - 07-09-2010 , 07:38 PM



John Nagle <nagle (AT) animats (DOT) com> wrote:
Quote:
Is there any way to get the maximum size of a VARCHAR column?
Some function like "COLUMN_WIDTH(columname)", perhaps?
SHOW [FULL] FIELDS ?
Or maybe you like INFORMATION_SCHEMA.COLUMNS better?

http://dev.mysql.com/doc/refman/5.1/...mns-table.html


XL

Reply With Quote
  #4  
Old   
John Nagle
 
Posts: n/a

Default Re: Any way to get max size of VARCHAR column? - 07-09-2010 , 08:01 PM



On 7/9/2010 4:30 PM, JRough wrote:
Quote:
On Jul 9, 2:06 pm, John Nagle<na... (AT) animats (DOT) com> wrote:
Is there any way to get the maximum size of a VARCHAR column?
Some function like "COLUMN_WIDTH(columname)", perhaps?

LENGTH gives the size of the contents, not the size limit of
the column, for VARCHAR columns. The output from DESCRIBE
requires parsing. The intent is to find out if an item is too
big before it goes into a file for a LOAD DATA INFILE and
aborts the whole load.

John Nagle

I'm not sure what you are asking?
No, you're not.

Quote:
The size of the varchar(_) column you can find through mysql query
browser.
You find it in the data structure. You can see the databases tables
in the schema section.
Yes, I know that.

What I want is to get the length of the field within SQL, so I
can use it in SQL expressions. It would be useful to put that
number in an SQL variable for use with LEFT during INSERT.

Quote:
You click on your table and copy the create table contents to the
clipboard then paste it into a query browser and you can see what the
size of the field is.

Look up file handling in the php manual
PHP?

John Nagle

Reply With Quote
  #5  
Old   
Captain Paralytic
 
Posts: n/a

Default Re: Any way to get max size of VARCHAR column? - 07-10-2010 , 08:07 AM



On Jul 10, 12:30*am, JRough <jlro... (AT) yahoo (DOT) com> wrote:
Quote:
On Jul 9, 2:06*pm, John Nagle <na... (AT) animats (DOT) com> wrote:

* *Is there any way to get the maximum size of a VARCHAR column?
Some function like "COLUMN_WIDTH(columname)", perhaps?

* * LENGTH gives the size of the contents, not the size limit of
the column, for VARCHAR columns. *The output from DESCRIBE
requires parsing. *The intent is to find out if an item is too
big before it goes into a file for a LOAD DATA INFILE and
aborts the whole load.

* * * * * * * * * * * * * * * * John Nagle

I'm not sure what you are asking?
The size of the varchar(_) column you can find through mysql query
browser.
You find it in the data structure. *You can see the *databases tables
in the schema section.
You click on your table and copy the create table contents to the
clipboard then paste it into a query browser and you can see what the
size of the field is.
If you mean you have to check that all the data *fits into that column
you have to loop through the rows and check them using file handling
routines.
Look up file handling in the php manual to know how to read to and
write to a file. *You have to read each row and put the data into an
array to loop through the fields in the rows to check the data.
Now I've seen everything, JRough trying to help someone else!

Reply With Quote
Reply




Thread Tools
Display Modes

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.