Replacing all CHAR colums with VARCHAR

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: Replacing all CHAR colums with VARCHAR
Date: 2007-01-02 00:37:59
Message-ID: enc9oa$1c4q$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have CHAR columns in database in 500 tables. There are currently no
VARCHAR columns.

My C# application receives character data with trailing spaces from npgsql.
This makes application code complicated. Application must remove trailing
spaces from incoming data for C# string manipulation to work.

Also Tom Lane strongly recommends using VARCHAR always and never use CHAR
columns.

Is it reasonable do convert all CHAR columns in database to VARCHAR columns
in whole database.
Where to find such script ?
Shoult I make a loop over all columns and execute ALTER TABLE statements
in transaction making all constraints deferred?

I have also some triggers, indexes and sequences in database and execute
statements into database which contain a lot of operations with CHAR
columns.

Will database work OK after such conversion?
What things may be broken ?

Or is it better to hack npgsql code so that it removes trailing spaces
itself ?

Andrus.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message novnov 2007-01-02 02:24:32 Re: Installing support for python on windows
Previous Message Adrian Klaver 2007-01-01 23:52:46 Re: Installing support for python on windows