Database Reference
In-Depth Information
To see how the table looks,use the DESCRIBE statement. It displays information about
the columns of a table, or the table schema — not the data itself. To use this SQL state-
ment to get information on the table we just created, you would enter the following SQL
statement:
DESCRIBE birds;
+-----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default |
Extra |
+-----------------+--------------+------+-----+---------+----------------+
| bird_id | int(11) | NO | PRI | NULL |
auto_increment |
| scientific_name | varchar(255) | YES | UNI | NULL
| |
| common_name | varchar(50) | YES | | NULL
| |
| family_id | int(11) | YES | | NULL
| |
| description | text | YES | | NULL
| |
+-----------------+--------------+------+-----+---------+----------------+
Notice that these results are displayed in a table format made with ASCII characters. It's
not very slick looking, but it's clean, quick, and provides the information requested. Let's
study this layout, not the content, per se.
The first row of this results set contains column headings describing the rows of informa-
tion that follow it. In the first column of this results set, Field contains the fields or
columns of the table created.
The second column, Type , lists the data type for each field. Notice that for the table's
columns in which we specified the data type VARCHAR with the specific widths within
parentheses, those settings are shown here (e.g., varchar(255) ). Where we didn't spe-
cify the size for the INT columns, the defaults were assumed and are shown here. We'll
cover later what INT(11) means and discuss the other possibilities for integer data
types.
The third column in the preceding results, Null , indicates whether each field may contain
NULL values. NULL is nothing; it's nonexistent data. This is different from blank or
empty content in a field. That may seem strange: just accept that there's a difference at
this point. You'll see that in action later in this topic.
Search WWH ::




Custom Search