A Beginner's Guide to Creating Tables in MySQL

Table of contents

No heading

No headings in the article.

A table organizes data in the form of rows and columns. It stores data in structured format.

In this tutorial we will see how to create a table in MySQL.

The command for creating table in MySQL is " CREATE TABLE" command

Now lets see the basic syntax for creating a table:

CREATE TABLE tablename(

column1 datatype,

column2 datatype,

column3 datatype,

.......

);

PS-Don't forget the semicolon.

Now let's break down the above syntax:

  1. CREATE TABLE IS A COMMAND FOR CREATING TABLE

  2. tablename IS THE NAME YOU WANT GIVE TO THE TABLE THAT IS TO BE CREATED.

  3. COLUMN1/COLUMN2/COLUMN3 DENOTES THE NAME TO BE GIVEN TO COLUMNS OF THE TABLE

  4. datatype SPECIFIES THE TYPE OF DATA THAT THE RESPECTIVE COLUMNS WILL HOLD.

Now lets see an example-

create table empData(
name varchar(50),
age int,
designation varchar(50),
empId int
)

Lets us understand the above example-

We have created a table of name empData. It has four columns named as name,age,designation and empId with varchar,int,varchar and int as their datatypes respectively.

That's it for today's blog. Do comment down if you liked my blog.

Thank You. Have a good day!