13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

234 Chapter 9 Creating Your <strong>Web</strong> Database<br />

<strong>MySQL</strong> then displays a list of all the tables in the database:<br />

+-----------------+<br />

| Tables in books |<br />

+-----------------+<br />

| book_reviews |<br />

| books |<br />

| customers |<br />

| order_items |<br />

| orders |<br />

+-----------------+<br />

5 rows in set (0.06 sec)<br />

You can also use show to see a list of databases by typing<br />

mysql> show databases;<br />

If you do not have the SHOW DATABASES privilege, you will see listed only the databases<br />

on which you have privileges.<br />

You can see more information about a particular table, for example, books, using<br />

DESCRIBE:<br />

mysql> describe books;<br />

<strong>MySQL</strong> then displays the information you supplied when creating the database:<br />

+--------+------------+------+-----+---------+-------+<br />

| Field | Type | Null | Key | Default | Extra |<br />

+--------+------------+------+-----+---------+-------+<br />

| isbn | char(13) | NO | PRI | NULL | |<br />

| author | char(50) | YES | | NULL | |<br />

| title | char(100) | YES | | NULL | |<br />

| price | float(4,2) | YES | | NULL | |<br />

+--------+------------+------+-----+---------+-------+<br />

4 rows in set (0.00 sec)<br />

These comm<strong>and</strong>s are useful to remind yourself of a column type or to navigate a database<br />

that you didn’t create.<br />

Creating Indexes<br />

We briefly mentioned indexes already, because designating primary keys creates indexes<br />

on those columns.<br />

One common problem faced by new <strong>MySQL</strong> users is that they complain about<br />

poor performance from this database they have heard is lightning fast.This performance

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!