PostgreSQL - SPLessons

PostgreSQL Queries

Chapter 18

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

PostgreSQL Queries

PostgreSQL Queries

shape Description

These PostgreSQL Queries are the principal structures for recovering data from the database. And these PostgreSQL Queries contains pretend designs that is displayed from the database. Numerous database administration frameworks utilizes Structured Query Language as a basic design structures related to query. PostgreSQL Queries statements can be classified into the following types:

Insert

shape Description

By using insert command a new record can be inserted in the existing database table. i.e, inserting field value like emp_id, emp_name and salary can be inserted.

Steps for inserting values inside the database tables

shape Step - 1

In the SQLDB database, employee21 table has been created.

shape Step - 2

Right click on employee21 table and select Script followed by Create Script.

shape Step - 3

Employee21 table has been created.

shape Step - 4

Right click on employee21 table and select Script followed by Insert Script.

shape Step - 5

Column details will appear.

shape Step - 6

Enter first record details and click on execute.

shape Step - 7

Enter second record details and click on execute.

shape Step - 8

Enter third record details and click on execute.

shape Step - 9

Enter fourth record details and click on execute.

shape Step - 10

Click on employee21 table and select View Data followed by View top 100 rows.

shape Step - 11

It display all the employee details of employee21 table.

Select

shape Description

Select statement is used to retrieve a desire value from the database tables.

Steps for selecting the desire values from the database tables

shape Step - 1

In the SQLDB database, employee21 table has been created.

shape Step - 2

Right click on employee21 table and select Script followed by Select Script.

shape Step - 3

Display all the column name with the tablename and added where condition.

shape Step - 4

A specific employee records get displayed using select query.

Update

shape Description

By using update command, the column values can be updated.i.e, changing the name of the employee and increasing/decreasing the salary.

Steps for updating the values inside the database tables

shape Step - 1

In the SQLDB database, employee21 table has been created.

shape Step - 2

Right click on employee21 table and select script followed by Update script.

shape Step - 3

It display the below window.

shape Step - 4

Updating the dept name value.

shape Step - 5

Right click on employee21 table and select View Data followed by View top 100 rows.

shape Step - 6

Here the dept name has been updated.

Delete

shape Description

By using delete command one can delete the rows of an existing table based on the given condition.

Steps for deleting a specific record from the database tables

shape Step - 1

In the SQLDB database ,employee21 table has been created.

shape Step - 2

Right click on employee21 and select script followed by delete script.

shape Step - 3

A new window is appeared with some condition.

shape Step - 4

Deleting the employee record from the employee21 table.

shape Step - 5

Right click on employee21 table select View Data followed by View Top 100 Rows.

shape Step - 6

Details of employee with emp_id=1002 has been successfully remove. 

Summary

shape Key Points

  • PostgreSQL Queries – Is a collection of variables of homogeneous data type.
  • Insert – Inserting the values inside the database tables.
  • Select – Retrieving a specific value from the database table.
  • Update – Updating the values from the database table.
  • Delete – Deleting a particular record from the database table.