本文向您展示如何使用DROP FUNCTION
从Oracle数据库中删除一个函数。
1. DROP功能示例
1.1创建一个函数get_current_month
。 然后,我们将使用DROP FUNCTION
语句删除该函数。
--Creating function
CREATE OR REPLACE FUNCTION get_current_month
RETURN VARCHAR2 IS
curr_month VARCHAR2(10);
BEGIN
SELECT to_char(sysdate, 'MONTH') INTO curr_month FROM dual;
return curr_month;
END get_current_month;
1.2运行它。
select get_current_month() from dual;
-- AUGUST
1.3删除函数get_current_month
。
DROP FUNCTION GET_CURRENT_MONTH;
-- function GET_CURRENT_MONTH dropped.
1.4再次运行删除的函数get_current_month
。
select get_current_month() from dual;
-- ORA-00904: "GET_CURRENT_MONTH": invalid identifier
-- 00904. 00000 - "%s: invalid identifier"
参考文献
翻译自: https://mkyong.com/oracle/oracle-plsql-drop-function-example/