In focus

How To Create A Table In MySQL

In this article we learn how to create and drop a table in MySQL.

Anmol Garg Apr 13, 2016

MySQL is a Relational Database Management System (RDBMS) that runs as a server which provides multi-user access to a number of databases. It is an open source database software based on the SQL vocabulary, which can be used in combination with most server-side languages, but it is most commonly employed with PHP.

Creating a Table in MySQL

One thing to remember, the table that you are creating must be inside a database and it is important that you use the current database. Command for using the current database

Syntax : Use database name;

: Here we are using emp database

Now we go to create table command

Create table command is used to create a table in MySQL.

Syntax : create table table name (values ( value1 , value 2 ,..... ));

: Here we create table with name emp_info

Create table emp_info (id int(2),name varchar (20),age int (2));

Table will be created.

Dropping a Table in MySQL

Drop table command is used to delete a table in MySQL.

Syntax : drop table table name;

: Here we drop a table with name emp_info.