In this tutorial, We are going to cover How to create table in MySQL Database.
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:
Below is syntax to create table in MySQL .
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.
Reference:
https://dev.mysql.com/doc/refman/8.0/en/creating-tables.html