SQL – Create Table using MySQL Interface

In previous chapter, we have learned how to create database using mysql interface. In this chapter, we are going to learn how to create table using MySQL interface.

If you remember, in previous when you have created the database, it asked to create table. Lets proceed.

We are going to create following table in MySQL.

Roll_no Student_name Subject Marks
1 John Math 90
2 Rita Math 95
3 Sam Math 84
4 Jack Math 72
5 Pom Math 99

This table has four columns, five records.

If you are not aware of the difference between database and table, then read following article.

Difference between database and table.

Create Table in MySQL using MySQL Interface

Step 01:

Identify column names:

In the above table. The column names are Roll_no, Student_name, Subject and Marks.

Step 02:

Idetify each column data type.

From the above table:

If you are not aware of MySQL datatypes then read following article:

MySQL datatypes

Step 03:

Estimate each column data value length

In the above table:

Roll_no value cant be larger than 100 (lets assume 80 students are there)

Therefore the length of Roll_no value can not be more than 3

Similarly, we are storing first name of students. So the length of student name value wont be greater than 50

Similarly subject value is math which is always going to be same because the table is about math marks. Therefore the length of subject value wont be greater than 4.

Similarly, maximum number on can secure in maths is 100. Therefore, the maximum length of marks value wont be greater than 3.

Step 04:

Start xampp. (If you have already started xampp, ignore step 4)

If you are not aware of xampp, and how to install it, then read following article.

HOW TO DOWNLOAD AND INSTALL XAMPP IN WINDOWS AND MAC OS X?

Step 05:

Visit following url:

If using windows: http://localhost/phpmyadmin/

If using mac: http://localhost:8080/phpmyadmin/

A following similar page going to appear

Create table using MYSQL Interface

step 06:

Look through left column and then click on your database. I am going to use gyanol_db (which I have created previously)

Then following screen appears.

create table using mysql interface

step 07:

Provide a table name. You can provide any name. But no space and special characters are allowed. To use multiple names use under score. I am going to provide table name – ‘student_name’

By default it is showing number of columns 4. You can change the number as per your need. But in our example, we have four columns. So we are leaving it as it is. Then click on go.

Step 08:

Then following screen going to appear.

create table using mysql interface

First of all, we are not required to provide information in all the input fields. But to create table, we are required to provide minimum, column name, data type, and length. Thats it.

Create Table MySQL Interface

In step 02 and Step 03 we have identified column name, column data type, and its length. Now enter into the table interface as above. Then click save.

Congratulations, you have just created one table for database successfully.

NOTE: The created table is blank as we have only created the table but has not provided any values yet.

In next chapter we are going to learn, how to insert data value in to the table using mysql interface.