Difference between revisions of "PostgreSQL-Database/C2/Inserting-and-Retrieving-Data/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(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
  • Insert data into a table and
  • Retrieve data from a table.
Slide 3

System Requirements

To record this tutorial, I am using
  • Ubuntu 24.04 LTS
  • Post gres Q L version 18 point 1, and
  • P g Admin 4 version 9 point 11.


Slide 4

Pre-requisites

https://EduPyramids.org

To follow this tutorial,
  • Learners should have Post gres Q L and p g Admin 4 installed in their systems.
  • For the prerequisite Post gres Q L tutorials, please visit this website.
Slide 5

Code Files

  • ird-codes.txt


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.


Let us type the following query in the query window to insert a row.


Let’s drag the boundary to see the query clearly.

Highlight values Ram, Mumbai and Male.


Highlight the numeric value.

Observe that character values are enclosed within single quotes.


Here numeric values are not enclosed in quotes.

Click on the Execute query button.

Show the tool tip.


Point to the Execute query pop window.

Point to the message.

Click the Continue button.

Let us now click on the Execute query button on the toolbar.


Execute query window opens with a message Do you want to run this query-

Click the Continue button to run the query.

Success message A message Query returned successfully appears.
Select and press delete key.


Type:


INSERT INTO students

(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.


We will check the Don't ask again check box to prevent the pop-up from appearing on every query execution.

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.


Each set of values inside the parentheses represent one row.

These rows are separated by commas.


The values in each row must match both the column order and the specified data type.

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

  • Insert data into a table
  • Retrieve data from a table.


Let us summarise.
Slide 9

Assignment

  • Insert five records in the Emp table created in the previous assignment
  • Retrieve the data.


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.


Thank you.

Contributors and Content Editors

Madhurig