Replacing all CHAR colums with VARCHAR - Mailing list pgsql-general

From Andrus
Subject Replacing all CHAR colums with VARCHAR
Date
Msg-id enc9oa$1c4q$1@news.hub.org
Whole thread Raw
Responses Re: Replacing all CHAR colums with VARCHAR  (Richard Huxton <dev@archonet.com>)
Re: Replacing all CHAR colums with VARCHAR  (Bruno Wolff III <bruno@wolff.to>)
List 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.



pgsql-general by date:

Previous
From: "Ing. Dan Horáček"
Date:
Subject: ldap auth problem
Next
From: "Andrus"
Date:
Subject: Replacing all CHAR colums with VARCHAR