📒
PyCoders Handbook
  • Welcome!
  • Values and Principles
  • Onboarding Guideline
  • Python
    • Week 1
      • 💻Introduction to Python
    • Week 2
      • 🗃️Lists, Tuples, Sets, Dictionaries
    • Week 3
      • 🤖Functions
      • 📦Modules & Packages
    • Week 4
      • 🛠️Errors & Exceptions
      • 💾File I/O (Input/Output)
    • Week 5
      • ⚙️OOP-1
    • Week 6
      • ⚙️OOP-2
    • Module Project
  • Database
    • Week 8
      • 🗄️Introduction to Databases & SQL
    • Week 9
      • 🐘PostgreSQL
    • Week 10
      • 🍃MongoDB
    • Module Project
  • DATA GATHERING
    • Week 13
      • 🌐Web Technologies & APIs
    • Week 14
      • ⚡Python Requests Library & FastAPI
  • Maths/Stats
    • 🔢Introduction to Statistics
    • Assignment
  • DATA MANIPULATION
    • Week 17
    • Week 18
    • Week 19
  • Data Visualization-1
    • Week 20
    • Week 20.5
      • Python graph gallery
    • Week 21
  • DATA MANIPULATION PROJECT
    • Week23-24-25 (Project Weeks)
  • DATA VISUALIZATON-2
    • Week26(PowerBI)
  • Machine Learning
    • Week27
    • Week 28
    • Capstone Project
  • Extra Documentation
    • Week27-2
    • Copy of Week 16
    • RegEx
    • PyQt5
    • ML
    • ML
    • ML
    • ML
    • ML
    • maths-stats
    • maths-stats
    • maths-stats
    • Module Project(Weather Application)
    • Tableau
    • Module Project(AutoScout24 Application)
    • ⚙️Web Scraping
    • Week28-2
Powered by GitBook
On this page
  • Section 1. Querying Data
  • Section 2. Filtering Data
  • Section 3. Joining Multiple Tables
  • Section 4. Grouping Data
  • Section 5. Set Operations
  • Section 6. Grouping sets, Cube, and Rollup
  • Section 7. Subquery
  • Section 8. Common Table Expressions
  • Section 9. Modifying Data
  • Section 10. Transactions
  • Section 11. Import & Export Data
  • Section 12. Managing Tables
  • Section 15. Conditional Expressions & Operators
  • Section 16. PostgreSQL Utilities
  • Section 17. PostgreSQL Recipes

Was this helpful?

  1. Database
  2. Week 9

PostgreSQL

PreviousWeek 9NextWeek 10

Last updated 2 years ago

Was this helpful?

IMPORTANT NOTE: We will continue the second week lessons based on the information on . You can reach detailed explanations of each subject from the relevant links below. In our physical lesson, we will do exercises on the sample database used here. For this reason, it is important that we come to the lesson with the sample database file running on our computers from the link . The name of the sample database file is dvdrental. We will do most of the SQL query exercises from PostgreSQL 14 version and PgAdmin 4 interface.

Section 1. Querying Data

  • : show you how to query data from a single table.

  • : learn how to assign temporary names to columns or expressions in a query.

  • : guide you on how to sort the result set returned from a query.

  • : provide you a clause that removes duplicate rows in the result set.

Section 2. Filtering Data

  • : filter rows based on a specified condition.

  • : get a subset of rows generated by a query.

  • : limit the number of rows returned by a query.

  • : select data that matches any value in a list of values.

  • : select data that is a range of values.

  • : filter data based on pattern matching.

  • : check if a value is null or not.

Section 3. Joining Multiple Tables

Section 4. Grouping Data

Section 5. Set Operations

Section 6. Grouping sets, Cube, and Rollup

Section 7. Subquery

Section 8. Common Table Expressions

Section 9. Modifying Data

In this section, you will learn how to insert data into a table with the INSERT statement, modify existing data with the UPDATE statement, and remove data with the DELETE statement. Besides, you learn how to use the upsert statement to merge data.

Section 10. Transactions

Section 11. Import & Export Data

You will learn how to import and export PostgreSQL data from and to CSV file format using the copy command.

Section 12. Managing Tables

In this section, you will start exploring the PostgreSQL data types and showing you how to create new tables and modify the structure of the existing tables.

Section 15. Conditional Expressions & Operators

Section 16. PostgreSQL Utilities

Section 17. PostgreSQL Recipes

END OF THE LECTURE

: show you a brief overview of joins in PostgreSQL.

: describes how to use table aliases in the query.

: select rows from one table that has the corresponding rows in other tables.

: select rows from one table that may or may not have the corresponding rows in other tables.

: join a table to itself by comparing a table to itself.

: use the full join to find a row in a table that does not have a matching row in another table.

: produce a Cartesian product of the rows in two or more tables.

: join two or more tables using implicit join condition based on the common column names in the joined tables.

: divide rows into groups and applies an aggregate function on each.

: apply conditions to groups.

: combine result sets of multiple queries into a single result set.

: combine the result sets of two or more queries and returns a single result set that has the rows appear in both result sets.

: return the rows in the first query that does not appear in the output of the second query.

: generate multiple grouping sets in reporting.

: define multiple grouping sets that include all possible combinations of dimensions.

: generate reports that contain totals and subtotals.

: write a query nested inside another query.

: retrieve data by comparing a value with a set of values returned by a subquery.

: query data by comparing a value with a list of values returned by a subquery.

: check for the existence of rows returned by a subquery.

: introduce you to PostgreSQL common table expressions or CTEs.

:discuss the recursive query and learn how to apply it in various contexts.

: guide you on how to insert single row into a table.

: show you how to insert multiple rows into a table.

: update existing data in a table.

: update values in a table based on values in another table.

: delete data in a table.

: insert or update data if the new row already exists in the table.

: show you how to handle transactions in PostgreSQL using BEGIN, COMMIT, and ROLLBACK statements.

: show you how to import CSV file into a table.

: show you how to export tables to a CSV file.

: cover the most commonly used PostgreSQL data types.

: guide you on how to create a new table in the database.

& : shows you how to create a new table from the result set of a query.

column with SERIAL uses SERIAL to add an auto-increment column to a table.

: introduce you to sequences and describe how to use a sequence to generate a sequence of numbers.

: show you how to use the identity column.

: modify the structure of an existing table.

: change the name of the table to a new one.

: show you how to use add one or more columns to an existing table.

: demonstrate how to drop a column of a table.

: show you how to change the data of a column.

: illustrate how to rename one or more columns of a table.

: remove an existing table and all of its dependent objects.

: remove all data in a large table quickly and efficiently.

: show you how to use the temporary table.

: show you how to copy a table to a new one.

: show you how to form conditional queries with CASE expression.

: return the first non-null argument. You can use it to substitute NULL by a default value.

: return NULL if the first argument equals the second one.

: convert from one data type into another e.g., from a string into an integer, from a string into a date.

: show you the most common psql commands that help you interact with psql faster and more effectively.

: describe how to compare data in two tables in a database.

: show you various ways to delete duplicate rows from a table.

: illustrate how to generate a random number in a specific range.

: guide you on how to use the EXPLAIN statement to return the execution plan of a query.

: compare PostgreSQL with MySQL in terms of functionalities.

🐘
https://www.postgresqltutorial.com/
https://www.postgresqltutorial.com/load-postgresql-sample-database/
Select
Column aliases
Order By
Select Distinct
Where
Limit
Fetch
In
Between
Like
Is Null
Joins
Table aliases
Inner Join
Left Join
Self-join
Full Outer Join
Cross Join
Natural Join
Group By
Having
Union
Intersect
Except
Grouping Sets
Cube
Rollup
Subquery
ANY
ALL
EXISTS
PostgreSQL CTE
Recursive query using CTEs
Insert
Insert multiple rows
Update
Update join
Delete
Upsert
PostgreSQL Transactions
Import CSV file into Table
Export PostgreSQL Table to CSV file
Data types
Create table
Select Into
Create table as
Auto-increment
Sequences
Identity column
Alter table
Rename table
Add column
Drop column
Change column data type
Rename column
Drop table
Truncate table
Temporary table
Copy a table
CASE
COALESCE
NULLIF
CAST
psql commands
How to compare two tables
How to delete duplicate rows in PostgreSQL
How to generate a random number in a range
EXPLAIN statement
PostgreSQL vs. MySQL