2

I need to safely rename a table and be sure, that all usages of this table in functions are also renamed.

Example:

CREATE TABLE test (
    id serial,
    name varchar(255)
);

CREATE FUNCTION public.last_test() RETURNS SETOF test
    LANGUAGE sql STABLE
AS $$
    SELECT
      *
    FROM
      test
    LIMIT 10;
$$;

ALTER TABLE test RENAME TO tests;

Now, when I look into function last_test, I see, that it still references old test table name.

Is it even possible to rename a table and all it's usages in functions automatically?

AntonAL
  • 121
  • 4

0 Answers0