Skip to content

Instantly share code, notes, and snippets.

@ichux
Last active September 15, 2018 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ichux/8119b539a836c682e3c7f0ebc5df655e to your computer and use it in GitHub Desktop.
Save ichux/8119b539a836c682e3c7f0ebc5df655e to your computer and use it in GitHub Desktop.
List all the tables in Postgres public schema
CREATE OR REPLACE FUNCTION public.list_public_tables()
RETURNS TABLE(name character varying)
LANGUAGE plpgsql
AS $function$
BEGIN
FOR name IN SELECT quote_ident(table_name) FROM information_schema.tables WHERE table_schema = 'public' LOOP
RETURN NEXT;
END LOOP;
END;
$function$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment