我正在Postgres数据库上运行一个项目,需要检索数据库中列的注释,以用作表格标题等.我已经看到有几个内置函数(pg_description和col_description),但我无法找到如何使用它们的例子,并且使用它们已经证明是徒劳的.
所以我想知道是否有人能够做到这一点,如果是这样,怎么样?
我试图使用动态SQL在postgres中运行一些查询.
例:
EXECUTE format('SELECT * from result_%s_table', quote_ident((select id from ids where condition = some_condition)))
Run Code Online (Sandbox Code Playgroud)
我必须查询一个表,其格式为result_%s_table,其中,我需要用另一个表替换正确的表名(一个id).
我收到了错误 ERROR: prepared statement "format" does not exist
我想粘贴
123
456
789
Run Code Online (Sandbox Code Playgroud)
成psql,并存储在一些可变多行字符串(即:str)以供以后使用.
那可能吗?现在我收到了unterminated quoted string错误.