How to use to_regclass with uppercase table names? I am using to_regclass() to check if a table exists (from here). This works for lowercase table names, but for table names with capital letters it always returns NULL, even when the table exists:

CREATE TABLE "asdf" (s text);
CREATE TABLE "FooBar" (s text);

SELECT to_regclass('asdf'); --     -&gt; "asdf"
SELECT to_regclass('FooBar'); --   -&gt; NULL
SELECT to_regclass('foobar'); --   -&gt; NULL


Fiddle
Once you start using those dreaded double quotes, you have to use them always:

SELECT to_regclass('"FooBar"');


(another good example why you should avoid those dreaded quoted identifiers)