Skip to content
  • Rudy Rodarte – SQL Server DBA
  • Technologies Covered

rudy dot dev

Rudy Rodarte's dev site

Show Function Body in PostgreSQL

Display function definitions in PSQL

Posted on 2024-07-262024-07-26 By RudyAdmin

Most of the time, when I am working in PostgreSQL I am either in DBeaver or Datagrip. Both of these tools are useful GUIs for interacting with many different database products. Here is an example from Datagrip, where we are looking at a simple function definition.

Jetbrains Datagrip showing function definition.

However, I occasionally find myself inside a PSQL prompt, without access to my usual GUIs. PostgreSQL has several commands that will display database object definitions directly, to the PSQL prompt. In this example, we can easily view function definitions from within PSQL.

— Display function definition in PostgreSQL
— Mostrar el codigo de una función en PostgreSQL
SELECT pg_get_functiondef('function_name_here'::regproc);
view raw pg_get_functiondef.sql hosted with ❤ by GitHub

The command pg_get_functiondef will display the function definition using only the function name.

pg_get_functiondef in PostgreSQL

The pg_get_functiondef command is a great addition to your PostgreSQL toolbox.

postgresql Tags:github, postgres, postresql

Post navigation

Previous Post: Get current PostgreSQL Sessions

Related Posts

Arrows flowing from a computer Get current PostgreSQL Sessions postgresql
  • Twitter
  • Instagram
  • Facebook

Copyright © 2025 rudy dot dev.

Powered by PressBook Grid Dark theme