To Drop all objects from Postgres Schema there could be following two approaches: Drop Schema with cascade all and re-create it again. In some cases where you dont want to/not allowed to drop and recreate schema, its easy to look for objects on current schema and drop them. following script would help to do so, Create function which would do the task and then drop that function too. --- CREATE OR REPLACE FUNCTION drop_DB_objects() RETURNS VOID AS $$ DECLARE rd_object RECORD; v_idx_statement VARCHAR(500); BEGIN ---1. Dropping all stored functions RAISE NOTICE '%', 'Dropping all stored functions...'; FOR rd_object IN ( SELECT format('%I.%I(%s)', ns.nspname, p.proname, oidvectortypes(p.proargtypes)) as functionDef FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = current_schema AND p.proname <...
Well, Finally we completed that presentation today. Thanks to everyone for being there and participating in discussion.....
ReplyDelete