Re: [INTERFACES] How do I drop a column from a table? - Mailing list pgsql-interfaces

From Thomas Lockhart
Subject Re: [INTERFACES] How do I drop a column from a table?
Date
Msg-id 37CBE501.6BC68052@alumni.caltech.edu
Whole thread Raw
In response to Re: [INTERFACES] How do I drop a column from a table?  (Tatsuo Ishii <t-ishii@sra.co.jp>)
List 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@alumni.caltech.edu
South Pasadena, California


pgsql-interfaces by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: [INTERFACES] How do I drop a column from a table?
Next
From: Rusty Brooks
Date:
Subject: Re: [INTERFACES] ODBC Questions