change attnum in pg_catalog.pg_attribute

Started by Grzegorz Przeździeckiabout 21 years ago6 messagesgeneral
Jump to latest
#1Grzegorz Przeździecki
Grzegorz.Przezdziecki@PolskieSklepy.pl

Welcome

I want to change column order in select * from table instruction;
I can do that changing attnum but I don't know it is safely or not for
system.

Question is can do that or not.
Thanks for help

Best Regards

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Grzegorz Przeździecki (#1)
Re: change attnum in pg_catalog.pg_attribute

somee <grzegorz.przezdziecki@polskiesklepy.pl> writes:

I want to change column order in select * from table instruction;
I can do that changing attnum but I don't know it is safely or not for
system.

It won't work and will likely crash the backend.

regards, tom lane

#3Grzegorz Przeździecki
Grzegorz.Przezdziecki@PolskieSklepy.pl
In reply to: Tom Lane (#2)
Re: change attnum in pg_catalog.pg_attribute

Dnia wtorek, 5 kwietnia 2005 20:13, Tom Lane napisaďż˝:

somee <grzegorz.przezdziecki@polskiesklepy.pl> writes:

I want to change column order in select * from table instruction;
I can do that changing attnum but I don't know it is safely or not for
system.

It won't work and will likely crash the backend.

Even if I will do like this and for ever??

1. attnum will be unique and greater than 0
2. no holes in attnum numeric
3. Make change
4. restart postgresql

regards, tom lane

Best Regards

--
Grzegorz Prze�dziecki
www.PolskieSklepy.pl
kom. +48.606.822.506
gg:3701851 skype: grzegorz.przezdziecki

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Grzegorz Przeździecki (#3)
Re: change attnum in pg_catalog.pg_attribute

Grzegorz =?iso-8859-2?q?Prze=BCdziecki?= <Grzegorz.Przezdziecki@PolskieSklepy.pl> writes:

It won't work and will likely crash the backend.

Even if I will do like this and for ever??

1. attnum will be unique and greater than 0
2. no holes in attnum numeric
3. Make change
4. restart postgresql

Yes, unless you also TRUNCATE the table, because attnum ordering tells
about the physical data layout within the table rows. Furthermore,
altering only pg_attribute is unlikely to represent a complete update
of the catalogs --- attnums also show up in pg_index, pg_attrdef,
pg_depend, pg_rewrite if there are any rules or views mentioning the
columns, and probably some other places I forgot.

regards, tom lane

#5Grzegorz Przeździecki
Grzegorz.Przezdziecki@PolskieSklepy.pl
In reply to: Tom Lane (#4)
Re: change attnum in pg_catalog.pg_attribute

Welcome

Yes, unless you also TRUNCATE the table, because attnum ordering tells
about the physical data layout within the table rows. Furthermore,
altering only pg_attribute is unlikely to represent a complete update
of the catalogs --- attnums also show up in pg_index, pg_attrdef,
pg_depend, pg_rewrite if there are any rules or views mentioning the
columns, and probably some other places I forgot.

Now understand
Thanks a lot

regards, tom lane

Best Regards

--
Grzegorz Prze�dziecki
www.PolskieSklepy.pl
kom. +48.606.822.506
gg:3701851 skype: grzegorz.przezdziecki

#6Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#2)
Re: change attnum in pg_catalog.pg_attribute

Tom Lane <tgl@sss.pgh.pa.us> writes:

somee <grzegorz.przezdziecki@polskiesklepy.pl> writes:

I want to change column order in select * from table instruction;
I can do that changing attnum but I don't know it is safely or not for
system.

It won't work and will likely crash the backend.

Out of curiosity, would it work if the table were completely empty at the
time?

--
greg