pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedchanging field length
13+ messages / 6 participants
[nested] [flat]
* changing field length
@ 2003-08-19 18:34 Jodi Kanter <jkanter@virginia.edu>
2003-08-19 19:09 ` Re: changing field length Gaetano Mendola <mendola@bigfoot.com>
2003-08-19 19:33 ` Re: changing field length Stephan Szabo <sszabo@megazone.bigpanda.com>
2003-08-20 00:37 ` Re: changing field length Nick Fankhauser <nickf@ontko.com>
0 siblings, 3 replies; 13+ messages in thread
From: Jodi Kanter @ 2003-08-19 18:34 UTC (permalink / raw)
To: pgsql-admin
I am running 7.3.3. Can I change a field that is varying character(128)
to varying character(250)?
Thanks
Jodi
--
_______________________________
Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter@virginia.edu <mailto:jkanter@virginia.edu>
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: changing field length
2003-08-19 18:34 changing field length Jodi Kanter <jkanter@virginia.edu>
@ 2003-08-19 19:09 ` Gaetano Mendola <mendola@bigfoot.com>
2003-08-20 14:16 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
2 siblings, 1 reply; 13+ messages in thread
From: Gaetano Mendola @ 2003-08-19 19:09 UTC (permalink / raw)
To: pgsql-admin; +Cc: Jodi Kanter <jkanter@virginia.edu>
"Jodi Kanter" <jkanter@virginia.edu> wrote:
> I am running 7.3.3. Can I change a field that is varying character(128)
> to varying character(250)?
nope.
You can
a) create a new column named tmp of character(250).
b) copy the content from old column to new column
c) drop the old column
d) rename the tmp column to the correct name
Regards
Gaeatano Mendola
PS: Be carefull with the constraint....
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: changing field length
2003-08-19 18:34 changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-19 19:09 ` Re: changing field length Gaetano Mendola <mendola@bigfoot.com>
@ 2003-08-20 14:16 ` Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:26 ` Re: changing field length Bruno Wolff III <bruno@wolff.to>
0 siblings, 1 reply; 13+ messages in thread
From: Jodi Kanter @ 2003-08-20 14:16 UTC (permalink / raw)
To: Gaetano Mendola <mendola@bigfoot.com>; +Cc: pgsql-admin
how do I copy from one field to another?
Gaetano Mendola wrote:
>"Jodi Kanter" <jkanter@virginia.edu> wrote:
>
>>I am running 7.3.3. Can I change a field that is varying character(128)
>>to varying character(250)?
>>
>
>nope.
>
>You can
> a) create a new column named tmp of character(250).
> b) copy the content from old column to new column
> c) drop the old column
> d) rename the tmp column to the correct name
>
>
>Regards
>Gaeatano Mendola
>
>PS: Be carefull with the constraint....
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
--
_______________________________
Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter@virginia.edu <mailto:jkanter@virginia.edu>
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: changing field length
2003-08-19 18:34 changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-19 19:09 ` Re: changing field length Gaetano Mendola <mendola@bigfoot.com>
2003-08-20 14:16 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
@ 2003-08-20 14:26 ` Bruno Wolff III <bruno@wolff.to>
2003-08-20 14:39 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:40 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:49 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
0 siblings, 3 replies; 13+ messages in thread
From: Bruno Wolff III @ 2003-08-20 14:26 UTC (permalink / raw)
To: Jodi Kanter <jkanter@virginia.edu>; +Cc: Gaetano Mendola <mendola@bigfoot.com>; pgsql-admin
On Wed, Aug 20, 2003 at 10:16:38 -0400,
Jodi Kanter <jkanter@virginia.edu> wrote:
> how do I copy from one field to another?
update tablename set newcol = oldcol;
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: changing field length
2003-08-19 18:34 changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-19 19:09 ` Re: changing field length Gaetano Mendola <mendola@bigfoot.com>
2003-08-20 14:16 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:26 ` Re: changing field length Bruno Wolff III <bruno@wolff.to>
@ 2003-08-20 14:39 ` Jodi Kanter <jkanter@virginia.edu>
2 siblings, 0 replies; 13+ messages in thread
From: Jodi Kanter @ 2003-08-20 14:39 UTC (permalink / raw)
To: Bruno Wolff III <bruno@wolff.to>; +Cc: Gaetano Mendola <mendola@bigfoot.com>; pgsql-admin
ExecUpdate: Fail to add null value in not null attribute study_name
Is there any way around this error. Col1 is a not null field but col2 is
not obviously since it is currently empty!
Thanks for the help.
Jodi
Bruno Wolff III wrote:
>On Wed, Aug 20, 2003 at 10:16:38 -0400,
> Jodi Kanter <jkanter@virginia.edu> wrote:
>
>>how do I copy from one field to another?
>>
>
>update tablename set newcol = oldcol;
>
--
_______________________________
Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter@virginia.edu <mailto:jkanter@virginia.edu>
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: changing field length
2003-08-19 18:34 changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-19 19:09 ` Re: changing field length Gaetano Mendola <mendola@bigfoot.com>
2003-08-20 14:16 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:26 ` Re: changing field length Bruno Wolff III <bruno@wolff.to>
@ 2003-08-20 14:40 ` Jodi Kanter <jkanter@virginia.edu>
2 siblings, 0 replies; 13+ messages in thread
From: Jodi Kanter @ 2003-08-20 14:40 UTC (permalink / raw)
To: Bruno Wolff III <bruno@wolff.to>; +Cc: Gaetano Mendola <mendola@bigfoot.com>; pgsql-admin
please ignore last message. I had my columns switched.
sorry about that!
Thanks for the quick response.
jodi
Bruno Wolff III wrote:
>On Wed, Aug 20, 2003 at 10:16:38 -0400,
> Jodi Kanter <jkanter@virginia.edu> wrote:
>
>>how do I copy from one field to another?
>>
>
>update tablename set newcol = oldcol;
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
--
_______________________________
Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter@virginia.edu <mailto:jkanter@virginia.edu>
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: changing field length
2003-08-19 18:34 changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-19 19:09 ` Re: changing field length Gaetano Mendola <mendola@bigfoot.com>
2003-08-20 14:16 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:26 ` Re: changing field length Bruno Wolff III <bruno@wolff.to>
@ 2003-08-20 14:49 ` Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:58 ` Re: changing field length Bruno Wolff III <bruno@wolff.to>
2 siblings, 1 reply; 13+ messages in thread
From: Jodi Kanter @ 2003-08-20 14:49 UTC (permalink / raw)
To: Bruno Wolff III <bruno@wolff.to>; +Cc: Gaetano Mendola <mendola@bigfoot.com>; pgsql-admin
can I now make this field not null?
is it possible to move a field up in a table? now that I have done this
move the new field is at the bottom of the list of fields. From time to
time we have had to make changes to our schema so I will rerun our
script and do a pg_dump of the data only and then restore the data from
within psql. This new field in the dump is in a different location then
it is when the script runs. I expect this will cause an error. I am
doing pg_dumps with the following: -Rau
I realize I can move it down in the script but was wondering if there
were another solution. Logically it makes sense to list it toward the
top of the table.
Thanks
Jodi
Bruno Wolff III wrote:
>On Wed, Aug 20, 2003 at 10:16:38 -0400,
> Jodi Kanter <jkanter@virginia.edu> wrote:
>
>>how do I copy from one field to another?
>>
>
>update tablename set newcol = oldcol;
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
--
_______________________________
Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter@virginia.edu <mailto:jkanter@virginia.edu>
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: changing field length
2003-08-19 18:34 changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-19 19:09 ` Re: changing field length Gaetano Mendola <mendola@bigfoot.com>
2003-08-20 14:16 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:26 ` Re: changing field length Bruno Wolff III <bruno@wolff.to>
2003-08-20 14:49 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
@ 2003-08-20 14:58 ` Bruno Wolff III <bruno@wolff.to>
2003-08-20 15:16 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
0 siblings, 1 reply; 13+ messages in thread
From: Bruno Wolff III @ 2003-08-20 14:58 UTC (permalink / raw)
To: Jodi Kanter <jkanter@virginia.edu>; +Cc: Gaetano Mendola <mendola@bigfoot.com>; pgsql-admin
On Wed, Aug 20, 2003 at 10:49:08 -0400,
Jodi Kanter <jkanter@virginia.edu> wrote:
> can I now make this field not null?
>
> is it possible to move a field up in a table? now that I have done this
Currently, not without recreating the table. There was some discussion
about that a few months ago, but nothing is happening in 7.4 on that
front. Maybe in 7.5 there will be a way to change the column order,
but don't count on it.
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: changing field length
2003-08-19 18:34 changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-19 19:09 ` Re: changing field length Gaetano Mendola <mendola@bigfoot.com>
2003-08-20 14:16 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:26 ` Re: changing field length Bruno Wolff III <bruno@wolff.to>
2003-08-20 14:49 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:58 ` Re: changing field length Bruno Wolff III <bruno@wolff.to>
@ 2003-08-20 15:16 ` Jodi Kanter <jkanter@virginia.edu>
2003-08-20 15:18 ` Re: changing field length Bruno Wolff III <bruno@wolff.to>
2003-08-20 15:48 ` Re: changing field length scott.marlowe <scott.marlowe@ihs.com>
0 siblings, 2 replies; 13+ messages in thread
From: Jodi Kanter @ 2003-08-20 15:16 UTC (permalink / raw)
To: Bruno Wolff III <bruno@wolff.to>; +Cc: Gaetano Mendola <mendola@bigfoot.com>; pgsql-admin
Ok. so for now I want to return to where I started. so I renamed the
table and regenerated my original table with the fields in the order
that I like. I cannot just do a
insert into table select * from other_table;
because the fields are in a different order.
Can I do this by listing the fields in my insert in the order in which I
want them placed?
Thanks
Jodi
Bruno Wolff III wrote:
>On Wed, Aug 20, 2003 at 10:49:08 -0400,
> Jodi Kanter <jkanter@virginia.edu> wrote:
>
>>can I now make this field not null?
>>
>>is it possible to move a field up in a table? now that I have done this
>>
>
>Currently, not without recreating the table. There was some discussion
>about that a few months ago, but nothing is happening in 7.4 on that
>front. Maybe in 7.5 there will be a way to change the column order,
>but don't count on it.
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
--
_______________________________
Jodi L Kanter
BioInformatics Database Administrator
University of Virginia
(434) 924-2846
jkanter@virginia.edu <mailto:jkanter@virginia.edu>
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: changing field length
2003-08-19 18:34 changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-19 19:09 ` Re: changing field length Gaetano Mendola <mendola@bigfoot.com>
2003-08-20 14:16 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:26 ` Re: changing field length Bruno Wolff III <bruno@wolff.to>
2003-08-20 14:49 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:58 ` Re: changing field length Bruno Wolff III <bruno@wolff.to>
2003-08-20 15:16 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
@ 2003-08-20 15:18 ` Bruno Wolff III <bruno@wolff.to>
1 sibling, 0 replies; 13+ messages in thread
From: Bruno Wolff III @ 2003-08-20 15:18 UTC (permalink / raw)
To: Jodi Kanter <jkanter@virginia.edu>; +Cc: Gaetano Mendola <mendola@bigfoot.com>; pgsql-admin
On Wed, Aug 20, 2003 at 11:16:18 -0400,
Jodi Kanter <jkanter@virginia.edu> wrote:
> Ok. so for now I want to return to where I started. so I renamed the
> table and regenerated my original table with the fields in the order
> that I like. I cannot just do a
> insert into table select * from other_table;
> because the fields are in a different order.
> Can I do this by listing the fields in my insert in the order in which I
> want them placed?
Yes. Instead of using '*' list the columns from the table that currently
has the data in the order that they appear in the table that is currently
empty.
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: changing field length
2003-08-19 18:34 changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-19 19:09 ` Re: changing field length Gaetano Mendola <mendola@bigfoot.com>
2003-08-20 14:16 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:26 ` Re: changing field length Bruno Wolff III <bruno@wolff.to>
2003-08-20 14:49 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:58 ` Re: changing field length Bruno Wolff III <bruno@wolff.to>
2003-08-20 15:16 ` Re: changing field length Jodi Kanter <jkanter@virginia.edu>
@ 2003-08-20 15:48 ` scott.marlowe <scott.marlowe@ihs.com>
1 sibling, 0 replies; 13+ messages in thread
From: scott.marlowe @ 2003-08-20 15:48 UTC (permalink / raw)
To: Jodi Kanter <jkanter@virginia.edu>; +Cc: Bruno Wolff III <bruno@wolff.to>; Gaetano Mendola <mendola@bigfoot.com>; pgsql-admin
As always, there's more than one way to skin a cat...
Create a new table and insert into it:
create newtable (field newdef, field2 newdef);
insert into
newtable (
select oldfield,
oldfield2 from oldtable
);
Create it on the fly with Postgresql casting shortcuts:
select
field1::newtype,
field2::newtype,
field3,
field4
into
newtable
from
oldtable;
Create it on the fly with ANSI style casting:
select
cast(field1 as newtype),
cast(field2 as newtype),
field3,
field4
into
newtable
from
oldtable;
On Wed, 20 Aug 2003, Jodi Kanter wrote:
> Ok. so for now I want to return to where I started. so I renamed the
> table and regenerated my original table with the fields in the order
> that I like. I cannot just do a
> insert into table select * from other_table;
> because the fields are in a different order.
> Can I do this by listing the fields in my insert in the order in which I
> want them placed?
> Thanks
> Jodi
>
> Bruno Wolff III wrote:
>
> >On Wed, Aug 20, 2003 at 10:49:08 -0400,
> > Jodi Kanter <jkanter@virginia.edu> wrote:
> >
> >>can I now make this field not null?
> >>
> >>is it possible to move a field up in a table? now that I have done this
> >>
> >
> >Currently, not without recreating the table. There was some discussion
> >about that a few months ago, but nothing is happening in 7.4 on that
> >front. Maybe in 7.5 there will be a way to change the column order,
> >but don't count on it.
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 6: Have you searched our list archives?
> >
> > http://archives.postgresql.org
> >
>
>
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: changing field length
2003-08-19 18:34 changing field length Jodi Kanter <jkanter@virginia.edu>
@ 2003-08-19 19:33 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
2 siblings, 0 replies; 13+ messages in thread
From: Stephan Szabo @ 2003-08-19 19:33 UTC (permalink / raw)
To: Jodi Kanter <jkanter@virginia.edu>; +Cc: pgsql-admin
On Tue, 19 Aug 2003, Jodi Kanter wrote:
> I am running 7.3.3. Can I change a field that is varying character(128)
> to varying character(250)?
You can either add a column, copy the data across and drop the old column
and use rename to give the new column the old name or if you're willing
to hack at system tables, you can change atttypmod in pg_attribute for the
column from 132 (maxsize + 4 to hold the real size) to 254.
^ permalink raw reply [nested|flat] 13+ messages in thread
* Re: changing field length
2003-08-19 18:34 changing field length Jodi Kanter <jkanter@virginia.edu>
@ 2003-08-20 00:37 ` Nick Fankhauser <nickf@ontko.com>
2 siblings, 0 replies; 13+ messages in thread
From: Nick Fankhauser @ 2003-08-20 00:37 UTC (permalink / raw)
To: Jodi Kanter <jkanter@virginia.edu>; pgsql-admin
Jodi-
Here's an example of the "hack" approach, which I've used without causing
any problems for some time:
update pg_attribute set atttypmod = 104
where attrelid = ( select oid from pg_class where relname = 'actor'
and attname = 'actor_full_name' );
In your case, you'd substitute 254 for 104, your table name for "actor" and
your field name for "actor_full_name";
-Nick
-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Jodi Kanter
Sent: Tuesday, August 19, 2003 1:34 PM
To: Postgres Admin List
Subject: [ADMIN] changing field length
I am running 7.3.3. Can I change a field that is varying character(128) to
varying character(250)?
Thanks
Jodi
--
_______________________________
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] 13+ messages in thread
end of thread, other threads:[~2003-08-20 15:48 UTC | newest]
Thread overview: 13+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-08-19 18:34 changing field length Jodi Kanter <jkanter@virginia.edu>
2003-08-19 19:09 ` Gaetano Mendola <mendola@bigfoot.com>
2003-08-20 14:16 ` Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:26 ` Bruno Wolff III <bruno@wolff.to>
2003-08-20 14:39 ` Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:40 ` Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:49 ` Jodi Kanter <jkanter@virginia.edu>
2003-08-20 14:58 ` Bruno Wolff III <bruno@wolff.to>
2003-08-20 15:16 ` Jodi Kanter <jkanter@virginia.edu>
2003-08-20 15:18 ` Bruno Wolff III <bruno@wolff.to>
2003-08-20 15:48 ` scott.marlowe <scott.marlowe@ihs.com>
2003-08-19 19:33 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
2003-08-20 00:37 ` Nick Fankhauser <nickf@ontko.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