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

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



pgsql-admin by date

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

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