是否可以使用pgsql中的\ o选项捕获控制台输出,而不是在命令行中重定向输出(psql >> logfilename)?
日志名称将根据查询输出动态设置。
SELECT current_user AS var1;
\gset
\o analyze_table_:var1.log
\echo 'analyzing table.............'
ANALYZE VERBOSE testtable;
\o
预期在日志中输出:
analyzing table.............
psql:testtable.sql:12: INFO: analyzing "public.testtable"
psql:testtable.sql:12: INFO: "testtable": scanned 1 of 1 pages,containing 4 live rows and 0 dead rows; 4 rows in sample, 4 estimated total rows
ANALYZE