It is very easy to create a table in MySQL. You need to use the Create table statement to create a table in MySQL. Please check below example
[php]create table table_name(
column1 datatype,
column2 datatype,
column3 datatype
);[/php]
There are three main elements in creating a table:
1. Table name: Name you want to give to your table. You can select any name.
2. column: Column name in your table.
3. datatype: Type of data you are going to store in that column.
But we can add more elements to a table.
let’s do a live example with a brief explanation:
[php]create table students(
roll_no int NOT NULL AUTO_INCREMENT,
student_name varchar(255) NOT NULL,
student_address varchar(255) NOT NULL,
PRIMARY KEY (roll_no)
);[/php]
Let’s explain these above statements:
- Table name: students
- columns: roll_no, student_name, student_address
- datatype: int, varchar
- Not Null: NOT NULL is used to prevent a user to create a record with a NULL value. If a user will try to create a record with NULL value then MySQL will display an error message.
- AUTO_INCREMENT: Field Attribute AUTO_INCREMENT tells MySQL to go ahead and add the next available number to the id field.
- PRIMARY KEY: Keyword PRIMARY KEY is used to define a column as a primary key.





Ajay
Hi Sir Thanks for the Information. I have a website which is basically HTML website can we integrate some search module. What will be the process for the same?
Rishab Kapoor
Hi Ajay, Please email me your website domain name, then I’ll be able to assist you.
Celeeine
I have learned good stuff here. Definitely, I’m going to bookmark your site for future reference.
Hardik
Hello Sir,
Can you write a blog for how to use HTML templates into WordPress website?
Thank you
Rishab Kapoor
Hi Hardik,
Sure I will write a blog on your suggested topic and will update you soon. Just Subscribe my blog and you will get a notification.