X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 05658529E2 for ; Tue, 28 Jun 2005 13:01:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61607-08 for ; Tue, 28 Jun 2005 16:00:59 +0000 (GMT) Received: from titan.ecommit.de (titan.ecommit.de [195.145.58.245]) by svr1.postgresql.org (Postfix) with ESMTP id 178685293E for ; Tue, 28 Jun 2005 13:00:58 -0300 (ADT) Received: from titan.ecommit.de (localhost [127.0.0.1]) by titan.ecommit.de (8.12.6/8.12.6/SuSE Linux 0.6) with ESMTP id j5SG0t0F001635; Tue, 28 Jun 2005 18:00:55 +0200 Received: from titan.ecommit.de (root@localhost) by titan.ecommit.de (8.12.6/8.12.6/Submit) with ESMTP id j5SG0t3R001634; Tue, 28 Jun 2005 18:00:55 +0200 Received: from fandelm.ecommit.de (fandelm.tc.de 192.168.252.51) by titan.ecommit.de (Scalix SMTP Relay 9.0.0.26) via ESMTP; Tue, 28 Jun 2005 18:00:53 +0200 (CEST) Date: Tue, 28 Jun 2005 17:59:24 +0200 From: "Martin Fandel" To: chen@musc.edu Cc: pgsql-admin@postgresql.org Message-ID: <1119974365.18693.16.camel@fandelm.ecommit.de> In-Reply-To: <1119972551.18693.3.camel@fandelm.ecommit.de> References: <42C15044.4030407@musc.edu> References: <200506281614.25981.peter_e@gmx.net> References: <42C1613F.4000605@musc.edu> References: <1119972551.18693.3.camel@fandelm.ecommit.de> Subject: Re: change existing table definition x-scalix-Hops: 1 X-Mailer: Evolution 2.0.1 Mime-Version: 1.0 Content-Type: text/plain Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.043 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/265 X-Sequence-Number: 18020 Aehm sorry. ALTER TABLE is not only in PostgreSQL 8 ;). Only the datatypes can be changed in postgres 8 (right?). I answered to fast. I'm sorry. CREATE TABLE newtable ( "bla" varchar(50)); CREATE INDEX/TRIGGER/... (with different names as the production table) INSERT INTO newtable (select * from production); ALTER TABLE production RENAME TO old; ALTER TABLE newtable RENAME TO production; If this is working correctly, you can drop the old INDEXES and rename them. If its not working correctly ALTER TABLE production RENAME TO new; ALTER TABLE old RENAME TO production; and insert the different data (which is in the oldtable) into the production table. Greetings, Martin Am Dienstag, den 28.06.2005, 17:29 +0200 schrieb Martin Fandel: > Hi > > ALTER TABLE is only in PostgreSQL 8. But you can create a new table > with varchar(50) and copy the data from the existing into the new > table. How much relation_size has your table? Do you create the > dbsize-functions which are included in the contrib package? > > Best regards, > Martin > > Am Dienstag, den 28.06.2005, 10:39 -0400 schrieb Chuming Chen: > > Peter Eisentraut wrote: > > > > >Chuming Chen wrote: > > > > > > > > >>How can I change the column definition of an existing table, ie. from > > >>varchar(30) to varchar(50)? Is there any way to add a new column to > > >>an existing table? > > >> > > >> > > > > > >The ALTER TABLE command can do all that. You need version 8.0 or later > > >for some functionality though. > > > > > > > > > > > Is there another way to do it in 7.* ? > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org