Unix Technical Forum

How to delete all operators

This is a discussion on How to delete all operators within the Pgsql General forums, part of the PostgreSQL category; --> Hi, I have a database with operators and functions in plpgsql. To update the data to the latest version ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 09:03 AM
Martin Pohl
 
Posts: n/a
Default How to delete all operators


Hi,

I have a database with operators and functions in plpgsql.
To update the data to the latest version I would like to drop all operators.
There might be some, that I don't know. I don't have access to the database,
but have to write a script, that will update the data.

Is there any way to drop all operators (given they are all in the schema
"public) in a script?

Something like (pseudocode):
Drop all operators in schema "public"

Thanks in advance for answers

--
E-Mails und Internet immer und überall!
1&1 PocketWeb, perfekt mit GMX: http://www.gmx.net/de/go/pocketweb

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 09:05 AM
=?ISO-8859-1?Q?William_Leite_Ara=FAjo?=
 
Posts: n/a
Default Re: How to delete all operators

You can make a function to do this.

CREATE FUNCTION drop_operators(text) RETURNS BOOL AS
$$
DECLARE
op record;
BEGIN
FOR op IN SELECT opname
FROM pg_operator as o left join pg_namespace as n on (
o.oprnamespace = n.oid)
WHERE nspname = $1
LOOP
EXECUTE 'DROP OPERATOR '||quote_literal(op.opname)||';';
END LOOP;
RETURN TRUE;
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE;

And so: SELECT drop_operators('public');

On 3/31/06, Martin Pohl <Nilpherd@gmx.net> wrote:
>
>
> Hi,
>
> I have a database with operators and functions in plpgsql.
> To update the data to the latest version I would like to drop all
> operators.
> There might be some, that I don't know. I don't have access to the
> database,
> but have to write a script, that will update the data.
>
> Is there any way to drop all operators (given they are all in the schema
> "public) in a script?
>
> Something like (pseudocode):
> Drop all operators in schema "public"
>
> Thanks in advance for answers
>
> --
> E-Mails und Internet immer und überall!
> 1&1 PocketWeb, perfekt mit GMX: http://www.gmx.net/de/go/pocketweb
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>




--
William Leite Araújo

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 09:06 AM
Jim Nasby
 
Posts: n/a
Default Re: How to delete all operators

On Mar 31, 2006, at 5:17 AM, Martin Pohl wrote:
> Is there any way to drop all operators (given they are all in the
> schema
> "public) in a script?
>
> Something like (pseudocode):
> Drop all operators in schema "public"


Nope, though information_schema or the newsysviews project on
pgFoundry might make it easier to get that list of operators.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461



---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:27 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com