Re: DDLs of a Function

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: pratmeht <pratikmehta28(at)gmail(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: DDLs of a Function
Date: 2019-12-17 13:00:43
Message-ID: 201895699817b24357a3d1b01620311549fc6371.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Mon, 2019-12-16 at 22:00 -0700, pratmeht wrote:
> We want to drop a table and recreate it. As we all know, dropping a table
> even drops the dependent objects like views, MVs, functions. I wanted your
> help to get the DDL of the (dependent) function before we can drop the
> table. Once the dropped table is being recreated, this DDL will be helpful
> to recreate that function.
>
> We found a way to get the DDL of the Views and MVs, but not for function! :(
> Can someone please help ?

You can use "pg_get_functiondef":

SELECT pg_get_functiondef('pg_get_functiondef'::regproc);

pg_get_functiondef
---------------------------------------------------------------
CREATE OR REPLACE FUNCTION pg_catalog.pg_get_functiondef(oid)+
RETURNS text +
LANGUAGE internal +
STABLE PARALLEL SAFE STRICT +
AS $function$pg_get_functiondef$function$ +

(1 row)

This article contains something about view dependencies:
https://www.cybertec-postgresql.com/en/tracking-view-dependencies-in-postgresql/

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Zahid Rahman 2019-12-17 21:29:49 401 unauthorised
Previous Message Omkar Dhorge 2019-12-17 05:39:59 Re: DDLs of a Function