Database Reference
In-Depth Information
Inserting Data
Those were a lot of details toabsorb in the last section. Let's take a break from creating
tables and enter data in the birds table. We'll use an INSERT statement,which was
covered briefly in Chapter3 , and will be covered in more detail in the next section. For
now, don't worry too much about understanding all of the possibilities with the INSERT
statement. Just enter the following on your server using the mysql client:
INSERT INTO birds ( scientific_name , common_name )
VALUES ( 'Charadrius vociferus' , 'Killdeer' ),
( 'Gavia immer' , 'Great Northern Loon' ),
( 'Aix sponsa' , 'Wood Duck' ),
( 'Chordeiles minor' , 'Common Nighthawk' ),
( 'Sitta carolinensis' , ' White-breasted Nuthatch' ),
( 'Apteryx mantelli' , 'North Island Brown Kiwi' );
This will create six rows of data for six birds. Enter the following from the mysql client to
see the contents of the table:
SELECT * FROM birds;
+---------+----------------------+-------------------+-----------+-------------+
| bird_id | scientific_name | common_name | family_id |
description |
+---------+----------------------+-------------------+-----------+-------------+
| 1 | Charadrius vociferus | Killdeer | NULL |
NULL |
| 2 | Gavia immer | Great Northern... | NULL |
NULL |
| 3 | Aix sponsa | Wood Duck | NULL |
NULL |
| 4 | Chordeiles minor | Common Nighthawk | NULL |
NULL |
| 5 | Sitta carolinensis | White-breasted... | NULL |
NULL |
| 6 | Apteryx mantelli | North Island... | NULL |
NULL |
+---------+----------------------+-------------------+-----------+-------------+
As you can see from the results, MySQL put values in the two columns we gave it, and set
the other columns to their defaultvalues (i.e., NULL). We can change those values later.
Let's create another table for a different database. We have information on birds in the
rookery database. Let's create another database that contains information about people
Search WWH ::




Custom Search