PostgreSQL convert columns to rows? Transpose?

前端 未结 5 1053
失恋的感觉
失恋的感觉 2020-11-28 08:50

I have a PostgreSQL function (or table) which gives me the following output:

Sl.no    username    Designation    salary   etc..
 1        A           XYZ             


        
5条回答
  •  一整个雨季
    2020-11-28 09:25

    If (like me) you were needing this information from a bash script, note there is a simple command-line switch for psql to tell it to output table columns as rows:

    psql mydbname -x -A -F= -c "SELECT * FROM foo WHERE id=123"
    

    The -x option is the key to getting psql to output columns as rows.

提交回复
热议问题