pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Display Length Between Var & Varchar
2+ messages / 2 participants
[nested] [flat]

* Display Length Between Var & Varchar
@ 2012-02-01 04:08  Carlos Mennens <carlos.mennens@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Carlos Mennens @ 2012-02-01 04:08 UTC (permalink / raw)
  To: pgsql-sql

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?



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Display Length Between Var & Varchar
@ 2012-02-01 04:13  Adrian Klaver <adrian.klaver@gmail.com>
  parent: Carlos Mennens <carlos.mennens@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Adrian Klaver @ 2012-02-01 04:13 UTC (permalink / raw)
  To: pgsql-sql; +Cc: Carlos Mennens <carlos.mennens@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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2012-02-01 04:13 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-02-01 04:08 Display Length Between Var & Varchar Carlos Mennens <carlos.mennens@gmail.com>
2012-02-01 04:13 ` Adrian Klaver <adrian.klaver@gmail.com>

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