Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Function management
4. ALTER FUNCTION and RENAME TO

Instruction

Good job! To change the name of a function, we will need to use the ALTER command in combination with the RENAME TO command.

Here we change the name of the get_circle_area(radius decimal) function to circle_area:

ALTER FUNCTION get_circle_area(radius decimal)
RENAME TO circle_area;

As you can see, the first command is ALTER FUNCTION, followed by the name of the original function. Then, we include the types of its arguments to identify the function. We may write the arguments' names and/or modes for legibility. Then comes the RENAME TO command, followed by the new function name (circle_area, in this case).

Exercise

Two exercises before, we modified the get_pi() function so it returns the truncated value of PI: 3.1415. We should follow programming best practices here and reflect our change in the function name.

Rename the function from get_pi() to get_truncated_pi(). Next, invoke the new function to make sure it works properly.