#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 1999
    Posts
    3
    Rep Power
    0
    Hi, im working with perl and dbi.
    Is there any select clause i can use to get the size of a field in bytes?

    Tnx in advance.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    British Columbia
    Posts
    11
    Rep Power
    0
    The byte size of a field generally depends upon the datatype of the column which you can find out with
    SHOW COLUMNS FROM tbl_tablename;
    1 byte: TINYINT, YEAR
    2 bytes: SMALLINT
    3 bytes: MEDIUMINT, TIME, DATE
    4 bytes: INT, TIMESTAMP,FLOAT etc.
    string types are one byte per character plus one byte for the terminator (unless it's a multibyte character set).
    SELECT LENGTH (string);
    returns the number of characters.

Similar Threads

  1. return value from 3 fields into 1 field
    By denali in forum MS SQL Development
    Replies: 1
    Last Post: December 19th, 2003, 08:44 AM
  2. Validating a field with multiple criteria...
    By brotherloco in forum Java Help
    Replies: 0
    Last Post: October 29th, 2003, 08:40 AM
  3. How to guess the size of the fields ??
    By fchaves in forum C Programming
    Replies: 0
    Last Post: August 25th, 2003, 09:21 AM
  4. Adding Values to a selected field only
    By vtaylor in forum MySQL Help
    Replies: 2
    Last Post: April 9th, 2002, 09:20 AM
  5. Database design question
    By mcsimon in forum Dev Shed Lounge
    Replies: 2
    Last Post: August 5th, 2001, 01:17 AM

IMN logo majestic logo threadwatch logo seochat tools logo