totn PostgreSQL

PostgreSQL Tutorial

PostgreSQL is the world's most advanced open-source relational database technology.

Our tutorial will start with the basics of PostgreSQL such as how to retrieve and manipulate data. Then we will move to the more advanced topics such as how to create tables and users. We will conclude with a review of the functions that are proprietary to PostgreSQL.

With this tutorial, you should be on your way to becoming proficient in PostgreSQL and its programming language.

Prerequisites

There are no prequisities for this PostgreSQL tutorial. You should be able to easily understand this tutorial and learn the basic concepts of PostgreSQL as you progress to the more advanced topics.

Now, let's get started!

Start Tutorial

Or jump directly to a topic in PostgreSQL:

PostgreSQL Functions

Functions - Alphabetical PostgreSQL Functions listed alphabetically
Functions - Category PostgreSQL Functions listed by category

PostgreSQL Keys, Constraints and Indexes

Primary Keys Create, alter, or drop primary keys
Unique Constraints Create, add, and drop unique constraints
Indexes Create, drop and rename indexes (performance tuning)

PostgreSQL Privileges and Passwords

Grant/Revoke Privileges Grant or revoke privileges
Change Password Change a user's password

PostgreSQL Database Administration

Users Database accounts
Vacuum Reclaim unused space in database
AutoVacuum Daemon that automatically reclaims unused space in database

PostgreSQL Programming

Literals (Constants) String, number, date, time, boolean literals
Declaring Variables Declare variables within stored programs
Comments within SQL How to create comments within your SQL statement

PostgreSQL Comparison Operators

Comparison Operators Operators such as =, <>, !=, >, <, and so on

PostgreSQL Query Types

SELECT Statement Retrieve records from a table
SELECT LIMIT Statement Retrieve records from a table and limit results
INSERT Statement Insert records into a table
UPDATE Statement Update records in a table
DELETE Statement Delete records from a table
TRUNCATE TABLE Statement Delete all records from a table (deallocates space)
UNION Operator Combine 2 result sets (removes duplicates)
UNION ALL Operator Combine 2 result sets (includes duplicates)
INTERSECT Operator Intersection of 2 result sets
EXCEPT Operator Result set of one minus the result set of another
Subqueries A query within a query

PostgreSQL Joins

JOIN Tables Inner and Outer joins

PostgreSQL Aliases

ALIASES Create a temporary name for a column or table

PostgreSQL Clauses

DISTINCT Clause Retrieve unique records
FROM Clause List tables and join information
WHERE Clause Filter results
ORDER BY Clause Sort query results
GROUP BY Clause Group by one or more columns
HAVING Clause Restrict the groups of returned rows

PostgreSQL SQL Functions

COUNT Function Return the count of an expression
SUM Function Return the sum of an expression
MIN Function Return the min of an expression
MAX Function Return the max of an expression
AVG Function Return the average of an expression

PostgreSQL Conditions

AND Condition 2 or more conditions to be met
OR Condition Any one of the conditions are met
AND and OR Combine AND and OR conditions
LIKE Condition Use wildcards in a WHERE clause
IN Condition Alternative to multiple OR conditions
NOT Condition Negate a condition
IS NULL Condition Test for a NULL value
IS NOT NULL Condition Test for a NOT NULL value
BETWEEN Condition Retrieve within a range (inclusive)
EXISTS Condition Condition is met if subquery returns at least one row

PostgreSQL Tables

CREATE TABLE Create a table
CREATE TABLE AS Create a table from another table's definition and data
ALTER TABLE Add, modify, delete columns in a table; rename a table
DROP TABLE Delete a table
VIEW Virtual tables (views of other tables)

PostgreSQL Data Types

Data Types Data Types in PostgreSQL