WDN Logo

home-icon Home / MySQL / MySQL online tutorial – Column Types part 2

MySQL online tutorial – Column Types part 2

MySQL online tutorial - Column Types part 2

MySQL Text data type

Text can be fixed length (char) or variable length strings. Also, text comparisons can be case sensitive or insensitive depending on the type you choose.

  • CHAR(x): where x can range from 1 to 255.
  • VARCHAR(x): x ranges from 1 – 255
  • TINYTEXT: small text, case insensitive
  • TEXT: slightly longer text, case insensitive
  • MEDIUMTEXT: medium size text, case insensitive
  • LONGTEXT: really long text, case insensitive
  • TINYBLOB: Blob means a Binary Large OBject. You should use blobs for case sensitive searches.
  • BLOB: slightly larger blob, case sensitive.
  • MEDIUMBLOB: medium sized blobs, case sensitive.
  • LONGBLOB: really huge blobs, case sensitive.
  • ENUM: Enumeration data type have fixed values and the column can take only one value from the given set. The values are placed in parenthesis following ENUM declaration. An example, is the marital status column we encountered in employee_per table.
    m_status ENUM("Y", "N")
    

    Thus, m_status column will take only Y or N as values. If you specify any other value with the INSERT statement, MYSQL will not return an error, it just inserts a NULLvalue in the column.

  • SET: An extension of ENUM. Values are fixed and placed after the SET declaration; however, SET columns can take multiple values from the values provided. Consider a column with the SET data type as
    hobbies SET ("Reading", "Surfing", "Trekking", "Computing")
    

    You can have 0 or all the four values in the column.

    INSERT tablename (hobbies) values ("Surfing", "Computing");
    

Sponsored Links

Search

Your comments
Star icon IMPORTANT Have a question / problem? Click here to ask an expert.

Sponsored Links

Tips

How do I view a deleted web page?
Is there a way to view a deleted web page - one that is no longer available? Yes there is and the solution is quite simple. [more...]

Fact

Flash memory was invented by Dr. Fujio Masuoka when he was working at Toshiba. It was presented at the 1984 International Electron Devices Meeting (IEDM) and introduced commercially for the first time by IBM in 1988. [more...]

Share on Whats app Share on Facebook Share on Twitter Share on Google plus