Inserting data Into table


In this section we are going to discuss data insertion into tables .
  • Insert statements is used to insert a data into a table.
  • Basic statements for data insertion .
Take a look on below image:

 Here we have given the query to insert data into the table the database server process this statements and insert a single row into the table in the database .
Syntex:

In this syntex INSERT INTO is the keyword that specifies the data insertion .Table_Name specifies the name of the table in which we are going to insert the data,columns name specifies the name of column in which we are going to give the value here we can specfies the desired columns name and if we wish to insert value for all columns of table so there is no need of specifing the each columns name .VALUES is the keyword that specifies the value we are going to give to table say value-1,value-2,value-n is the values .we must enter the value of columns according to the columns in the table.
Strucutre of table :
Table Name:  friendsdtls
Columns Name or Field :
s_no                 int(10)
first_name       varchar (50)
last_name        varchar(50)
city                  varchar(50)
create the following table if you have any problem in creating the table then take a look on  table creation . The data which we are going to insert in the friendsdtls table
So the insert query for the above table is as follows :
INSERT INTO `test`.`friendsdtls` ( `s_no`,`first_name` ,`last_name` ,`city`)
                                        VALUES ( '1', 'abhishek', 'choudhary', 'kolkata');
we can also insert the data without mentioning the fields  but in that case must be in order as follows:
INSERT INTO `test`.`friendsdtls` VALUES ('2', 'md', 'imran', 'kolkata'  );
after  executing the above lines of query  your table will look like as below
Here you go a sample video how to insert data into table .you can view this video on my you tube channel as well @  http://youtu.be/yJl0z84Rh40

I am interested in hearing your feedback, so that I can improve my articles and learning resources for you.connect with us on facebook, twitter

Share

Did you enjoy reading this and found it useful? If so, please share it with your friends:

4 comments: