Re: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER - Mailing list pgsql-admin

From David G. Johnston
Subject Re: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER
Date
Msg-id CAKFQuwb-g1f+dWPST3SFqQV6Mqu6d6MyieYxia6YoJpuRtDJgg@mail.gmail.com
Whole thread Raw
In response to RE: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER  (<lennam@incisivetechgroup.com>)
Responses RE: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER
List pgsql-admin
On Tue, Jun 18, 2024 at 12:58 PM <lennam@incisivetechgroup.com> wrote:

 

Following scripts will take care to change schema owner

 

Mk_altr_proc_owner.sql  ( copy past this SQL statement)

SELECT ' alter procedure '||rtrim(nspname)||'.'||ltrim( proname )||' owner to targetschema;'


Maybe using quote_ident to prevent, unlikely as it may be, SQL injection issues.  The trims seem likely to be unnecessary - catalog contents should be clean.
 

  

Psql -h hostname -U ursename -d dbname -t -A -f mk_altr_proc_owner.sql -o altr_proc_owner.sql

 


The script output file is nice to check one's works I guess.  But if you are going to use psql there is the \gexec meta-command that makes this even easier.

David J.

pgsql-admin by date:

Previous
From: Ron Johnson
Date:
Subject: Re: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER
Next
From: "David G. Johnston"
Date:
Subject: Re: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER