Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
1. Welcome
Summary

Instruction

Welcome to our course on user-defined functions in PosrgreSQL! This course will teach you the basics of creating functions in PostgreSQL.

Note that we use the term "function". In PostgreSQL 11, a new notion of stored procedures was introduced. This course only covers creating user-defined functions in PostgreSQL. Up till PostgreSQL 11, people often called (and used) user-defined functions as stored procedures. Don't be surprised if you see the term "stored procedure" refer to a user-defined function in Postgres.

In this part of our course, we'll introduce you to the concept of user-defined functions and describe the main benefits of using them. We'll also introduce and briefly explain the syntax of functions. Finally, and most importantly, we'll show you some practical examples of using functions.

But first and foremost, let's review the database tables we are going to use. The first table is named circle.

Exercise

Select all columns from the circle table.

This table contains attributes related to a circle object, including the following:

  • id
  • radius
  • diameter
  • circumference
  • area

The last two attributes/columns (circumference and area) are going to be calculated and updated by new functions that we will create later.