1. Home
  2. Computing & Technology
  3. PHP / MySQL

Understanding how SQL databases work

By Angela Bradley, About.com

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.

Index: Understanding how SQL databases work

  1. Understanding MySQL
  2. What are SQL tables?
  3. Understanding SQL Relational Databases
  4. SQL Data Types

4 of 4

Explore PHP / MySQL

More from About.com

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Learn MySQL
  5. SQL tutorial - MySQL Tutorial - SQL Data Types

©2008 About.com, a part of The New York Times Company.

All rights reserved.