May 2019
Intermediate to advanced
600 pages
20h 46m
English
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);'
Read now
Unlock full access