Advanced Course

Writing User-Defined Functions in PostgreSQL

Take your PostgreSQL skills to the next level by learning how to write your own functions.

4.89 ★★★★★ ★★★★★ (272 ratings)

3,776 learners enrolled

Lifetime access

limited to this course only

$39

Want a better deal?

Get unlimited lifetime access to all 71 present and future courses

Save $450

Unlimited lifetime access

to all 71 present and future courses

$149 $599

75% OFF

Free trial Yes

Certificate of completion Yes

Time to complete 20 h

Coding challenges 94

Skills you will gain

  • Understand what a user-defined function is and when you should use it.
  • Learn how to create a user-defined function in PostgreSQL.
  • Understand the syntax of PostgreSQL’s most commonly used procedural language, PL/pgSQL.
  • Discover the different types of parameters in PostgreSQL functions (IN, OUT and INOUT).
  • Learn to use the results of a SQL query inside a function.
  • Understand how to nest function calls.
  • Discover how to return a table from a function.

Last reviews

Table of contents

Course progress 0%

Exercises completed 0/94

  1. Introduction to User-Defined Functions

    0/11

    Get familiar with creating functions in PostgreSQL.

  2. Writing Functions in PostgreSQL – the Basics

    0/29

    Get to know the basic syntax of implementing functions in PostgreSQL. Learn about parameter types supported in PostgreSQL functions.

  3. Writing Complex Functions in PostgreSQL

    0/18

    Learn how to use complex statements in functions.

  4. Functions returning tables in PostgreSQL

    0/13

    Discover how you can return tables from functions in PostgreSQL.

  5. Function management

    0/8

    Learn how to create, remove and rename functions in PostgreSQL.

  6. Quiz

    0/15

    Check your knowledge of writng functions in PostgreSQL by implementing a simple Extract-Tranform-Load (ETL) process.

Get the Certificate of Competency in SQL

This certificate will confirm your practical SQL problem-solving skills

Description

Why write your own functions? In PostgreSQL, functions allow you to perform operations that would normally take several queries and round trips. In simple words, this means you'll get your results much faster. User-defined functions extend the functionality of PostgreSQL and add convenience, improve query logic, and allow other applications to reuse your database.

Cover image for the course 'Writing User-Defined Functions in PostgreSQL'

In this course, you'll learn about PL/pgSQL, the most commonly used procedural language in PostgreSQL. You'll get to know the syntax of PL/pgSQL, various types of parameters that functions in PostgreSQL support (IN, OUT, INOUT parameters), and how to use complex statements in a function body. Moreover, you'll learn to write functions with hands-on, practical examples based on real-world use cases. In the final part of the course, you'll write functions implementing a simple ETL (Extract-Transform-Load) process in a data warehouse (DWH).

Writing user-defined functions is something all advanced users of databases should know. This course is ideal for aspiring database programmers and future database administrators (DBAs).

Note: Up until PostgreSQL 11, user-defined functions in PostgreSQL were sometimes also called (and used as) stored procedures. Don't be surprised if you see the term "stored procedure" refer to a user-defined function in Postgres. This course only covers creating user-defined functions in PostgreSQL.

What's in It for Me?

  • 94 interactive exercises. Learn at your own pace, from anywhere and anytime. Interact with hands-on exercises for improved retention.
  • Lifetime access to the course. When you purchase the course, you'll get instant personal access to all of its content.
  • Certificate of completion. After you successfully finish all of the exercises, you'll get a downloadable PDF certificate to showcase your accomplishment.
  • 30-day money-back guarantee. If you're not satisfied with the quality of the course, you can get a refund within 30 days of your purchase.
  • Hints for the exercises. You can ask questions and share insights with other members of our community through the Discuss tab.

What Do You Need to Take This Course?

  • A web browser and an Internet connection.
  • Basic knowledge of SQL.
  • Basic knowledge of programming.

This Course Will Teach You:

  • What a user-defined function is and when you should use it.
  • How to create a user-defined function in PostgreSQL.
  • The syntax of PostgreSQL’s most commonly used procedural language, PL/pgSQL.
  • The different types of parameters in PostgreSQL functions (IN, OUT and INOUT).
  • How you can use results of a SQL query inside a function.
  • How you can nest function calls.
  • How to return a table from a function.

Who Should Take This Course?

  • Students taking course on relational databases.
  • PostgreSQL developers.
  • Beginner Database Administrators (DBAs).
  • People interested in programming relational databases, particularly PostgreSQL.

Reviews (15)

Average rating

4.89/5

★★★★★ ★★★★★ (272 ratings)

5 stars

91%

4 stars

9%

3 stars

0%

2 stars

0%

1 stars

0%