Orlando Andico wrote:
> 
> On Wed, 18 Jul 2001, Percy wrote:
> ..
> > hello all!
> >
> > how to drop columns in postgresql?
> 
> according to pg expert Mike, hindi pwede. Alam ko hindi rin pwede sa
> Oracle. The way to do it is
> 
> CREATE TABLE new_table AS SELECT list_of_columns FROM old_table;
> DROP TABLE old_table;
> CREATE VIEW old_table AS SELECT * from new_table;
> 
> although pg allows table renaming so you prolly don't need the CREATE
> VIEW. oracle needs it though.

Then you still have to ALTER TABLE to add constraints and defaults,
re-create the indexes that are created automagically, re-establish any
referential integrity constraints referring to other tables, etc.

Much easier just to get it right at CREATE TABLE time, or learn to live
with the overhead of the unused columns.

Brian
_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]

To subscribe to the Linux Newbies' List: send "subscribe" in the body to 
[EMAIL PROTECTED]

Reply via email to