Modifying existing tables

From: Steve Doerr <sdoerr(at)swbell(dot)net>
To: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Modifying existing tables
Date: 2001-08-03 03:37:37
Message-ID: 3B6A1C81.2D9D4E70@swbell.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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;

Browse pgsql-admin by date

  From Date Subject
Next Message Jason 2001-08-03 11:50:01 A replication like process
Previous Message Tom Lane 2001-08-03 00:33:58 Re: Memory exhausted errors