1. Home
  2. MySQL Tutorials
  3. MySQL – Create Table

MySQL – Create Table

To create new tables into a database, the MySQL command known as CREATE TABLE is ideal. Equally, there are three steps required in  creating a table. They are as follows
1. The Name of the table.
2. The names of fields
3. The definitions of each field.

Syntax:

CREATE TABLE [IF NOT EXISTS]  table_name(coloumn 1, coloumn 2, coloumn 3, )

Example:

In this example, the table we are to create will be named “employee”

mysql> CREATE TABLE employee (100) NOT NULL, 
emp_surname VARCHAR (100) NOT NULL, 
PRIMARY KEY (emp_id);

NOTE: The NOT NULL attribute was used in the example above to prevent the field from being NULL.

Was this article helpful to you? Yes No

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.