pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Elphick <olly@lfix.co.uk>
To: Jaruwan Laongmal <jaruwan@gits.net.th>
Cc: pgsql-sql@postgresql.org
Subject: Re: [HACKERS] How to modify type in table?
Date: Tue, 30 Jan 2001 12:22:05 +0000
Message-ID: <200101301222.f0UCM5F17760@linda.lfix.co.uk> (raw)
In-Reply-To: <jaruwan@gits.net.th> <015601c08a6b$dd92e7e0$6d9a96cb@ntl>

"Jaruwan Laongmal" wrote:
  >Would you like to inform me how to modify type in table?
  >For example , I define type as varchar(14) , but I want to modify to varcha=
  >r(120). How to do this.

There is no facility to do this directly.  (Allowing columns to change
their type would possibly involve rewriting the entire table.)

You can use pg_dump to dump either a database or a particular table. Then
you can edit the CREATE TABLE command in the dump output and then create a
new database or table from the dump.

If the table in question is not referenced by any other objects, dump
it  (pg_dump -t table database >dump); edit the dump; delete or rename the
old table; and finally restore the dump (psql -d database <dump).

If the table is the target of RI references, triggers, rules and so on, it
is easiest to use pg_dump to dump the whole database,  (This is because the
table is referenced by oid, not by name, and recreating the table will
make it seem to disappear from all those references.)

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "The Lord knoweth how to deliver the godly out of 
      temptations, and to reserve the unjust unto the day of
      judgment to be punished;"            II Peter 2:9 





view thread (5+ messages)  latest in thread

Message-ID: <200101301222.f0UCM5F17760@linda.lfix.co.uk>
Permalink:  ../200101301222.f0UCM5F17760@linda.lfix.co.uk/
Also on:    postgresql.org/message-id/200101301222.f0UCM5F17760@linda.lfix.co.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: olly@lfix.co.uk, jaruwan@gits.net.th
  Subject: Re: [HACKERS] How to modify type in table?
  In-Reply-To: <200101301222.f0UCM5F17760@linda.lfix.co.uk>
  References: <200101301222.f0UCM5F17760@linda.lfix.co.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox