Spacing in output

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jerome Lyles

    Spacing in output

    I have a small training database: sql_tutorial. It works fine but the spacing
    between the output lines is too much. This is the way it looks when I copy
    and paste from the Konsole to this email:

    sql_tutorial=> SELECT prod_name FROM Products;
    prod_name
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    8 inch teddy bear
    12 inch teddy bear
    18 inch teddy bear


    This is the way it looks on the Konsole:

    sql_tutorial=> SELECT prod_name FROM Products;

    prod_name
    --------------------------------------------------------------------------------------
    --------------------------------------------------------------------------------------
    --------------------------------------------------------------------------------------
    ------------------
    8 inch teddy bear


    12 inch teddy bear


    18 inch teddy bear

    How can I change the Konsole output to look like the first example?
    Thanks,
    Jerome

    ---------------------------(end of broadcast)---------------------------
    TIP 8: explain analyze is your friend

  • Thomas F.O'Connell

    #2
    Re: Spacing in output

    The spacing in Konsole is directly related to the wrapping that it's
    doing based on the size of the prod_name field (I.e., length in terms
    of characters).

    You can alter the format settings of psql. See:



    -tfo

    On Sep 14, 2004, at 4:05 PM, Jerome Lyles wrote:
    [color=blue]
    > I have a small training database: sql_tutorial. It works fine but the
    > spacing
    > between the output lines is too much. This is the way it looks when I
    > copy
    > and paste from the Konsole to this email:
    >
    > sql_tutorial=> SELECT prod_name FROM Products;
    > prod_name
    > -----------------------------------------------------------------------
    > -----------------------------------------------------------------------
    > -----------------------------------------------------------------------
    > --------------------------------------------
    > 8 inch teddy bear
    > 12 inch teddy bear
    > 18 inch teddy bear
    >
    >
    > This is the way it looks on the Konsole:
    >
    > sql_tutorial=> SELECT prod_name FROM Products;
    >
    > prod_name
    > -----------------------------------------------------------------------
    > ---------------
    > -----------------------------------------------------------------------
    > ---------------
    > -----------------------------------------------------------------------
    > ---------------
    > ------------------
    > 8 inch teddy bear
    >
    >
    > 12 inch teddy bear
    >
    >
    > 18 inch teddy bear
    >
    > How can I change the Konsole output to look like the first example?
    > Thanks,
    > Jerome
    >
    > ---------------------------(end of
    > broadcast)---------------------------
    > TIP 8: explain analyze is your friend[/color]


    ---------------------------(end of broadcast)---------------------------
    TIP 8: explain analyze is your friend

    Comment

    • David Fetter

      #3
      Re: Spacing in output

      On Tue, Sep 14, 2004 at 11:05:46AM -1000, Jerome Lyles wrote:[color=blue]
      > I have a small training database: sql_tutorial. It works fine but the spacing
      > between the output lines is too much. This is the way it looks when I copy
      > and paste from the Konsole to this email:
      >
      > sql_tutorial=> SELECT prod_name FROM Products;[/color]

      Is prod_name a char(n) for some large n?

      Cheers,
      D[color=blue]
      > prod_name
      > -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      > 8 inch teddy bear
      > 12 inch teddy bear
      > 18 inch teddy bear
      >
      >
      > This is the way it looks on the Konsole:
      >
      > sql_tutorial=> SELECT prod_name FROM Products;
      >
      > prod_name
      > --------------------------------------------------------------------------------------
      > --------------------------------------------------------------------------------------
      > --------------------------------------------------------------------------------------
      > ------------------
      > 8 inch teddy bear
      >
      >
      > 12 inch teddy bear
      >
      >
      > 18 inch teddy bear
      >
      > How can I change the Konsole output to look like the first example?
      > Thanks,
      > Jerome
      >
      > ---------------------------(end of broadcast)---------------------------
      > TIP 8: explain analyze is your friend[/color]

      --
      David Fetter david@fetter.or g http://fetter.org/
      phone: +1 510 893 6100 mobile: +1 415 235 3778

      Remember to vote!

      ---------------------------(end of broadcast)---------------------------
      TIP 4: Don't 'kill -9' the postmaster

      Comment

      • Jerome Lyles

        #4
        Re: Spacing in output

        On Tuesday 14 September 2004 11:27 am, David Fetter wrote:[color=blue]
        > On Tue, Sep 14, 2004 at 11:05:46AM -1000, Jerome Lyles wrote:[color=green]
        > > I have a small training database: sql_tutorial. It works fine but the
        > > spacing between the output lines is too much. This is the way it looks
        > > when I copy and paste from the Konsole to this email:
        > >
        > > sql_tutorial=> SELECT prod_name FROM Products;[/color]
        >
        > Is prod_name a char(n) for some large n?
        >
        > Cheers,
        > D[/color]
        char(255)
        Jerome

        ---------------------------(end of broadcast)---------------------------
        TIP 3: if posting/reading through Usenet, please send an appropriate
        subscribe-nomail command to majordomo@postg resql.org so that your
        message can get through to the mailing list cleanly

        Comment

        • David Fetter

          #5
          Re: Spacing in output

          On Tue, Sep 14, 2004 at 06:37:40PM -1000, Jerome Lyles wrote:[color=blue]
          > On Tuesday 14 September 2004 11:27 am, David Fetter wrote:[color=green]
          > > On Tue, Sep 14, 2004 at 11:05:46AM -1000, Jerome Lyles wrote:[color=darkred]
          > > > I have a small training database: sql_tutorial. It works fine
          > > > but the spacing between the output lines is too much. This is
          > > > the way it looks when I copy and paste from the Konsole to this
          > > > email:[/color][/color][/color]
          [color=blue][color=green][color=darkred]
          > > > sql_tutorial=> SELECT prod_name FROM Products;[/color]
          > >
          > > Is prod_name a char(n) for some large n?
          > >
          > > Cheers,
          > > D[/color]
          > char(255)[/color]

          Well, Don't Do That, Then. TEXT is a great type for storing text.
          VARCHAR(n) is a TEXT with a maximum length constraint, and CHAR(n)
          (fixed length) is pretty nearly obsolete.

          Cheers,
          D
          --
          David Fetter david@fetter.or g http://fetter.org/
          phone: +1 510 893 6100 mobile: +1 415 235 3778

          Remember to vote!

          ---------------------------(end of broadcast)---------------------------
          TIP 9: the planner will ignore your desire to choose an index scan if your
          joining column's datatypes do not match

          Comment

          • Jerome Lyles

            #6
            Re: Spacing in output

            On Wednesday 15 September 2004 05:24 am, David Fetter wrote:[color=blue]
            > On Tue, Sep 14, 2004 at 06:37:40PM -1000, Jerome Lyles wrote:[color=green]
            > > On Tuesday 14 September 2004 11:27 am, David Fetter wrote:[color=darkred]
            > > > On Tue, Sep 14, 2004 at 11:05:46AM -1000, Jerome Lyles wrote:
            > > > > I have a small training database: sql_tutorial. It works fine
            > > > > but the spacing between the output lines is too much. This is
            > > > > the way it looks when I copy and paste from the Konsole to this
            > > > > email:
            > > > >
            > > > > sql_tutorial=> SELECT prod_name FROM Products;
            > > >
            > > > Is prod_name a char(n) for some large n?
            > > >
            > > > Cheers,
            > > > D[/color]
            > >
            > > char(255)[/color]
            >
            > Well, Don't Do That, Then. TEXT is a great type for storing text.
            > VARCHAR(n) is a TEXT with a maximum length constraint, and CHAR(n)
            > (fixed length) is pretty nearly obsolete.
            >
            > Cheers,
            > D[/color]
            This is amazing. Im using a book called 'Teach Yourself SQL in 10 minutes'
            with a 2004 copyright and this is the second example of obsolete TEXT type
            used in the examples so far.
            Jerome

            ---------------------------(end of broadcast)---------------------------
            TIP 5: Have you checked our extensive FAQ?



            Comment

            • Rolf Østvik

              #7
              Re: Spacing in output

              susemail@hawaii .rr.com (Jerome Lyles) wrote in
              news:2004091411 05.46091.susema il@hawaii.rr.co m:
              [color=blue]
              > I have a small training database: sql_tutorial. It works fine but the[/color]
              spacing[color=blue]
              > between the output lines is too much. This is the way it looks when I[/color]
              copy[color=blue]
              > and paste from the Konsole to this email:[/color]


              the simplest is
              SELECT prod_name::text FROM products;

              (will cast the char(255) column to text and in the process removes all
              trailing spaces.)

              or use trim function to remove trailing spaces.

              --
              Rolf

              Comment

              Working...