Our 3rd Lecture on MySQL -
Today we'll learn how to create table in MySQL by SQL query and also from XAMPP. I'll recommend to see the previous two tutorials on MySQL to complete today's lecture.In our previous lecture we've created a database called db_new. and now we'll create a table called student in this database.
Why have to create table in MySQL:
So, I think it is necessary to learn that why need to create a table in MySQL. In any relational database management system we need to relation one table with another to make our work so easy and simple. For this we have to create table.Create Table Syntax in MySQL:
CREATE TABLE table_name ( column_name1 data_type(size), column_name2 data_type(size), ...... );
So we need to create a Student table where student has a ID, Name, Email, Address attributes. The SQL syntax is the -
For doing this we need to select our database first. Then write the query in SQL tab.
CREATE TABLE Student ( ID INT(11) PRIMARY KEY, Name VARCHAR(30) NOT NULL, Email VARCHAR(50) NOT NULL, Address TEXT NOT NULL );
After running this SQL query a table Student will be created with among attributes - ID, Name, Email and Address. Which will look like this.
We can also do this by using Graphical User Interface of XAMPP. Like this -
Thanks for staying with us. Wait for our next tutorial about MySQL..
0 comments:
Post a Comment