pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Steve Doerr <sdoerr@swbell.net>
To: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Modifying existing tables
Date: Thu, 02 Aug 2001 22:37:37 -0500
Message-ID: <3B6A1C81.2D9D4E70@swbell.net> (raw)

Is this the only way to add attributes to an existing table, and add
unique and a default(for example) to existing attributes?

Just wondered if there are alternatives.  I didn't really see this in
the docs or mailing lists.

Thanks for any input.
Steve

original table:
CREATE TABLE table (
    attrib1 int,
    attrib2 int,
);


table edit:
CREATE TABLE newtable (
    attrib1 int UNIQUE,
    attrib2 int DEFAULT 1,
    attrib3 int
);

INSERT INTO newtable (attrib1, attrib2)
SELECT attrib1, attrib2 FROM table;

DROP TABLE table;
ALTER TABLE newtable RENAME TO table;





Message-ID: <3B6A1C81.2D9D4E70@swbell.net>
Permalink:  ../3B6A1C81.2D9D4E70@swbell.net/
Also on:    postgresql.org/message-id/3B6A1C81.2D9D4E70@swbell.net

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: sdoerr@swbell.net
  Subject: Re: Modifying existing tables
  In-Reply-To: <3B6A1C81.2D9D4E70@swbell.net>
  References: <3B6A1C81.2D9D4E70@swbell.net>

* 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