Create
eharetea

MySQL CREATE statement is used in order to create tables.

Create tables in MySQL.

Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Friday August 01st, 2008 12:52 AM

CREATE is used to create databases or tables.

syntax:
CREATE DATABASE database_name
CREATE TABLE table_name(columns)

EXAMPLE:

mysql> CREATE TABLE users(
user_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(15) NOT NULL,last_name VARCHAR(30) NOT NULL,
email VARCHAR(40) NOT NULL, password char(40) NOT NULL,
registration_date DATETIME NOT NULL)
ENGINE = MYISAM;


mysql> DESC users;

+-------------------+-------------+------+-----+---------+----------------+
| Field             | Type        | Null | Key | Default | Extra          |
+-------------------+-------------+------+-----+---------+----------------+
| user_id           | int(11)     | NO   | PRI |         | auto_increment |
| first_name        | varchar(15) | NO   |     |         |                |
| last_name         | varchar(30) | NO   |     |         |                |
| email             | varchar(40) | NO   |     |         |                |
| password          | char(40)    | NO   |     |         |                |
| registration_date | datetime    | NO   |     |         |                |
+-------------------+-------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)


# adding indexes on create:

mysql>CREATE TABLE tetet (
comment_id INT UNSIGNED AUTO_INCREMENT NOT NULL,
subject VARCHAR(100) NOT NULL,
comment TEXT NOT NULL,
PRIMARY KEY (comment_id),
FULLTEXT (comment) );