How to uninstall oracle_fdw in PostgreSQL

Galaxy Glossary

How do I uninstall oracle_fdw extension in PostgreSQL?

DROP EXTENSION oracle_fdw cleanly removes the Oracle Foreign Data Wrapper and all its dependent objects from the current PostgreSQL database.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Description

Table of Contents

When should I remove oracle_fdw?

Remove the extension when Oracle connectivity is no longer required, you are migrating all data to PostgreSQL, or you need to reclaim superuser privileges that were granted for oracle_fdw.

How do I uninstall oracle_fdw extension?

Run DROP EXTENSION oracle_fdw; in the target database. Add IF EXISTS to avoid errors if the extension is already gone, and use CASCADE to drop views, foreign tables, or objects that depend on oracle_fdw.

What privileges are required?

You need superuser or the CURRENT_USER that owns the extension. Without the proper role, PostgreSQL raises an “must be owner of extension” error.

Does it affect other databases?

No. DROP EXTENSION only affects the current database. Repeat the command in every database that holds oracle_fdw objects.

Best practice: audit dependent objects first

Query pg_depend or use \dx+ oracle_fdw in psql to list dependencies. Refactor or archive foreign tables before executing CASCADE.

Example: uninstalling in an ecommerce schema

The ecommerce team created foreign tables in oracle_inventory. After migrating data to the local Products table, they run:

-- drop Oracle foreign tables first
DROP FOREIGN TABLE IF EXISTS oracle_inventory.product_stock;

-- remove the extension safely
DROP EXTENSION IF EXISTS oracle_fdw CASCADE;

This cleans the schema while preserving native tables like Products, Orders, and Customers.

Verify removal

Run \dx in psql or query pg_extension. oracle_fdw should no longer appear.

Why How to uninstall oracle_fdw in PostgreSQL is important

How to uninstall oracle_fdw in PostgreSQL Example Usage


-- Step-by-step removal in ecommerce database
BEGIN;
-- 1. Check dependencies
SELECT objid::regclass AS dependent_object
FROM pg_depend d
JOIN pg_extension e ON d.refobjid = e.oid
WHERE e.extname = 'oracle_fdw';

-- 2. Drop extension safely
DROP EXTENSION IF EXISTS oracle_fdw CASCADE;
COMMIT;

How to uninstall oracle_fdw in PostgreSQL Syntax


DROP EXTENSION [ IF EXISTS ] oracle_fdw [ CASCADE | RESTRICT ];

-- Examples
-- 1. Simple removal
DROP EXTENSION oracle_fdw;

-- 2. Avoid error if not installed
DROP EXTENSION IF EXISTS oracle_fdw;

-- 3. Remove extension and dependent foreign tables in an ecommerce database
DROP EXTENSION IF EXISTS oracle_fdw CASCADE;

Common Mistakes

Frequently Asked Questions (FAQs)

Can I reinstall oracle_fdw later?

Yes. Use CREATE EXTENSION oracle_fdw; after the shared library is available. Foreign tables must be recreated.

Will DROP EXTENSION delete my native tables?

No. DROP EXTENSION only removes objects that belong to oracle_fdw or depend on it. Regular tables like Products or Orders remain intact.

Is a server restart required?

No restart is needed. The change applies immediately after the transaction commits.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.