Difference between revisions of "PostgreSQL-Database/C2/Inserting-and-Retrieving-Data/English"
(Created page with "Title of the tutorial: '''Inserting and Retrieving Data'''. Author: EduPyramids Keywords: '''INSERT Script, INSERT''' '''statement''', '''Query Tool, Execute query''', '''SEL...") |
|||
| Line 1: | Line 1: | ||
Title of the tutorial: '''Inserting and Retrieving Data'''. | Title of the tutorial: '''Inserting and Retrieving Data'''. | ||
| − | Author: EduPyramids | + | |
| + | '''Author''': '''EduPyramids''' | ||
Keywords: '''INSERT Script, INSERT''' '''statement''', '''Query Tool, Execute query''', '''SELECT''' '''query'''.''' Retrieving data,''' '''data redundancy''', '''EduPyramids, Video Tutorial.''' | Keywords: '''INSERT Script, INSERT''' '''statement''', '''Query Tool, Execute query''', '''SELECT''' '''query'''.''' Retrieving data,''' '''data redundancy''', '''EduPyramids, Video Tutorial.''' | ||
Latest revision as of 19:35, 6 February 2026
Title of the tutorial: Inserting and Retrieving Data.
Author: EduPyramids
Keywords: INSERT Script, INSERT statement, Query Tool, Execute query, SELECT query. Retrieving data, data redundancy, EduPyramids, Video Tutorial.
| Visual Cue | Narration |
| Slide 1
Title Slide |
Welcome to the Spoken tutorial on Inserting and Retrieving Data. |
| Slide 2
Learning Objectives |
In this tutorial, we will learn to
|
| Slide 3
System Requirements |
To record this tutorial, I am using
|
| Slide 4
Pre-requisites |
To follow this tutorial,
|
| Slide 5
Code Files
|
The following code file is required to practice this tutorial.
This file is provided in the Code Files link on this tutorial page. |
| Open pgAdmin | Let us open pgAdmin 4. |
| Show dashboardDouble click on Servers.Enter password: postgres
Click OK |
Please ensure that you are connected to the Localhost Post gres Q L server. |
| Select Studentdb | In the Browser pane, let us expand the Student d b database. |
| Click on the Schemas, then Public and then Tables. | Now let’s expand the Schemas node, public node and then Tables node. |
| Click students table | Let us click on the students table. |
| Click Columns | Next let us click on the Columns node. |
| Point to columns | We can see the structure of the students table with its columns. |
| Transition | Now let us insert data into this table. |
| Right-click students | Let me right click on the students table. |
| Select Scripts → INSERT Script | Let us select Scripts.
A submenu list opens From the submenu select INSERT Script. |
| Query Tool opens | The Query Tool window opens with a default INSERT statement. |
| Slide 6:
INSERT Statement INSERT INTO table(column1,column2...) VALUES (value1, value2,...); Highlight according to narration |
The Insert statement inserts one or more rows into a table.
The inserted values must match column order and data type of each column. That is column 1 takes the value 1 and column 2 takes the value 2 and so on. |
| Highlight syntax | The column names must follow the same order as the values. |
| Type:
INSERT INTO students (student_name, city, gender, date_of_birth, cgpa) VALUES ('Ram', 'Mumbai', 'Male', '1996-10-23', 9.6); |
Please delete the default INSERT statement before typing the new query.
|
| Highlight values Ram, Mumbai and Male.
|
Observe that character values are enclosed within single quotes.
|
| Click on the Execute query button.
Show the tool tip.
Point to the message. Click the Continue button. |
Let us now click on the Execute query button on the toolbar.
Click the Continue button to run the query. |
| Success message | A message Query returned successfully appears. |
| Select and press delete key.
(student_name, city, gender, date_of_birth, cgpa) VALUES ('Kishore', 'Mumbai', 'Male', '1996-08-09', 8.5); |
I will insert one more row in the same way.
Please delete the last command before typing the new command. Let me type the following query. |
| Click on the Execute query button.
Point to the Don’t ask again check box on the left. |
Let us click on the Execute query button to run the query.
Click Continue in the pop up box. |
| Transition | Now let us retrieve the inserted data. |
| Type SELECT * FROM students; | Type SELECT asterisk FROM students semicolon. |
| Click on the Execute query button. | Let me execute the query again. |
| Point to the Output pane | The output is displayed in a tabular format.
Let’s drag the boundary to see the table clearly |
| Slide 7
Syntax: Insert - Multiple row INSERT INTO table(column1,column2...) VALUES (value1, value2,...), (value1, value2,...), …..; |
This syntax is used to insert multiple rows in a single INSERT statement.
These rows are separated by commas.
|
| INSERT into students(student_name, city, gender, date_of_birth,cgpa)
Values ('Ram','Chennai','Male','1995-11-21', 9.2), ('Kishore','Mumbai','Male','1996-08-09', 8.5), ('Pooja','Pune','Female','1995-03-25', 9.2); |
Now let me type this INSERT statement. |
| Click on the Execute query button. | Let us execute the query again. |
| Point to the message | The message shows 3 rows. |
| Type Select * from students;
Click on the Execute query button. |
Let us retrieve the data again using a SELECT query.
Let us execute the query. |
| Drag the boundary to see the table.
Highlight Duplicate names |
Let us drag the boundary to see the entire table
The table contains multiple students with the same name. So the student names are not unique. This causes data redundancy. |
| Point to the data. | How can we uniquely identify each student? |
| We will learn more about data redundancy in the next tutorial. | |
| Click on Save File icon on the toolbar. | Let us save the file.
Click on the Save File icon on the toolbar. |
| Save the file as insertscript-student.sql | Save file window opens
Type the Name as insert script hyphen student dot s q l.Now click on the Save button. |
| With this, we come to the end of this tutorial. | |
| Slide 8
Summary In this tutorial, we learnt to
|
Let us summarise. |
| Slide 9
Assignment
|
As an Assignment, Please do the following. |
| Slide 10
Thank you. |
This Spoken Tutorial is brought to you by EduPyramids Educational Services Private Limited SINE IIT Bombay.
|