pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@gmail.com>
To: pgsql-sql@postgresql.org
Cc: Carlos Mennens <carlos.mennens@gmail.com>
Subject: Re: Display Length Between Var & Varchar
Date: Tue, 31 Jan 2012 20:13:53 -0800
Message-ID: <201201312013.53423.adrian.klaver@gmail.com> (raw)
In-Reply-To: <CAAQLLO6wQ0b--_Y1LVR5S68HW6Wi7msOAmvELhaLE7cNmOtFCw@mail.gmail.com>
References: <CAAQLLO6wQ0b--_Y1LVR5S68HW6Wi7msOAmvELhaLE7cNmOtFCw@mail.gmail.com>

On Tuesday, January 31, 2012 8:08:06 pm Carlos Mennens wrote:
> I've noticed when I set a field to char, it takes up lots of space over
> varchar:
> 
> iamunix=# SELECT * FROM music;
>  id |       band        |          album           |    date    |
>                   asin                        |    label
> ----+-------------------+--------------------------+------------+----------
> ------------------------------------------+-------------- 1 | Dance Gavin
> Dance | Downtown Battle Mountain | 2007-05-15 |
> B000OQF4PQ                                         | Rise Records
> (1 row)
> 
> iamunix=# SELECT * FROM music;
>  id |       band        |          album           |    date    |
> asin    |    label
> ----+-------------------+--------------------------+------------+----------
> --+-------------- 1 | Dance Gavin Dance | Downtown Battle Mountain |
> 2007-05-15 |
> B000OQF4PQ | Rise Records
> (1 row)
> 
> I don't know how well it will show in plain text via email but does
> anyone know why the field display width is wasted with so much white
> space when set to char?

You will find that the Manual is very helpful in this regard:)

http://www.postgresql.org/docs/9.0/interactive/datatype-character.html
character varying(n), varchar(n)	variable-length with limit
character(n), char(n)	fixed-length, blank padded

-- 
Adrian Klaver
adrian.klaver@gmail.com



view thread (2+ messages)

Message-ID: <201201312013.53423.adrian.klaver@gmail.com>
Permalink:  ../201201312013.53423.adrian.klaver@gmail.com/
Also on:    postgresql.org/message-id/201201312013.53423.adrian.klaver@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: adrian.klaver@gmail.com, carlos.mennens@gmail.com
  Subject: Re: Display Length Between Var & Varchar
  In-Reply-To: <201201312013.53423.adrian.klaver@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox