Professional Documents
Culture Documents
Create A Table in MySQL
Create A Table in MySQL
Create A Table in MySQL
For this example we'll create two tables. The first one describe the species of animals available in a pet store and the
second will store the data of a pet in the store. The table names will be species and pet
The species table will consist of the id and the animal species, and the pet table will consist of animal id, species, sex,
and price
mysql> CREATE TABLE species (id INT NOT NULL AUTO_INCREMENT, species varchar(30)
NOT NULL, primary key(id));
Query OK, 0 rows affected (0.02 sec)
mysql> CREATE TABLE pet(id INT NOT NULL AUTO_INCREMENT, sp_id INT NOT NULL, sex
CHAR(1) NOT NULL, price DECIMAL(4,2) NOT NULL, primary key(id));
Query OK, 0 rows affected (0.03 sec)
The SQL sytax to create table is : CREATE TABLE <tablename> (<list of fields>)
The DESCRIBE or DESC statement is used to show a description of a table. You can also use EXPLAIN or SHOW
COLUMNS
Search
www.php-mysql-tutorial.
Web com
This tutorial is far from perfect so if you have any critiques, questions, comments or problems about this tutorial
please tell me. Click here to send your feedback. And if you like this tutorial please link to this site. It will really help a
lot :-)
My Experimental Sites
1. Crocodile Hunter DVD 2. Kids & Baby Apparel Store 3. DVD Players, Home Theater Systems 4. Action Figures, Kids
Activities & Learning 5. Baby Play Centers & Walkers