Unix Technical Forum

Re: Position of a field

This is a discussion on Re: Position of a field within the pgsql Sql forums, part of the PostgreSQL category; --> am Tue, dem 27.02.2007, um 8:51:27 -0300 mailte Ezequias Rodrigues da Rocha folgendes: > Hi list, > > I ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 03:09 PM
A. Kretschmer
 
Posts: n/a
Default Re: Position of a field

am Tue, dem 27.02.2007, um 8:51:27 -0300 mailte Ezequias Rodrigues da Rocha folgendes:
> Hi list,
>
> I just would like to know if it is possible to change the position of
> a field in a table. I am seen in pgAdmin3 that there is a position but
> on th is application I can't see if there is a place to do that.


Why do you want to do this? You can define the order of the fields in
the SELECT-Statement. Other way: you can create a VIEW. And another way:
you can recreate the table (create new_table as select <cols in desired
order> from old_table, drop old_table, rename new_tabel to old_table)


Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 03:09 PM
Ezequias Rodrigues da Rocha
 
Posts: n/a
Default Re: Position of a field

I understant you inquiry but I don't meant to add all the fields order
in an insert statement.

IE:
insert into table values (value1, value2, value3....)

is better than

insert into table (column1,column2,column3 ...) values (value1,
value2, value3....)

If there is only one way (recreating) that was not good for me.

Regards
Ezequias

2007/2/27, A. Kretschmer <andreas.kretschmer@schollglas.com>:
> am Tue, dem 27.02.2007, um 8:51:27 -0300 mailte Ezequias Rodrigues da Rocha folgendes:
> > Hi list,
> >
> > I just would like to know if it is possible to change the position of
> > a field in a table. I am seen in pgAdmin3 that there is a position but
> > on th is application I can't see if there is a place to do that.

>
> Why do you want to do this? You can define the order of the fields in
> the SELECT-Statement. Other way: you can create a VIEW. And another way:
> you can recreate the table (create new_table as select <cols in desired
> order> from old_table, drop old_table, rename new_tabel to old_table)
>
>
> Andreas
> --
> Andreas Kretschmer
> Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
> GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>



--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Atenciosamente (Sincerely)
Ezequias Rodrigues da Rocha
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
A pior das democracias ainda é melhor do que a melhor das ditaduras
The worst of democracies is still better than the better of dictatorships
http://ezequiasrocha.blogspot.com/

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-19-2008, 03:09 PM
A. Kretschmer
 
Posts: n/a
Default Re: Position of a field

am Tue, dem 27.02.2007, um 9:48:57 -0300 mailte Ezequias Rodrigues da Rocha folgendes:
> I understant you inquiry but I don't meant to add all the fields order
> in an insert statement.
>
> IE:
> insert into table values (value1, value2, value3....)
>
> is better than
>
> insert into table (column1,column2,column3 ...) values (value1,
> value2, value3....)


No, it isn't better, because, if you change the table in the future and
add new colums, your insert-statement will be failed. If you write your
insert with explicit column order, nothing happens, except the new row
will be empty.


Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:37 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com