Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.postgresql > #274
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Robert Klemme <shortcutter@googlemail.com> |
| Newsgroups | comp.databases.postgresql |
| Subject | Re: Column Order |
| Date | Fri, 04 Nov 2011 17:39:23 +0100 |
| Lines | 28 |
| Message-ID | <9hiipsF25kU1@mid.individual.net> (permalink) |
| References | <9hi005F3v8U1@mid.individual.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-15; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net 36kwIkiVEMthglQ0lNDRFAiBAmBh65tRnODzPvdi/zvZf/8iQ= |
| Cancel-Lock | sha1:8Epib96S8WbMn/DjG0nAp6Bxd28= |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 |
| In-Reply-To | <9hi005F3v8U1@mid.individual.net> |
| Xref | x330-a1.tempe.blueboxinc.net comp.databases.postgresql:274 |
Show key headers only | View raw
On 11/04/2011 12:18 PM, Michael Hufschmidt wrote: > When I do a "SELECT * FROM myTable WHERE ..." using psql I want to have > the columns displayed in a meaningful order by default. I want to avoid > a "SELECT firstname, lastname, <many other cols to follow> ...". Is it > possible to modify the order of columns with an > ALTER TABLE myTable ALTER COLUMN lastname <put behind firstname> > > Same holds for adding a new column, how can I > ALTER TABLE myTable ADD COLUMN title VARCHAR(255) <put before firstname> > > This is possible in mySQL, not in PostgreSQL? > > Any ideas are welcome - Michael IMHO it is generally a bad idea to rely on column order because that may change etc. It's usually best to explicitly select columns in the order that you desire. You could define a view with the proper order on the table but you'll have to update that view definition every time your table has a new column. Bottom line: do not use "SELECT *" other than for briefly checking column contents. In any sort of application I would always name only those columns explicit which I need for the query. That may also save you a lot of network bandwidth between client and database server. Kind regards robert
Back to comp.databases.postgresql | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Column Order Michael Hufschmidt <Michael.Hufschmidt@omnis.net> - 2011-11-04 12:18 +0100
Re: Column Order Robert Klemme <shortcutter@googlemail.com> - 2011-11-04 17:39 +0100
Re: Column Order Matthew Woodcraft <mattheww@chiark.greenend.org.uk> - 2011-11-04 18:29 +0000
Re: Column Order Matthew Woodcraft <mattheww@chiark.greenend.org.uk> - 2011-11-04 18:23 +0000
csiph-web