PostgreSQL Basics
Learn PostgreSQL data operations with practical guides to SELECT, filters, joins, inserts, updates, deletes, and grouping.
This chapter introduces the knowledge related to data operations in PostgreSQL, including inserting data rows, deleting data rows, updating/modifying, querying data, filtering data, etc.
-
PostgreSQL SELECT
This article describes the basic syntax of theSELECTstatement and how to use theSELECTstatement to query data from a data table. -
PostgreSQL WHERE
This article describes how to useWHEREclause in aSELECTstatement to filter rows in PostgreSQL. -
PostgreSQL ORDER BY
This article describes how to use theORDER BYclause sort the result set returned by theSELECTstatement in PostgreSQL. -
PostgreSQL FETCH
This article describes how to use theFETCHclause in the PostgreSQLSELECTstatement to limit the number of rows returned by a query. -
PostgreSQL LIMIT
This article describes how to use theLIMITclause in theSELECTstatement to limit the number of rows returned by a query. -
PostgreSQL OFFSET
This article describes how to use theOFFSETclause in aSELECTstatement to skip a specified number of rows. -
PostgreSQL DISTINCT
This article describes how to use in PostgreSQLDISTINCTto return a result set with no duplicate rows. -
PostgreSQL Column Alias
This article describes aliasing a column in PostgreSQL to improve readability of the output. -
PostgreSQL Table Alias
This article describes how to use table aliases in PostgreSQL. -
PostgreSQL IN
This article describes how to use theINoperator check if a list of values contains a specified value. -
PostgreSQL BETWEEN
This article describes how to use theBETWEENoperator check if a value is in an interval. -
PostgreSQL LIKE
This article describes how to use theLIKEoperator check if a text matches a specified pattern. -
PostgreSQL IS NULL
This article describes how to use theIS NULLoperator check if a value isNULL. -
PostgreSQL EXISTS
This article describes how to use theEXISTSoperator check if a subquery returns rows. -
PostgreSQL ALL
This article describes how to use theALLoperator compare a value with all the values returned by a subquery. -
PostgreSQL ANY
This article describes how to use theANYoperator check if at least one value in a set of values satisfies the specified condition. -
PostgreSQL GROUP BY
This article describes how to use theGROUP BYclause in a PostgreSQLSELECTstatement to group rows according to a specified column or expression. -
PostgreSQL HAVING
This article describes how to use theHAVINGclause specify filter conditions for grouped queries. -
PostgreSQL GROUPING SETS
This article describes how to useGROUPING SETSin aGROUP BYclause to generate a report on multiple dimensions in one query. -
PostgreSQL ROLLUP
This article describes how to useROLLUPin aGROUP BYclause to generate a report on multiple dimensions in one query. -
PostgreSQL CUBE
This article describes how to useCUBEin aGROUP BYclause to generate a report on multiple dimensions in one query. -
PostgreSQL JOIN
This article introduces join statements in PostgreSQL, including cross join, inner join, natural join, left join, right join, and full join. -
PostgreSQL Subqueries
This article describes how to use subqueries in PostgreSQL. -
PostgreSQL CTE
This article describes how to use common table expressions in PostgreSQL. -
PostgreSQL UNION
This article describes how to merge two result sets using theUNIONoperator. -
PostgreSQL INTERSECT
This article describes how to use theINTERSECToperator to compute the intersection of two sets. -
PostgreSQL EXCEPT
This article describes how to use theEXCEPToperator get a difference from two sets. -
PostgreSQL INSERT
Learn PostgreSQL INSERT syntax, conflict handling, and how RETURNING reports inserted or updated rows. -
UPSERT: ON CONFLICT
Use PostgreSQL INSERT ON CONFLICT to skip duplicate rows or update them, with conflict targets, EXCLUDED, and RETURNING examples. -
PostgreSQL UPDATE
Learn PostgreSQL UPDATE syntax, filter rows safely, and return changed values with RETURNING. -
PostgreSQL UPDATE...FROM
Learn PostgreSQL UPDATE FROM syntax with a working example, a correct join condition, and a warning about duplicate source matches. -
PostgreSQL RETURNING OLD and NEW
PostgreSQL 18 lets INSERT, UPDATE, DELETE, and MERGE return OLD and NEW row values in one statement. See syntax and runnable examples. -
PostgreSQL DELETE
Learn PostgreSQL DELETE syntax, choose rows safely, and return deleted values with RETURNING. -
PostgreSQL TRUNCATE
This article will describes how to use theTRUNCATE TABLEstatement to empty one or more tables. -
PostgreSQL CASE
This article describes how to implement logical processing using PostgreSQL CASE conditional expressions.