Difficulty: Easy
Correct Answer: ALTER FUNCTION
Explanation:
Introduction / Context:
When underlying tables or dependent objects change, stored program units (such as functions) may need recompilation so the database engine can validate references and refresh metadata. Knowing the correct SQL command avoids runtime errors and invalid status for schema objects.
Given Data / Assumptions:
Concept / Approach:
SQL uses the ALTER verb to modify existing objects. For functions, the standard pattern is ALTER FUNCTION. Some platforms support syntax such as “ALTER FUNCTION f() COMPILE” or require re-issuing the definition through ALTER. Phrases like “SET FUNCTION” or “SET STORED FUNCTION” are not standard SQL DDL commands for recompilation.
Step-by-Step Solution:
Identify the object class: FUNCTION.Select the DDL verb for modifying existing objects: ALTER.Combine into the correct statement: ALTER FUNCTION.
Verification / Alternative check:
DBMS documentation for Oracle, PostgreSQL, SQL Server, and others shows ALTER FUNCTION as the vehicle for compiling, changing attributes, or redefining function bodies (syntax details vary, but the verb remains ALTER).
Why Other Options Are Wrong:
Common Pitfalls:
Dropping and recreating the function unnecessarily (losing privileges or dependencies) instead of using ALTER; forgetting to handle dependent objects that may also need recompilation.
Final Answer:
ALTER FUNCTION
Discussion & Comments