Received: from wolff.to (wolff.to [66.92.219.49]) by postgresql.org (Postfix) with SMTP id 992A4475B5D for ; Tue, 23 Jul 2002 11:38:31 -0400 (EDT) Received: (qmail 24502 invoked by uid 500); 23 Jul 2002 15:44:36 -0000 Date: Tue, 23 Jul 2002 10:44:36 -0500 From: Bruno Wolff III To: Raphael Bauduin Cc: pgsql-admin@postgresql.org Subject: Re: CREATE TABLE AS ... Message-ID: <20020723154436.GA24446@wolff.to> Mail-Followup-To: Raphael Bauduin , pgsql-admin@postgresql.org References: <20020723134807.GB22069@raphael> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020723134807.GB22069@raphael> User-Agent: Mutt/1.3.25i X-Archive-Number: 200207/316 X-Sequence-Number: 5000 On Tue, Jul 23, 2002 at 15:48:07 +0200, Raphael Bauduin wrote: > Hi, > > In a data model change, I wanted to use the "create table as select" > feature. However, I want that table to have a primary key defined, and > thus a field defined as NOT NULL. I didn't find a way to add a NOT NULL > constraint on a column of an existing table. If there isn't, what's the > best way to go? A COPY? Another option is to use create table and insert select. The create can then set up the table exactly like you need. And then you can copy over data using insert selecting from the source table.