There's more…

If you are extracting values from a table that is being used to create object names, then you may need to use a handy function named quote_ident(). This function puts double quotes around a value if PostgreSQL requires that for an object name, as shown here:

postgres=# SELECT quote_ident('MyCust');
quote_ident
-------------
"MyCust"
(1 row)
postgres=# SELECT quote_ident('mycust');
quote_ident
-------------
mycust
(1 row)

The quote_ident() function may be especially useful if you are creating a table based on a variable name in a PL/pgSQL function, as follows:

EXECUTE 'CREATE TEMP TABLE ' || quote_ident(tablename) ||
'(col1 INTEGER);'