In this tutorial, you will learn how to create a table in MySQL database. You can create a table by using the command line, PHPMyAdmin, or any other MySQL GUI tools. I am using MySQL Workbench GUI Tool and PHPMyAdmin to perform the database operations.
There are three things which required to create a new table in MySQL database. See the below:
In the below example, we are creating “tbl_employee” in the database “mysql_tutorial”.
CREATE TABLE tbl_employee(
emp_id INT NOT NULL AUTO_INCREMENT,
dept_id INT NOT NULL,
emp_firstname VARCHAR(100) NOT NULL,
emp_lastname VARCHAR(100) NOT NULL,
emp_salary VARCHAR(100) NOT NULL,
PRIMARY KEY (emp_id)
Open your MySQL Workbench application, connect with MySQL, select your database and then copy paste above MySQL queries and execute. It will create a “tbl_employee” table in your selected database.
Open the PHPMyAdmin, select database, click on SQL tabs and then copy paste above MySQL queries and execute it. It will create MySQL table as tbl_employee.
Now click on tbl_employee table just created and see the table defination.