Thread: 7.0.2: missing CREATE DATABASE documentation

7.0.2: missing CREATE DATABASE documentation

From
"Albert REINER"
Date:
Saluton,

I just found that the documentation for CREATE DATABASE is not
complete:

,----[ pslq ]
| albert=> \h create database
| Command:     CREATE DATABASE
| Description: Creates a new database
| Syntax:
| CREATE DATABASE name [ WITH LOCATION = 'dbpath' ]
`----

Similarly in the documentation in .../user/sql-createdatabase.htm:
there is at least the optional WITH ENCODING = '...';

Albert.


--

--------------------------------------------------------------------------
Albert Reiner                                   <areiner@tph.tuwien.ac.at>
Deutsch       *       English       *       Esperanto       *       Latine
--------------------------------------------------------------------------

Trailing spaces in char or varchar fields

From
"Huy Do"
Date:
Hi,

Is there a way to get postgres to keep the trailing spaces
in a field. I have an existing database which I am porting
to postgresql. This database allows fields to have trailing
spaces and many key fields have trailing spaces to distinguish
uniqueness (i know this is bad but it's legacy stuff).

When I dump my database and try to copy it into postgresql, it
complains about duplicate keys because postgres is trimming the
spaces.

Can anyone help ?

Thanks so much

Huy

Re: Trailing spaces in char or varchar fields

From
Tom Lane
Date:
"Huy Do" <huy@travel.com.au> writes:
> Is there a way to get postgres to keep the trailing spaces
> in a field. I have an existing database which I am porting
> to postgresql. This database allows fields to have trailing
> spaces and many key fields have trailing spaces to distinguish
> uniqueness (i know this is bad but it's legacy stuff).
> When I dump my database and try to copy it into postgresql, it
> complains about duplicate keys because postgres is trimming the
> spaces.

Postgres does not trim trailing spaces.  I suspect that that behavior
is coming from whatever tool you used to transfer the data.

            regards, tom lane

RE: Trailing spaces in char or varchar fields

From
"Huy Do"
Date:

> -----Original Message-----
> From: pgsql-novice-owner@postgresql.org
> [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of Tom Lane
> Sent: Friday, January 05, 2001 11:26 AM
> To: Huy Do
> Cc: PostgreSQL-Novice
> Subject: Re: Trailing spaces in char or varchar fields
>
>
> "Huy Do" <huy@travel.com.au> writes:
> > Is there a way to get postgres to keep the trailing spaces
> > in a field. I have an existing database which I am porting
> > to postgresql. This database allows fields to have trailing
> > spaces and many key fields have trailing spaces to distinguish
> > uniqueness (i know this is bad but it's legacy stuff).
> > When I dump my database and try to copy it into postgresql, it
> > complains about duplicate keys because postgres is trimming the
> > spaces.
>
> Postgres does not trim trailing spaces.  I suspect that that behavior
> is coming from whatever tool you used to transfer the data.
>
>             regards, tom lane
>

Sorry, i just got a bit mixed up. What I really meant was that postgres
pads char fields. Varchar fields aren't padded so my question now is,
is there any major disadvantages of changing all my char fields to
varchar fields or should i just stick to changing those that are absolutely
necessary. The fields which I will be changing will be primary keys so I
think there should be some performance trade offs.

Thanks

Huy

Re: Trailing spaces in char or varchar fields

From
Tom Lane
Date:
"Huy Do" <huy@travel.com.au> writes:
> is there any major disadvantages of changing all my char fields to
> varchar fields

No.  Stop worrying about micro-optimization and instead worry about
picking the data type that describes the semantics of your data.
If the presence or absence of a trailing space makes a difference
to you, then you should be using varchar (or text).

            regards, tom lane

Re: Trailing spaces in char or varchar fields

From
"Anthony E . Greene"
Date:
On Thu, 04 Jan 2001 20:26:11 Tom Lane wrote:
>"Huy Do" <huy@travel.com.au> writes:
>> Is there a way to get postgres to keep the trailing spaces
>> in a field. I have an existing database which I am porting
>> to postgresql. This database allows fields to have trailing
>> spaces and many key fields have trailing spaces to distinguish
>> uniqueness (i know this is bad but it's legacy stuff).
>> When I dump my database and try to copy it into postgresql, it
>> complains about duplicate keys because postgres is trimming the
>> spaces.
>
>Postgres does not trim trailing spaces.  I suspect that that behavior
>is coming from whatever tool you used to transfer the data.
>
>            regards, tom lane

I have found in testing with pgsql that trailing spaces are ignored in
fixed-length char fields. In varchar fields, trailing spaces are
significant.

--
Anthony E. Greene <agreene@pobox.com> <http://www.pobox.com/~agreene/>
PGP Key: 0x6C94239D/7B3D BD7D 7D91 1B44 BA26  C484 A42A 60DD 6C94 239D
Chat:  AOL/Yahoo: TonyG05    ICQ: 91183266
Linux. The choice of a GNU Generation. <http://www.linux.org/>