Alternate output format for psql

前端 未结 7 1855
迷失自我
迷失自我 2020-12-04 04:44

I am using PostgreSQL 8.4 on Ubuntu. I have a table with columns c1 through cN. The columns are wide enough that selecting all columns causes a row

7条回答
  •  Happy的楠姐
    2020-12-04 04:54

    You have so many choices, how could you be confused :-)? The main controls are:

    # \pset format
    # \H
    # \x
    # \pset pager off
    

    Each has options and interactions with the others. The most automatic options are:

    # \x off;\pset format wrapped
    # \x auto
    

    The newer "\x auto" option switches to line-by-line display only "if needed".

    -[ RECORD 1 ]---------------
    id          | 6
    description | This is a gallery of oilve oil brands.
    authority   | I love olive oil, and wanted to create a place for
    reviews and comments on various types.
    -[ RECORD 2 ]---------------
    id          | 19
    description | XXX Test A 
    authority   | Testing
    

    The older "\pset format wrapped" is similar in that it tries to fit the data neatly on screen, but falls back to unaligned if the headers won't fit. Here's an example of wrapped:

     id |          description           |            authority            
    ----+--------------------------------+---------------------------------
      6 | This is a gallery of oilve     | I love olive oil, and wanted to
        ; oil brands.                    ;  create a place for reviews and
        ;                                ;  comments on various types.
     19 | Test Test A                    | Testing
    

提交回复
热议问题