pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: character type modification
5+ messages / 5 participants
[nested] [flat]

* Re: character type modification
@ 2003-12-16 17:31 Godshall Michael <Michael_Godshall@gmachs.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Godshall Michael @ 2003-12-16 17:31 UTC (permalink / raw)
  To: Jodi Kanter <jkanter@virginia.edu>; pgsql-admin

Existing table column data types cannot be altered in any stable version of
postgres(7.4 or previous).  I don't know if it is available in a beta
release.

-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Jodi Kanter
Sent: Tuesday, December 16, 2003 11:32 AM
To: Postgres Admin List
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@virginia.edu <mailto:jkanter@virginia.edu> 
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

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

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

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

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

* character type modification
@ 2003-12-16 17:32 Jodi Kanter <jkanter@virginia.edu>
  2003-12-16 17:35 ` Re: character type modification Michael Fuhr <mfuhr+pgsql-admin@fuhr.org>
  2003-12-16 17:45 ` Re: character type modification Andrei Bintintan <klodoma@ar-sd.net>
  2003-12-17 08:02 ` Re: character type modification Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 3 replies; 5+ messages in thread

From: Jodi Kanter @ 2003-12-16 17:32 UTC (permalink / raw)
  To: pgsql-admin

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@virginia.edu <mailto:jkanter@virginia.edu>/

 

/ /

/ /

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

* Re: character type modification
  2003-12-16 17:32 character type modification Jodi Kanter <jkanter@virginia.edu>
@ 2003-12-16 17:35 ` Michael Fuhr <mfuhr+pgsql-admin@fuhr.org>
  2 siblings, 0 replies; 5+ messages in thread

From: Michael Fuhr @ 2003-12-16 17:35 UTC (permalink / raw)
  To: Jodi Kanter <jkanter@virginia.edu>; +Cc: pgsql-admin

On Tue, Dec 16, 2003 at 12:32:05PM -0500, Jodi Kanter wrote:

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

The FAQ has a question entitled "How do you remove a column from a
table, or change its data type?":

http://www.postgresql.org/docs/faqs/FAQ.html

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



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

* Re: character type modification
  2003-12-16 17:32 character type modification Jodi Kanter <jkanter@virginia.edu>
@ 2003-12-16 17:45 ` Andrei Bintintan <klodoma@ar-sd.net>
  2 siblings, 0 replies; 5+ messages in thread

From: Andrei Bintintan @ 2003-12-16 17:45 UTC (permalink / raw)
  To: Jodi Kanter <jkanter@virginia.edu>; 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@yahoo.co.in>
To: "Andrei Bintintan" <klodoma@ar-sd.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@ar-sd.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@yahoo.co.in>
> > To: <pgsql-admin@postgresql.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@postgresql.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@virginia.edu
  <!--[if !supportLineBreakNewLine]-->
  <!--[endif]-->

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

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

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

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

* Re: character type modification
  2003-12-16 17:32 character type modification Jodi Kanter <jkanter@virginia.edu>
@ 2003-12-17 08:02 ` Tom Lane <tgl@sss.pgh.pa.us>
  2 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2003-12-17 08:02 UTC (permalink / raw)
  To: Jodi Kanter <jkanter@virginia.edu>; +Cc: pgsql-admin

Jodi Kanter <jkanter@virginia.edu> writes:
> Can I alter a column from character varying(128) to text without having 
> to create a temp table? I am running 7.3.3.

Yeah, if you're brave enough: change the column's atttypid to 'text'
(25, I think, but check it) and atttypmod to -1 in pg_attribute.
This is sufficient since the two datatypes have the same representation
--- in general you can't just hack atttypid at random, but it will
work in this case.

Highly advisable to practice this maneuver in a scratch database.

BTW, if you're running 7.3.3 and not 7.3.4 (even better 7.3.5), you are
not being brave but foolish.  7.3.3's WAL-startup-failure bug will get
you sooner or later.

			regards, tom lane



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


end of thread, other threads:[~2003-12-17 08:02 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-12-16 17:31 Re: character type modification Godshall Michael <Michael_Godshall@gmachs.com>
2003-12-16 17:32 character type modification Jodi Kanter <jkanter@virginia.edu>
2003-12-16 17:35 ` Michael Fuhr <mfuhr+pgsql-admin@fuhr.org>
2003-12-16 17:45 ` Andrei Bintintan <klodoma@ar-sd.net>
2003-12-17 08:02 ` Tom Lane <tgl@sss.pgh.pa.us>

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