1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Understanding how SQL databases work


4 of 4

SQL Data Types
Each column can only contain one type of data which we must define. An example of what this means is; in our age column we use a number. We could not change Kelly's entry to "twenty-six" if we had defined that column to be a number. The main data types are numbers, date/time, text, and binary. Although these have many subcategories, we will just touch on the most common types that you will use in this tutorial.

INTEGER- This stores whole numbers, both positive and negative. Some examples are 2, 45, -16 and 23989. In our example, the age category could have been integer.

FLOAT- This stores numbers when you need to use decimals. Some examples would be 2.5, -.664, 43.8882, or 10.00001.

DATETIME- This stores a date and time in the format YYYY-MM-DD HH:MM:SS

VARCHAR- This stores a limited amount of text or single characters. In our example, the name column could have been varcar (short for variable character)

BLOB- This stores binary data other than text, for example file uploads.

  1. About.com
  2. Technology
  3. PHP / MySQL
  4. Learn MySQL
  5. SQL tutorial - MySQL Tutorial - SQL Data Types

©2014 About.com. All rights reserved.