Re: URGENT!!! changing Column size

From: SZUCS Gábor <surrano(at)mailbox(dot)hu>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: URGENT!!! changing Column size
Date: 2003-10-28 17:02:14
Message-ID: 076b01c39d75$3d677270$0403a8c0@fejleszt4
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)physics(dot)gmu(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Greg Stark 2003-10-28 18:21:17 Re: numeric and float converts to int differently?
Previous Message SZŰCS Gábor 2003-10-28 16:42:10 Re: numeric and float converts to int differently?