Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-interfaces by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group