PostgreSQL tutorial
This PostgreSQL Tutorial course teaches you how to use basics of PostgreSQL programming language. The PostgreSQL Tutorial is designed for beginners and advanced developers.
In PostgreSQL are four procedural languages with you can write functions:
PL/pgSQL
PL/Tcl
PL/Perl
PL/Python
This postgresql tutorial will be concentrated on PL/pgSQL language.
The basic objects of PostgreSQL are: tables, columns, indexes, constraints, functions, triggers.
To modify objects is used create, insert, update, select, delete, drop and alter.
1. Introduction to PostgreSQL
- PostgreSQL Create Table – shows you how to create table in a PostgreSQL database.
- PostgreSQL Insert – insert rows into a table from a PostgreSQL database.
- PostgreSQL Select – returns rows from a table.
- PostgreSQL Update – change the value of the columns in a table.
- PostgreSQL Delete – delete rows from a table.
2. Conditional Statements
- PostgreSQL IF – example of the IF statement.
- PostgreSQL IF – Else – example of the IF – Else statement.
- PostgreSQL IF – Elsif – Else – learn how to use conditional statements.
- PostgreSQL Case – example of the CASE statement.
- PostgreSQL LOOP – example of the LOOP statement.
3. Create Function
- PostgreSQL Create Function – shows you how to create function in the PostgreSQL database.
4. Create Trigger
- PostgreSQL Create Trigger – syntax and example of how to create trigger in the PostgreSQL database.
5. View
- PostgreSQL View – syntax and example of how to create and use a view.
6. Aggregate functions
- PostgreSQL AVG – returns the average in a select statement.
- PostgreSQL MAX – returns the maximum value in a select statement.
- PostgreSQL MIN – returns the minimum value in a select statement.
- PostgreSQL SUM – returns the sum value of all rows in a select statement.
7. PostgreSQL Tutorial
- PostgreSQL Tutorial – basic commands of PostgreSQL language.
PL/pgSQL – SQL Procedural Language
The basic commands of PL/pgSQL – SQL Procedural Language:
- PostgreSQL Create Table
- PostgreSQL Drop Table
- PostgreSQL Select
- PostgreSQL Insert
- PostgreSQL Update
- PostgreSQL Delete
- PostgreSQL Distinct
- PostgreSQL Where
- PostgreSQL And – Or
- PostgreSQL Between
- PostgreSQL Like
- PostgreSQL Order By
- PostgreSQL Group By
- PostgreSQL Having
- PostgreSQL Count
- PostgreSQL AVG
- PostgreSQL MAX
- PostgreSQL MIN
- PostgreSQL SUM
- PostgreSQL View
- PostgreSQL Create Function
- PostgreSQL Create Trigger
Alter Examples
- Add primary key to existing table
- Add foreign key constraint to table
- Add unique key constraint to table
- Add column to existing table
- Add multiple columns to existing table
- Drop column from existing table
- Drop multiple columns from table
- Rename column table
- Rename name of existing table
- Add check constraint to a table
- Remove check constraint from table
PostgreSQL error messages help
- Error messages help
- Column must appear in the GROUP BY clause
- Column specified more than once
- Constraint for relation already exists
- Constraint of relation does not exist
- Control reaches end of function without return
- ERROR: cannot begin/end transactions in PL/pgSQL
- Duplicate key value violates unique constraint
- Duplicate key value violates NOT NULL unique constraint
- INSERT has more target columns than expressions
- Invalid input syntax for type boolean
- Multiple primary keys for table are not allowed
- Negative substring length not allowed
- Null value in column violates not-null constraint
- PostgreSQL Numeric field overflow
- Relation does not exist
- Value too long for type character varying or type numeric