Re: [INTERFACES] How do I drop a column from a table?

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: t-ishii(at)sra(dot)co(dot)jp, robertC(at)opmr(dot)com
Cc: pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] How do I drop a column from a table?
Date: 1999-08-31 14:21:53
Message-ID: 37CBE501.6BC68052@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

> > Adding columns is directly supported. Removing columns, or redefining
> > them, is done with a CREATE TABLE AS/DROP TABLE/CREATE TABLE AS/DROP
> > TABLE sequence, where you write the columns you want to retain into a
> > temporary table, delete the original table, and then do the same back
> > into a new table with the same name as the original.
> But this method might lose some characteristics such as primary key,
> unique constraints, no?

OK, then CREATE TABLE AS/DROP TABLE/CREATE TABLE/INSERT/DROP TABLE,
where the CREATE TABLE can include all relevant characteristics.

btw, Tatsuo reminds me that if you have a SERIAL type, you will need
to retain the underlying sequence which supports it, define the column
in the new table as an INT, and define the DEFAULT clause for it to
reference the sequence explicitly.

- Thomas

--
Thomas Lockhart lockhart(at)alumni(dot)caltech(dot)edu
South Pasadena, California

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Rusty Brooks 1999-08-31 14:25:24 Re: [INTERFACES] ODBC Questions
Previous Message Tatsuo Ishii 1999-08-31 13:59:38 Re: [INTERFACES] How do I drop a column from a table?