Here be the place where I store Perl programs for your edification.
col-retyper.txt — a program to change the datatype of a column in a Postgresql table, such as changing numeric(5.2) to varchar(20). This is not as easy as it seems, because there's no direct alter column DDL command to do this. Things get more complicated if the column has a comment associated with it.
Usage: col-reftype <table> <column> <type>
e.g. col-reftype tab1 col_misc 'varchar(44)'
Note that if the new datatype contains meta-characters, it will need to be quoted to avoid shell interpretation.
Copyright © David Landgren 2008
last update:
2008-11-07 22:26:45 UTC