Create Database

The major SQL DDL statements are CREATE DATABASE and CREATE/DROP/ALTER TABLE. The SQL statement CREATE is used to create the database and table structures.

Example: CREATE DATABASE SW

A new database named SW is created by the SQL statement CREATE  DATABASE SW. Once the database is created, the next step is to create the database tables.

The general format for the CREATE TABLE command is:

CREATE TABLE <tablename>
(
ColumnName, Datatype, Optional Column Constraint,
ColumnName, Datatype, Optional Column Constraint,
Optional table Constraints
);

Tablename is the name of the database table such as Employee. Each field in the CREATE TABLE has three parts (see above):

  1. ColumnName
  2. Data type
  3. Optional Column Constraint


ColumnName

The ColumnName must be unique within the table. Some examples of ColumnNames are FirstName and LastName.