O'Reilly logo

PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition by Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Databases and Tables

The first logical use of SQL and MySQL will be to create a database. The syntax for creating a new database is

CREATE DATABASE databasename
				

The CREATE term is also used for making tables.

CREATE TABLE tablename (

column1name description,

column2name description
...)

As you can see from this syntax, after naming the table, you define each column—in order—within parentheses. Each column-description pair should be separated from the next by a comma. Should you choose to create indexes at this time, you can add those at the end of the creation statement, but you can add indexes at a later time as well.

To create databases and tables

1.
Access the mysql client using the steps outlined previously. Throughout the rest ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required