From: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Inserting a new column in between. |
Date: | 2007-02-25 09:03:09 |
Message-ID: | 20070225090308.GA6635@KanotixBox |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-novice |
RPK <rohitprakash123(at)indiatimes(dot)com> schrieb:
>
> Andreas,
>
> I am talking about inserting a field or changing their order in the
> structure itself. In MS Access and SQL Server we have this facility. Some
> times I need to shift the less important field to the last so that when I
> query using:
>
> Select * from tablename;
You should don't do that! Why? For instance, you have a table with many
rows, including BLOBs. Your applivation needs only a few columns, but
you select * returns the whole rows.
So, but no problem:
test=# create table foo (a int, c int);
CREATE TABLE
test=*# insert into foo values (1,3);
INSERT 0 1
test=*# commit;
COMMIT
Okay, we have a table with columns a and c, and now i notice i forgot
the column b. No problem:
test=# begin;
BEGIN
test=*# create table foo_temp as select a, null::int as b, c from foo;
SELECT
test=*# drop table foo;
DROP TABLE
test=*# alter table foo_temp rename to foo;
ALTER TABLE
test=*# commit;
COMMIT
test=# select * from foo;
a | b | c
---+---+---
1 | | 3
(1 row)
Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknow)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Sabino Mullane | 2007-02-25 14:30:53 | Re: Wikipedia on Postgres (was Re: postgresql vs mysql) |
Previous Message | Noel Faux | 2007-02-25 09:00:50 | Re: Inserting a new column in between. |
From | Date | Subject | |
---|---|---|---|
Next Message | joseph speigle | 2007-02-26 01:45:59 | trigger not firing |
Previous Message | Noel Faux | 2007-02-25 09:00:50 | Re: Inserting a new column in between. |