Re: ALTER DROP COLUMN

From: Fred Yankowski <fred(at)ontosys(dot)com>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ALTER DROP COLUMN
Date: 2001-02-12 21:40:33
Message-ID: 20010212154033.A24166@enteract.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I just tried this recommended procedure with a little test. It copied
over the Attribute and Type information and the primary key index, but
left everything else behind: not-null constraints, defaults,
references constraints, check constraints, sequence generated for
'serial' type -- to name a few.

So how is this useful for anything beyond a toy database?

This inability to drop a column makes it hard to follow an "extreme
programming" style of development, where one designs only as much into
the database schema as is needed at the moment (DTSTTCPW, YAGNI).
When I do that I often find that I need to drop columns (in favor of
other columns of different types) as I evolve the schema to support
ever more complex applications. PostgreSQL makes this a bit harder
than it needs to be.

On Mon, Feb 12, 2001 at 12:34:20PM -0800, Brent R. Matzelle wrote:
> I know it's a pain, but it isn't all that bad. Just rename your
> table like so:
>
> ALTER TABLE <old_name> RENAME TO <another_name>
>

> Then re-create the old table without the deleted column(s):
>
> SELECT col1, col2, col4 INTO TABLE <old_name> FROM
> <another_name>
>
> Then delete the old table:
>
> DROP TABLE <another_name>

--
Fred Yankowski fred(at)OntoSys(dot)com tel: +1.630.879.1312
Principal Consultant www.OntoSys.com fax: +1.630.879.1370
OntoSys, Inc 38W242 Deerpath Rd, Batavia, IL 60510, USA

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Barry Lind 2001-02-12 21:46:55 Re: How to make PostgreSQL JDBC drive get PGTZ?
Previous Message Laurel Williams 2001-02-12 21:28:48 Re: 7.1 Docs WAS:Auto-timestamp generator (attached)