pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Lockhart <lockhart@alumni.caltech.edu>
To: t-ishii@sra.co.jp
To: robertC@opmr.com
Cc: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] How do I drop a column from a table?
Date: Tue, 31 Aug 1999 14:21:53 +0000
Message-ID: <37CBE501.6BC68052@alumni.caltech.edu> (raw)
References: <199908311359.WAA00554@ext04.sra.co.jp>

> > 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



view thread (8+ messages)  latest in thread

Message-ID: <37CBE501.6BC68052@alumni.caltech.edu>
Permalink:  ../37CBE501.6BC68052@alumni.caltech.edu/
Also on:    postgresql.org/message-id/37CBE501.6BC68052@alumni.caltech.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: lockhart@alumni.caltech.edu, t-ishii@sra.co.jp, robertC@opmr.com
  Subject: Re: [INTERFACES] How do I drop a column from a table?
  In-Reply-To: <37CBE501.6BC68052@alumni.caltech.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox