postgresql - 导出到文件时格式化数据?
问题描述
我希望输出文件中的输出格式如下。
Expected OUTPUT:
Table CUSTOMERMSTR
---------------------------
custno cjd custtype
-------------- ----------- ------------
cust123 01-OCT-1900 1
cust123 08-SEP-1997 1
cust123 01-JAN-1996 1
3 rows
截至目前:
Table CUSTOMERMSTR
----------------------------
custno|to_char|custtype
cust123|01-OCT-1900|1
cust123|08-SEP-1997|1
cust123|01-JAN-1996|1
这是我在 UNIX 服务器中的 expdata.psql 文件。这没有给出预期的格式。
请帮助我添加什么以在我的 .psql 脚本中获得所需的输出。
--col custno format 9999999 heading "custno"
--col cjd format A25 heading "cjd"
--col custtype format 999999999 heading "custtype"
\t off
\a
\echo
\echo Table CUSTOMERMSTR
\echo ----------------------------
\echo
select custno,TO_CHAR(cjd,'DD-MON-YYYY'),custtype from CUSTOMERMSTR;