Okay, we are about to go into the details of SQL queries, but before that we should say one
last thing about SQL database structures. Specifically,
most databases store their data in terms of data types.
Defining data types allows the database to be more
efficient and helps to protect you against adding bad
data to your tables.
There are several standard data types including
Type |
Alias |
Description |
CHARACTER |
CHAR |
Contains a string of characters.
Usually, these fields will have a specified maximum length that is defined
when the table is created. |
NUMERIC |
NONE |
Contains a number with a specified number
of decimal digits and scale (indicating a power to which the
value should be multiplied) defined at the table creation. |
DECIMAL |
DEC |
Similar to NUMERIC except that it is more
proprietary. |
INTEGER |
INT |
Only accepts integers |
SMALLINT |
NONE |
Same as INTEGER except that precision
must be smaller than INT precisions in the same table. |
FLOAT |
NONE |
Contains floating point numbers |
DOUBLE PRECISION |
NONE |
Like FLOAT but with greater precision |
It is important to note that not all databases will
implement the entire list and that some will implement their own data types such as
calendar or monetary types. Some fields may also allow a NULL value
in them even if NULL is not exactly the correct type.
Okay, we will explain data types when we actually start using them,
so for now, let's go on to some real examples of doing things with SQL. Let's
log on to a database and start executing queries using SQL.
Previous |
Next |
Table of Contents
|