Updated on 2025-05-29 GMT+08:00

DROP PACKAGE

Description

Deletes an existing package or package body.

Precautions

After a package body is dropped, the stored procedures and functions in the package become invalid.

Only the initial user has the permission to perform the DROP operation on the packages of the initial user.

Syntax

DROP PACKAGE [ IF EXISTS ] package_name;

DROP PACKAGE BODY [ IF EXISTS ] package_name;

Parameters

  • IF EXISTS

    Reports a notice instead of an error if the specified stored procedure does not exist.

  • package_name

    Specifies the name of the package to be deleted.

    Value range: an existing package name.

Examples

-- Create an ORA-compatible database.
gaussdb=# CREATE DATABASE ora_compat_db DBCOMPATIBILITY 'ORA';
CREATE DATABASE
gaussdb=# \c ora_compat_db

-- Create a package.
gaussdb=# CREATE OR REPLACE PACKAGE emp_bonus IS
var1 INT:=1;-- Public variable
var2 INT:=2;
PROCEDURE testpro1(var3 INT);-- Public stored procedure, which can be called by external systems.
END emp_bonus;
/

-- Delete the package.
gaussdb=# DROP PACKAGE emp_bonus;

-- Switch back to the initial database and delete the ORA-compatible database. Replace postgres with the actual database name.
gaussdb=# \c postgres
gaussdb=# DROP DATABASE ora_compat_db;

Helpful Links

ALTER PACKAGE and CREATE PACKAGE