Specifications

A summary of possible identifiers is shown in Table 8.4. The only additional exception is that
you cannot use ASCII(0) or ASCII(255) in identifiers (and to be honest, Im not sure why
youd want to).
TABLE 8.4 MySQL Identifiers
Max Case Characters
Type Length Sensitive? Allowed
Database 64 same as O/S Anything allowed in a directory name in
your O/S except the / character
Table 64 same as O/S Anything allowed in a filename in your
O/S except the / and . characters
Column 64 no Anything
Alias 255 no Anything
These rules are extremely open.
As of MySQL 3.23.6, you can even have reserved words and special characters of all kinds in
identifiers, the only limitation being that if you use anything weird like this, you have to put it
in back quotes (located under the tilde key on the top left of most keyboards). For example
create database `create database`;
The rules in versions of MySQL (prior to 3.23.6) are more restrictive, and dont allow you to
do this.
Of course, you should apply common sense to all this freedom. Just because you can call a
database `create database`, it doesnt that mean that you should. The same principle applies
as in any other kind of programminguse meaningful identifiers.
Column Data Types
The three basic column types in MySQL are: numeric, date and time, and string. Within each
of these categories are a large number of types. Well summarize them here, and go into more
detail about the strengths and weaknesses of each in Chapter 11.
Each of the three types comes in various storage sizes. When choosing a column type, the prin-
ciple is generally to choose the smallest type that your data will fit into.
For many data types, when you are creating a column of that type, you can specify the maxi-
mum display length. This is shown in the following tables of data types as M. If its optional for
that type, it is shown in square brackets. The maximum value you can specify for M is 255.
Optional values throughout these descriptions are shown in square brackets.
Using MySQL
P
ART II
200
11 7842 CH08 3/6/01 3:38 PM Page 200