Insert records into the created table
Here is the syntax for inserting records in a single row.Query syntax
INSERT INTO table_name (column1, column2, column3,…….columnN)
VALUES (value1, value2, value3 …valueN);
You have to insert data following the data types.
Suppose we are inserting records in the first row of the table from the previous lecture like this
Here is that table Job which is under the company database with some inserted data. Now we have to insert records into the created table in the database by using the SQL command. The records of the table given below will be inserted.
Job
E_id | Name | Gender | Age | City | CGPA |
102 | Austin | Male | 24 | New York | 3.00 |
103 | Mirza | Male | 23 | Dhaka | 2.88 |
104 | Hashim | Male | 23 | Karachi | 3.25 |
105 | Aliza | Female | 25 | London | 3.50 |
106 | Stephen | Male | 22 | Melbourne | 3.25 |
107 | Kumar | Male | 24 | Mumbai | 3.75 |
108 | Usman | Male | 26 | Dhaka | 3.25 |
So,
Insert a record of the first row.
Query
INSERT INTO Job (E_id, Name, Gender, Age, City, CGPA)
VALUES (102, 'Austin', 'Male', 24,'New York', 3.00);
After this first record will be saved.
Click on the go button. Then data will be inserted into the first row.
For the records of the second row,
Query syntax
INSERT INTO table_name
VALUES (value1, value2, value3 …valueN);
For the second record, we can write for this table
Query
INSERT INTO Job (E_id, Name, Gender, Age, City, CGPA)
VALUES (103, ‘Mirza’, ‘Male’, 24,’Dhaka’, 2.88);
Another data will be inserted.
This process will take a lot of time if we insert data like this. Records can be inserted into multiple rows at a time also. In this case, we can apply this query to insert the data in one process.
Query syntax
INSERT INTO table_name
VALUES
(value1, value2, value3 …valueN),
(value1, value2, value3 …valueN),
………………………………………………..
(value1, value2, value3 …valueN);
Job table syntax will be like this for the rest of the row records.
Query
INSERT INTO Job (E_id, Name, Gender, Age, City, CGPA)
VALUES
(105,'Aliza', 'Female', 25, 'London', 3.50),
(106, 'Stephen', 'Male', 22, 'Melbourne', 3.25),
(107, 'Kumar', 'Male', 24, 'Mumbai', 3.75),
(108,'Usman', 'Male', 26,'Dhaka', 3.25);
Values will be inserted into the Job table which is under the company database.
0 Comments