X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E8532475ADE for ; Fri, 18 Apr 2003 01:51:47 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 5FAAE475458 for ; Fri, 18 Apr 2003 01:51:47 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 5E3ECD612; Thu, 17 Apr 2003 22:51:47 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 53C4B5C03; Thu, 17 Apr 2003 22:51:47 -0700 (PDT) Date: Thu, 17 Apr 2003 22:51:47 -0700 (PDT) From: Stephan Szabo To: Devi Munandar Cc: Subject: Re: change field type and length In-Reply-To: <003301c30569$43003d60$a6f0cda7@informatika.lipi.go.id> Message-ID: <20030417224828.E97534-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-26.0 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/256 X-Sequence-Number: 8411 On Fri, 18 Apr 2003, Devi Munandar wrote: > I've created table with postgresql, and so far so good, but I want to change > Field type and field length, I've tried to find command line and > documentation postgresql to change table field, but I can't get it. so there > are any trip to change that field...? > > CREATE TABLE "dat_jab" ( > "code_jab" numeric(2,0) NOT NULL, > "nm_jab" varchar(25), > CONSTRAINT "dat_jab_pkey" PRIMARY KEY ("code_jab") > ); > CREATE INDEX "dat_jab_code_jab_key" ON "dat_jab" ("code_jab"); > > *** want to change Field Type "code_jab" numeric(4.0) , and field name > "nm_jab" -->"nm_cdjab" Renaming should be easy with ALTER TABLE RENAME COLUMN. For changing the field type, I think about the best you can do is making a new column with the correct new type, copy the data across and drop the old column.