pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
change field type and length
3+ messages / 3 participants
[nested] [flat]

* change field type and length
@ 2003-04-18 05:13  Devi Munandar <devi@informatika.lipi.go.id>
  0 siblings, 2 replies; 3+ messages in thread

From: Devi Munandar @ 2003-04-18 05:13 UTC (permalink / raw)
  To: pgsql-admin

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"


regards

--dv




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: change field type and length
@ 2003-04-18 05:23  Michiel Lange <michiel@minas.demon.nl>
  parent: Devi Munandar <devi@informatika.lipi.go.id>
  1 sibling, 0 replies; 3+ messages in thread

From: Michiel Lange @ 2003-04-18 05:23 UTC (permalink / raw)
  To: Devi Munandar <devi@informatika.lipi.go.id>; +Cc: pgsql-admin

I've been looking at it too, and my idea is that this is not possible. Only 
a dump and load would do the trick...
if the data-types are compatible of course...

Michiel
At 12:13 18-4-2003 +0700, 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"
>
>
>regards
>
>--dv
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>http://archives.postgresql.org




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: change field type and length
@ 2003-04-18 05:51  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Devi Munandar <devi@informatika.lipi.go.id>
  1 sibling, 0 replies; 3+ messages in thread

From: Stephan Szabo @ 2003-04-18 05:51 UTC (permalink / raw)
  To: Devi Munandar <devi@informatika.lipi.go.id>; +Cc: pgsql-admin


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.




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2003-04-18 05:51 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-04-18 05:13 change field type and length Devi Munandar <devi@informatika.lipi.go.id>
2003-04-18 05:23 ` Michiel Lange <michiel@minas.demon.nl>
2003-04-18 05:51 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>

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