Difference between revisions of "PostgreSQL-Database/C2/NULL-Values-and-UPDATE-Statement/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 52: Line 52:
 
* '''nvu-commands.txt'''
 
* '''nvu-commands.txt'''
  
This file is provided in the Code Files link on this tutorial page.
+
This file is provided in the Code Files link of this tutorial page.
 
|| The following code file is required to practice this tutorial.
 
|| The following code file is required to practice this tutorial.
  
Line 71: Line 71:
 
|| '''Slide 7'''
 
|| '''Slide 7'''
  
'''Syntax of Null value'''
+
'''Syntax of Null'''
  
 
'''SELECT column_names'''
 
'''SELECT column_names'''
Line 90: Line 90:
  
 
Click the''' Execute query icon.'''
 
Click the''' Execute query icon.'''
|| Let us insert a '''NULL''' value.For this, type the following query.
+
|| Let us insert a '''NULL''' value. For this, type the following query.
  
 
Here the '''NULL''' keyword is used to insert null values.  
 
Here the '''NULL''' keyword is used to insert null values.  
Line 105: Line 105:
  
 
ADD ANNOTATION.( '''CGPA''' and '''DOB''' are automatically set to '''NULL''')
 
ADD ANNOTATION.( '''CGPA''' and '''DOB''' are automatically set to '''NULL''')
|| Type the following query and execute it. Here, '''C G P A''' and '''D O B columns''' are automatically set to '''NULL'''.
+
|| Type the following query and execute it.  
 +
 
 +
Here, '''C G P A''' and '''D O B columns''' are automatically set to '''NULL'''.
 
|-
 
|-
 
||  
 
||  
Line 115: Line 117:
 
|| Type the following query.
 
|| Type the following query.
  
Here we are using the I'''S NULL '''clause.
+
Here we are using the '''IS NULL '''clause.
  
 
Let us execute the query.
 
Let us execute the query.
Line 121: Line 123:
 
The output displays details of students whose '''C G P A''' is currently not recorded.
 
The output displays details of students whose '''C G P A''' is currently not recorded.
 
|-
 
|-
||  
+
|| Point to '''D O B''' and '''C G P A''' values.
 
|| Here, the '''D O B''' and '''C G P A''' values are not known.  
 
|| Here, the '''D O B''' and '''C G P A''' values are not known.  
 
|-
 
|-
Line 134: Line 136:
  
 
Click on the''' Execute query button'''.
 
Click on the''' Execute query button'''.
|| Type the following query and execute it. This query displays studentid and their names whose '''C G P A''' value is '''NULL'''.
+
|| Type the following query and execute it.  
 +
 
 +
This query displays studentid and their names whose '''C G P A''' value is '''NULL'''.
 
|-
 
|-
 
||  
 
||  
Line 141: Line 145:
 
|| '''Slide 8'''
 
|| '''Slide 8'''
  
'''UPDATE Statement'''
+
'''UPDATE statement'''
 
|| '''UPDATE''' Statement is used to modify existing records in a table.
 
|| '''UPDATE''' Statement is used to modify existing records in a table.
 
|-
 
|-
 
|| '''Slide 9'''
 
|| '''Slide 9'''
  
'''Syntax of UPDATE Statement'''.
+
'''Syntax of UPDATE Statement'''
  
 
'''UPDATE table_name'''
 
'''UPDATE table_name'''
Line 187: Line 191:
 
|-
 
|-
 
|| Show the table and point to M in the records.
 
|| Show the table and point to M in the records.
|| Let us update the records of students with studentids S116 and S117
+
|| Let us update the records of students with studentids S116 and S117.
 
|-
 
|-
 
|| Type the following:'''UPDATE students'''
 
|| Type the following:'''UPDATE students'''
Line 211: Line 215:
  
 
Point to the gender columns of the students.
 
Point to the gender columns of the students.
|| Let us display the entire table.Type this query and execute it.
+
|| Let us display the entire table.
 +
 
 +
Type this query and execute it.
  
We can see that in the gender column M is updated to Male for studentids '''S116 '''and''' S117'''.
+
We can see that in the gender column '''M''' is updated to '''Male''' for studentids '''S116 '''and''' S117'''.
 
|-
 
|-
 
|| '''Slide 10'''
 
|| '''Slide 10'''

Latest revision as of 17:19, 22 April 2026

Title of the Script: NULL Values and UPDATE Statement.

Author: Ketki Bhamble

Keywords: PostgreSQL, pgAdmin 4, syntax, NULL values, IS NULL, UPDATE statement, EduPyramids, video tutorial.


Visual Cue Narration
Slide 1


Title Slide

Welcome to this Spoken Tutorial on NULL Values and UPDATE Statement.
Slide 2


Learning Objectives

In this tutorial, we will learn how to,
  • Insert and Display Null values and
  • UPDATE Statement
Slide 3

System Requirements

  • Ubuntu 24.04 LTS
  • PostgreSQL version 18.1, and
  • PgAdmin 4 version 9.11.
To record this tutorial, I am using the following setup.
Slide 4

Pre-requisites

https://EduPyramids.org


To follow this tutorial,
  • Learners should have PostgreSQL and p g Admin 4.
  • For the prerequisite PostgreSQL tutorials, please visit this website.
Slide 5

Code Files

The following code file is required to practice this tutorial:

  • nvu-commands.txt

This file is provided in the Code Files link of this tutorial page.

The following code file is required to practice this tutorial.

This file is provided in the Code Files link of this tutorial page.

Please download and extract the file.

Let us get started.
Slide 6

What is a NULL Value?

A null value is an unknown or missing value.

If a field has no value it can be left blank as no data stored in it.

Slide 7

Syntax of Null

SELECT column_names

FROM table_name

WHERE column_name IS NULL;

This is the syntax to show a Null value.

IS NULL clause checks for fields that have no stored values.

I have opened the p g Admin 4 interface and connected to the localhost server.
Type: INSERT INTO students (studentid, studentname, city, gender, dob, cgpa)

VALUES ('S116', 'Ravi', 'Pune', 'M', NULL, NULL);

Click the Execute query icon.

Let us insert a NULL value. For this, type the following query.

Here the NULL keyword is used to insert null values.

Let us execute the query.

The query is returned successfully.

Type: INSERT INTO students (studentid, studentname, city, gender)

VALUES ('S117', 'Kiran', 'Pune', 'M');

Click on the Execute query button.

ADD ANNOTATION.( CGPA and DOB are automatically set to NULL)

Type the following query and execute it.

Here, C G P A and D O B columns are automatically set to NULL.

We can add a NULL value by inserting a record without specifying its value.
Type: SELECT * FROM students

WHERE cgpa IS NULL;

Type the following query.

Here we are using the IS NULL clause.

Let us execute the query.

The output displays details of students whose C G P A is currently not recorded.

Point to D O B and C G P A values. Here, the D O B and C G P A values are not known.
Now let us see another example.
Type: SELECT studentid, studentname

FROM students

WHERE cgpa IS NULL;

Click on the Execute query button.

Type the following query and execute it.

This query displays studentid and their names whose C G P A value is NULL.

Let us update the record so that it no longer displays NULL.
Slide 8

UPDATE statement

UPDATE Statement is used to modify existing records in a table.
Slide 9

Syntax of UPDATE Statement

UPDATE table_name

SET column1 = value1, column2 = value2, ...

WHERE condition;

Here is the syntax of the UPDATE statement.UPDATE specifies the table to be modified.

SET assigns new values to one or more columns.

WHERE selects the records that need to be updated.

Type: UPDATE students

SET cgpa = 8.1

WHERE studentid = 'S116';

Click on the Execute query button.

Let us update the Null value.

Type this query.

Here the SET keyword sets the C G P A value to 8 point 1.

Let us execute the query.

Cursor on Query returned successfully in 322 msec. The output shows that the query is updated.
Type:

SELECT * FROM students

WHERE studentid = ‘S116’;

Now let us type this query and execute it.

We can see that a new record is added to the table.

Show the table and point to M in the records. Let us update the records of students with studentids S116 and S117.
Type the following:UPDATE students

SET gender = 'Male'

WHERE studentid = 'S116'

OR studentid = 'S117';

Click on the Execute Query button.

Type the following query.

In this query we will set the gender to male.

Let us execute the query.

The table is now updated.

Type: SELECT * FROM students;

Click on the Execute Query button.

Point to the gender columns of the students.

Let us display the entire table.

Type this query and execute it.

We can see that in the gender column M is updated to Male for studentids S116 and S117.

Slide 10

Summary

In this tutorial, we have learnt how to,

  • Insert and Display Null values and
  • UPDATE Statement
With this, we come to the end of this tutorial.

Let us summarise.

Slide 11

Assignment

As an Assignment,

Insert a student record with a NULL CGPA value.

Update the NULL CGPA value for one student.

Verify the updated record using a SELECT query.

We encourage you to do this assignment.
Slide 12

Thank you

This Spoken Tutorial is brought to you by EduPyramids Educational Services Private Limited SINE IIT Bombay.

Thank you for joining.

Contributors and Content Editors

Ketkinaina, Madhurig