MySQL data types

I got most of the information from the MySQL 5.0 reference manual. This is a great reference for all of the different datatypes availible in MySQL. I decided to focus on the char and varchar. I did this because as we discussed in class, these data type will be the "work horse" of our work with databases.

Char and Varchar

First of all, the char and varchar are string data types. This means that they hold many differnet forms of data but the data can not be easily manipulated. For example, number characters can be stored in a char or varchar but there are stored a characters not numbers and as so can not be manipulated in the same manner as a number stored as a number.

Char and varchar are declared with the amount of characters that will be in the field. An example would be varchar (20). This statement would create a row for a varchar that would hold upto 20 characters. Char and varchar can hold from 0 to 255 characters. If a char or varchar are declared with out specifying the length it will be automatically set to 255.

Working Example

This is a hard one to show a working example of on the web. I did find a few big web pages that run off MySQL and from what I can see, they all would have to use char or varchar to store the data. One example is One part of their site that would be interesting to learn about is the login from the webpage and having it connect to a database.