I have a php script that patches database, comparing pg_catalog's tables to
input files. One thing it can do, but I can't take responsibility ;) is
changing the type of a column.
It's basically the same that everyone wrote, except that I also examine
dependencies, as broad an examination as I could think about.
However; the code is not yet ready, and not my exclusive possession, but the
steps I could tell you are:
1. Note oid: SELECT oid, relname from pg_class WHERE relname='institution'
2. Identify the attribute: SELECT * from pg_attribute WHERE attrelid = xxx AND ...
3. Search for depends: SELECT d.* FROM pg_depend d, pg_attribute a WHERE refobjid=a.attrelid and
refobjsubid=a.attnum AND ... -- you are on your own here ;)
4. Drop those dependencies (more likely, foreign keys, constraints, indexes)
5. Do the change
6. Apply dependencies.
HTH,
G.
------------------------------- cut here -------------------------------
----- Original Message -----
From: <mohan@physics.gmu.edu>
Sent: Monday, October 27, 2003 6:10 PM
> Hi can we change the size of a column in postgres. I have a table named
> institution and column name is name varchar2(25), i want to change it to
> varchar2(50). Please let me know.
>
> --Mohan