Re: Display Length Between Var & Varchar

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Cc: Carlos Mennens <carlos(dot)mennens(at)gmail(dot)com>
Subject: Re: Display Length Between Var & Varchar
Date: 2012-02-01 04:13:53
Message-ID: 201201312013.53423.adrian.klaver@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2012-02-01 04:47:11 Re: Fw: Re: [SQL] pg_dump not correctly saving schema with partitioned tables?
Previous Message Carlos Mennens 2012-02-01 04:08:06 Display Length Between Var & Varchar