Re: character type modification

From: "Andrei Bintintan" <klodoma(at)ar-sd(dot)net>
To: "Jodi Kanter" <jkanter(at)virginia(dot)edu>, "Postgres Admin List" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: character type modification
Date: 2003-12-16 17:45:08
Message-ID: 004301c3c3fc$590f0f80$0b00a8c0@andyy
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

This is another discuttion about this problem.

Please read these mails.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

I cannot write here all the syntax:
I'll give an example: you have a table called "person" and you have a column
called "name" varchar(10) and you want to change it into varchar(25).

alter person add column name_temp varchar(25);
update person set name_temp = name;
alter person drop column name;
alter person rename column name_temp to name;

This is it. Now depending on you database complexity if you have a complex
database and a lot of indexes or triggers, you will have to drop these items
and rebuild them.

Have fun.
Andy.

----- Original Message -----
From: "Chitta Ranjan Mishra" <c_r_mishra(at)yahoo(dot)co(dot)in>
To: "Andrei Bintintan" <klodoma(at)ar-sd(dot)net>
Sent: Friday, December 12, 2003 5:46 AM
Subject: [ADMIN] Help---- Urgent

> Dear Sir,
> Thanks for your reply. Kindly send me the syntax
> for all this.
>
> Thanking you,
> Regds
> C.R.Mishra
>
>
>
> --- Andrei Bintintan <klodoma(at)ar-sd(dot)net> wrote: >
> Create a new column
> >
> > alter <tablename> add column <newcolname>
> > varchar(25);
> >
> > Then copy the old column into the new column:
> > update <tablename> set <newcolname> = <oldcolname>;
> >
> > Drop the last column:
> > alter <tablename> drop column <oldcolname>;
> >
> > Rename the column:
> > alter <tablename> rename column <newcolname> to
> > <oldcolname>;
> >
> > Take care for INDEXES if there are any.
> >
> > This should do it.
> >
> > Best regards.
> >
> >
> > ----- Original Message -----
> > From: "Chitta Ranjan Mishra"
> > <c_r_mishra(at)yahoo(dot)co(dot)in>
> > To: <pgsql-admin(at)postgresql(dot)org>
> > Sent: Thursday, December 11, 2003 7:19 AM
> > Subject: [ADMIN] Help---- Urgent
> >
> >
> > > Dear Sir,
> > > I wnat to alter the size of one of the column
> > of a
> > > table. How to do this in Postgres ? Plz help me.
> > > It's very urgent...
> > >
> > > I tried with the following syntax :
> > > but it failed....
> > >
> > > alter table tablename modify(coumnname
> > varchar(25));
> > >
> > > it's very urgnet...plz reply soon..
> > >
> > > Thanking you,
> > > Regds
> > > C.R.Mishra
> > >
> > >
> > >
> > >
> > >
> >
> ________________________________________________________________________
> > > Yahoo! India Mobile: Download the latest
> > polyphonic ringtones.
> > > Go to http://in.mobile.yahoo.com
> > >
> > > ---------------------------(end of
> > broadcast)---------------------------
> > > TIP 1: subscribe and unsubscribe commands go to
> majordomo(at)postgresql(dot)org
>
> ________________________________________________________________________
> Yahoo! India Mobile: Download the latest polyphonic ringtones.
> Go to http://in.mobile.yahoo.com

----- Original Message -----
From: Jodi Kanter
To: Postgres Admin List
Sent: Tuesday, December 16, 2003 7:32 PM
Subject: [ADMIN] character type modification

Can I alter a column from character varying(128) to text without having to create a temp table? I am running 7.3.3.
Thanks

--

_______________________________
Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter(at)virginia(dot)edu
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

<!--[if !supportEmptyParas]--> <!--[endif]-->

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message sumbry 2003-12-16 20:01:59 Re: Postgresql on software RAID
Previous Message Michael Fuhr 2003-12-16 17:35:46 Re: character type modification