How to Insert Records into Table | Insert into Table SQL | Insert into Statement | Intellipaat

How to Insert Records into Table | Insert into Table SQL | Insert into Statement | Intellipaat

November 8, 2019 1 By Kailee Schamberger


Hey guys welcome back to this SQL
tutorial series. In this session we’ll learn how to insert records into a table.
We can insert records for this insert into statement. Now let’s understand this
command properly. So first we’d have to type in the keywords insert into then
we ll give In the table name following which we ll give In the keyword values and inside the parentheses we’d have to give in the values for each of the column
respectively. Now let’s go to MS SQL server and insert records into an
employee table. So let me start with the command so I will type in insert into then I’d have to give in the name of the table which would be
employee after which I will give in the keyword
values and inside the paranthesis I can give in all of the records so let me
start with the first record right so we’ll have to start off with the employee
ID so the employee IDs let’s say 1 then the second column is the employee’s name and this is of type varchar that is why I will give in the value inside these
single quotes so the employees name is Sam after this we would have to give in
the employee salary so Sam earns $95,000 per annum. I will give in 95,000 over here
then we have the employees age so Sam’s age is 45 after which we have the
employee’s gender again since this is a variable character so I will use the
single quotes over here and Sam is male obviously after which we’d have to give
in the department in which the employee works so again this is variable length
character I will give in single quotes and Sam works in operations so let me
type in operations over here now I will put in semicolon over here I
will select all of this and I will click on execute so we have successfully
inserted one record into our table. Now let me follow the same procedure and
insert another record so insert into employee values and inside the
parentheses the first column is employee ID which would be two after this
I’d have to give in the name of the employee so the name of the employee is
Bob and Bob earns $80,000 which is his salary so let me put in eighty thousand over here then we have the employees age so Bob’s age is 21 then we have the gender
of the employee so Bob is male obviously again then we have to give in the
department in which the employee works so Bob works in support again I will put in semicolon I’d have
to select all of these let me click on execute right so we have also insert in
the second record. Now let me insert the third record so again it would be the
same command, insert into employee values inside the brackets let me give all of
the values for the columns so employee ID is three, the name is Ann and Ann’s salary is
one hundred and twenty five thousand dollars per annum
she’s quite rich doesn’t she? and her age is 25 and she’s obviously female now we’ll have to give in the department in which the employee works so Ann works in analytics, let me type in analytics over
here so it seems like people who work in
analytics earn quite a lot doesn’t it? so let me put in semicolon over here I’ll
select all of these and let me click execute so similarly I will insert three
more records into the same table right so we have successfully inserted
six records into our table. So guys this is how we can insert records into a
table. In the next session we’ll learn how to select individual records from
the table. So thanks for attending the session, let’s meet in the next class.