Specifications

we insert a row with a NULL value or no value in this field, MySQL will generate the next num-
ber in the autoincrement sequence and insert it for us automatically. This is pretty useful.
You can also insert multiple rows into a table at once. Each row should be in its own set of
brackets, and each set of brackets should be separated by a comma.
Weve put together some simple sample data to populate the database. This is just a series of
simple INSERT statements that use this multirow insertion approach. The script that does this
can be found on the CD accompanying this book in the file \chapter9\book_insert.sql. It is
also shown in Listing 9.1.
LISTING 9.1 book_insert.sql SQL to Populate the Tables for Book-O-Rama
use books;
insert into customers values
(NULL, “Julie Smith”, “25 Oak Street”, “Airport West”),
(NULL, “Alan Wong”, “1/47 Haines Avenue”, “Box Hill”),
(NULL, “Michelle Arthur”, “357 North Road”, “Yarraville”);
insert into orders values
(NULL, 3, 69.98, “02-Apr-2000”),
(NULL, 1, 49.99, “15-Apr-2000”),
(NULL, 2, 74.98, “19-Apr-2000”),
(NULL, 3, 24.99, “01-May-2000”);
insert into books values
(“0-672-31697-8”, “Michael Morgan”, “Java 2 for Professional Developers”,
34.99),
(“0-672-31745-1”, “Thomas Down”, “Installing Debian GNU/Linux”, 24.99),
(“0-672-31509-2”, “Pruitt, et al.”, “Sams Teach Yourself GIMP in 24 Hours”,
24.99),
(“0-672-31769-9”, “Thomas Schenk”, “Caldera OpenLinux System Administration
Unleashed”, 49.99);
insert into order_items values
(1, “0-672-31697-8”, 2),
(2, “0-672-31769-9”, 1),
(3, “0-672-31769-9”, 1),
(3, “0-672-31509-2”, 1),
(4, “0-672-31745-1”, 3);
insert into book_reviews values
(“0-672-31697-8”, “Morgan’s book is clearly written and goes well beyond
most of the basic Java books out there.”);
Using MySQL
P
ART II
210
12 7842 CH09 3/6/01 3:36 PM Page 210